{
  "schema_version": "1.0",
  "nodes": [
    {
      "id": "course",
      "type": "input/json_value",
      "label": "Course (from the school)",
      "parameters": {
        "required": true
      }
    },
    {
      "id": "course_text",
      "type": "utility/extract",
      "label": "Course as text",
      "parameters": {
        "path": "$",
        "expected_type": "json",
        "on_missing": "fail"
      }
    },
    {
      "id": "brief",
      "type": "text/template",
      "label": "Course for the writer",
      "parameters": {
        "template": "CORSO (dati della scuola, JSON)\n[course]",
        "placeholders": [
          {
            "name": "course",
            "inputPort": "course"
          }
        ]
      }
    },
    {
      "id": "writer",
      "type": "ai/text_generation",
      "label": "Write the headline and the reasons",
      "parameters": {
        "system_prompt": "You write the posters of Parola, a network of language schools in Italy.\nFrom the facts of one course, write in Italian, warm and direct, for adults who are thinking about joining.\n\nReturn one JSON object and nothing else:\n{\n  \"headline\": \"the promise of the course, at most 34 characters, may contain one short word in the course language\",\n  \"subhead\": \"one sentence, at most 80 characters\",\n  \"reasons\": [ { \"text\": \"at most 52 characters\" } ]  — exactly 3 reasons to join\n}\n\nRules:\n- Use only the facts given. Never invent teachers, certificates, discounts, places or numbers.\n- Do not write the price, the dates, the schedule, the address or the contacts: the poster prints them.\n- No exclamation marks, no superlatives.",
        "response_format": "json_object",
        "temperature": 0.6,
        "max_tokens": 4000
      }
    },
    {
      "id": "copy_contract",
      "type": "utility/json_schema_validate",
      "label": "Words fit the poster",
      "parameters": {
        "schema_source": "inline",
        "schema_definition": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "headline",
            "subhead",
            "reasons"
          ],
          "properties": {
            "headline": {
              "type": "string",
              "minLength": 6,
              "maxLength": 38
            },
            "subhead": {
              "type": "string",
              "minLength": 10,
              "maxLength": 88
            },
            "reasons": {
              "type": "array",
              "minItems": 3,
              "maxItems": 3,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 6,
                    "maxLength": 58
                  }
                }
              }
            }
          }
        },
        "mode": "fail"
      }
    },
    {
      "id": "render",
      "type": "design/template_render",
      "label": "Compose the poster",
      "parameters": {
        "template_id": "__TEMPLATE_ID__",
        "template_revision": "__TEMPLATE_REVISION__",
        "output": "both",
        "page_selection": "all",
        "missing_policy": "fail_required",
        "overflow_policy": "template",
        "max_repeat": 3
      }
    },
    {
      "id": "poster_pdf",
      "type": "output/pdf",
      "label": "Poster — PDF",
      "parameters": {
        "output_name": "poster_pdf"
      }
    },
    {
      "id": "poster_image",
      "type": "output/image",
      "label": "Poster — image",
      "parameters": {
        "output_name": "poster_image"
      }
    },
    {
      "id": "copy_output",
      "type": "output/json",
      "label": "Approved words",
      "parameters": {
        "output_name": "poster_copy"
      }
    }
  ],
  "connections": [
    {
      "from_node": "course",
      "from_output": "json",
      "to_node": "course_text",
      "to_input": "json"
    },
    {
      "from_node": "course_text",
      "from_output": "value",
      "to_node": "brief",
      "to_input": "course"
    },
    {
      "from_node": "brief",
      "from_output": "result",
      "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_0"
    },
    {
      "from_node": "course",
      "from_output": "json",
      "to_node": "render",
      "to_input": "data_1"
    },
    {
      "from_node": "render",
      "from_output": "pdf",
      "to_node": "poster_pdf",
      "to_input": "pdf"
    },
    {
      "from_node": "render",
      "from_output": "image",
      "to_node": "poster_image",
      "to_input": "image"
    },
    {
      "from_node": "copy_contract",
      "from_output": "normalized_json",
      "to_node": "copy_output",
      "to_input": "json"
    }
  ],
  "layout": {
    "nodes": {
      "course": {
        "x": 0,
        "y": 200
      },
      "course_text": {
        "x": 420,
        "y": 0
      },
      "brief": {
        "x": 840,
        "y": 0
      },
      "writer": {
        "x": 1260,
        "y": 0
      },
      "copy_contract": {
        "x": 1680,
        "y": 0
      },
      "render": {
        "x": 2100,
        "y": 200
      },
      "poster_pdf": {
        "x": 2540,
        "y": 120
      },
      "poster_image": {
        "x": 2540,
        "y": 280
      },
      "copy_output": {
        "x": 2100,
        "y": -160
      }
    }
  }
}
