{
  "schema_version": "1.0",
  "nodes": [
    {
      "id": "brief",
      "type": "input/text",
      "label": "Topic and facts",
      "parameters": {
        "multiline": true,
        "required": true,
        "text": "Topic: caring for an olive tree in a pot on a terrace (city customers, beginners).\nFacts to use: water deeply then let the top 5 cm dry; at least 6 hours of direct sun; slow-release Mediterranean feed in March; below -5 °C wrap the pot in fleece and raise it off the floor.\nOffer this month: every olive tree comes with its terracotta pot."
      }
    },
    {
      "id": "cover_photo",
      "type": "input/image",
      "label": "Cover photo",
      "parameters": {
        "image": "__COVER_PHOTO_ASSET_PATH__",
        "required": true
      }
    },
    {
      "id": "writer",
      "type": "ai/text_generation",
      "label": "Write the carousel",
      "parameters": {
        "response_format": "json_object",
        "temperature": 0.6,
        "max_tokens": 2500,
        "system_prompt": "You write an Instagram carousel for a garden centre, in English, friendly and practical.\nUse only the facts in the brief; never invent prices, offers, numbers or plant facts that the brief does not give.\nReturn one JSON object and nothing else:\n{ \"kicker\": \"capitals, the number of tips and the subject, at most 28 characters\",\n  \"cover_title\": \"at most 60 characters\",\n  \"tips\": [ { \"title\": \"10 to 60 characters\", \"body\": \"60 to 220 characters\" } ]  (3 to 5 tips, one per fact),\n  \"cta\": \"the offer as an invitation, 20 to 110 characters\" }"
      }
    },
    {
      "id": "copy_contract",
      "type": "utility/json_schema_validate",
      "label": "Copy fits the slides",
      "parameters": {
        "schema_source": "inline",
        "schema_definition": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kicker",
            "cover_title",
            "tips",
            "cta"
          ],
          "properties": {
            "kicker": {
              "type": "string",
              "minLength": 6,
              "maxLength": 28,
              "description": "Capitals, e.g. \"4 TIPS FOR YOUR TERRACE\"."
            },
            "cover_title": {
              "type": "string",
              "minLength": 15,
              "maxLength": 60
            },
            "tips": {
              "type": "array",
              "minItems": 3,
              "maxItems": 5,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "title",
                  "body"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 60
                  },
                  "body": {
                    "type": "string",
                    "minLength": 60,
                    "maxLength": 220
                  }
                }
              }
            },
            "cta": {
              "type": "string",
              "minLength": 20,
              "maxLength": 110
            }
          }
        },
        "mode": "fail"
      }
    },
    {
      "id": "render",
      "type": "design/template_render",
      "label": "Compose the slides",
      "parameters": {
        "template_id": "__TEMPLATE_ID__",
        "template_revision": "__TEMPLATE_REVISION__",
        "output": "pages",
        "page_selection": "all",
        "missing_policy": "fail_required",
        "overflow_policy": "template",
        "max_repeat": 5
      }
    },
    {
      "id": "slides",
      "type": "output/json",
      "label": "Slides (page images)",
      "parameters": {}
    },
    {
      "id": "copy_output",
      "type": "output/json",
      "label": "Carousel copy",
      "parameters": {}
    }
  ],
  "connections": [
    {
      "from_node": "brief",
      "from_output": "text",
      "to_node": "writer",
      "to_input": "prompt"
    },
    {
      "from_node": "writer",
      "from_output": "json",
      "to_node": "copy_contract",
      "to_input": "document"
    },
    {
      "from_node": "copy_contract",
      "from_output": "normalized_json",
      "to_node": "render",
      "to_input": "data"
    },
    {
      "from_node": "cover_photo",
      "from_output": "image",
      "to_node": "render",
      "to_input": "cover_photo"
    },
    {
      "from_node": "render",
      "from_output": "pages_manifest",
      "to_node": "slides",
      "to_input": "json"
    },
    {
      "from_node": "copy_contract",
      "from_output": "normalized_json",
      "to_node": "copy_output",
      "to_input": "json"
    }
  ]
}
