{
  "name": "Generate research-backed infographics with GPT-4, kie.ai, and Gmail",
  "nodes": [
    {
      "id": "50054b91-f707-4554-a4a5-fe16cc452f33",
      "name": "Build Image Prompt",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        288,
        -96
      ]
    },
    {
      "id": "3ec9937d-8285-40eb-97b4-446bacd33325",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        32,
        -96
      ]
    },
    {
      "id": "6225a140-0da7-4c7d-bafb-424f00a82b73",
      "name": "Generate Infographic",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        640,
        -96
      ]
    },
    {
      "id": "38f42d17-7e68-4740-887d-0b073bc65a15",
      "name": "Route by Job Status",
      "type": "n8n-nodes-base.switch",
      "position": [
        1248,
        -368
      ]
    },
    {
      "id": "3ebb7db3-b3b4-46d6-9c36-f67fea80dc0c",
      "name": "Download Generated Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1568,
        -720
      ]
    },
    {
      "id": "bde80cd1-0270-4049-b649-d3aedd645b6b",
      "name": "Email Image to User",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1840,
        -736
      ]
    },
    {
      "id": "0fd7d6f2-5eeb-46ee-b5ed-5fad5645e3af",
      "name": "Researcher",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        288,
        96
      ]
    },
    {
      "id": "a135b4c8-37c4-4ab4-8b04-2e0d291eab11",
      "name": "Polling Delay (15s)",
      "type": "n8n-nodes-base.wait",
      "position": [
        880,
        -160
      ]
    },
    {
      "id": "903cdf74-b9c7-4643-97db-b3b9ef74e54b",
      "name": "Increment Retry",
      "type": "n8n-nodes-base.code",
      "position": [
        1584,
        -384
      ]
    },
    {
      "id": "68103b4d-db4c-47a0-8eed-14c76b24db0f",
      "name": "Check Timeout",
      "type": "n8n-nodes-base.if",
      "position": [
        1760,
        -384
      ]
    },
    {
      "id": "80fda454-4c5d-410c-a1fd-06201e06ca8c",
      "name": "Check Job Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1072,
        -160
      ]
    },
    {
      "id": "659856d2-8dbd-46cc-afd6-2670ec0a7b69",
      "name": "Prepare Error Email",
      "type": "n8n-nodes-base.code",
      "position": [
        2192,
        -80
      ]
    },
    {
      "id": "c7b29f15-8cbf-458d-b67b-21d671f3cabc",
      "name": "Send Error Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2368,
        -80
      ]
    },
    {
      "id": "75f9b6a5-a226-4b23-b7fb-fcc84871719c",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        -848
      ],
      "parameters": {
        "width": 380,
        "height": 1124,
        "content": "## 🖼️ AI Infographic Generator\n\n**Generate research-backed, professionally designed infographics using GPT-4 web search and kie.ai's image AI - no design skills needed.**\n\n---\n\n### Who is this for\n- M"
      }
    },
    {
      "id": "b941f1b4-80d2-41d1-87c5-9adfc0e4a086",
      "name": "Section: User Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -224
      ],
      "parameters": {
        "width": null,
        "height": 340,
        "content": "## ① User Input"
      }
    },
    {
      "id": "271fed77-dd09-4619-a75f-397241144bbb",
      "name": "Section: AI Prompt Engineering",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -336
      ],
      "parameters": {
        "width": 280,
        "height": 588,
        "content": "## ② AI Prompt Engineering\nGPT-4 with web search researches your topic and writes an optimized image generation prompt."
      }
    },
    {
      "id": "4f25c833-247e-4a8e-be96-ec1607e83143",
      "name": "Section: Generate and Poll",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -496
      ],
      "parameters": {
        "width": 870,
        "height": 586,
        "content": "## ③ Generate & Poll\nSubmits the job to kie.ai, then polls every 15s until complete, failed, or timed out (20 retries max)."
      }
    },
    {
      "id": "240f1056-2d02-4469-9d38-afb3b2b5d065",
      "name": "Section: Success Path",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        -848
      ],
      "parameters": {
        "width": 560,
        "height": 290,
        "content": "## ④ Success\nDownloads the generated image and emails it as an attachment."
      }
    },
    {
      "id": "d4e53401-8f75-4203-ae82-9ecaeb32c536",
      "name": "Section: Error Handling",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        -496
      ],
      "parameters": {
        "width": 1080,
        "height": 576,
        "content": "## ⑤ Error Handling\nHandles 3 failure scenarios: generation failure, polling timeout (>20 retries), and API errors. Sends a descriptive error email for each case."
      }
    }
  ],
  "connections": {
    "Researcher": {
      "ai_languageModel": [
        [
          {
            "node": "Build Image Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check Timeout": {
      "main": [
        [
          {
            "node": "Prepare Error Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Polling Delay (15s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Increment Retry": {
      "main": [
        [
          {
            "node": "Check Timeout",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Job Status": {
      "main": [
        [
          {
            "node": "Route by Job Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Image Prompt": {
      "main": [
        [
          {
            "node": "Generate Infographic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Build Image Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Polling Delay (15s)": {
      "main": [
        [
          {
            "node": "Check Job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Error Email": {
      "main": [
        [
          {
            "node": "Send Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Job Status": {
      "main": [
        [
          {
            "node": "Download Generated Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Increment Retry",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Infographic": {
      "main": [
        [
          {
            "node": "Polling Delay (15s)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Generated Image": {
      "main": [
        [
          {
            "node": "Email Image to User",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}