From ccfeb66b736ee3a256417768881da0e8300559b4 Mon Sep 17 00:00:00 2001 From: nusquama Date: Sun, 15 Mar 2026 12:00:54 +0800 Subject: [PATCH] creation --- ...research-backed_infographics_with_gpt-4_kie.ai_and_gmail.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 workflows/Generate research-backed infographics with GPT-4, kie.ai, and Gmail-14000/generate_research-backed_infographics_with_gpt-4_kie.ai_and_gmail.json diff --git a/workflows/Generate research-backed infographics with GPT-4, kie.ai, and Gmail-14000/generate_research-backed_infographics_with_gpt-4_kie.ai_and_gmail.json b/workflows/Generate research-backed infographics with GPT-4, kie.ai, and Gmail-14000/generate_research-backed_infographics_with_gpt-4_kie.ai_and_gmail.json new file mode 100644 index 000000000..1d0ecc2dc --- /dev/null +++ b/workflows/Generate research-backed infographics with GPT-4, kie.ai, and Gmail-14000/generate_research-backed_infographics_with_gpt-4_kie.ai_and_gmail.json @@ -0,0 +1 @@ +{"id":"Xaq4lLIaOk0q0mDx","meta":{"instanceId":"faddc4774f9b11649df4b718ccf1c47f344f37c56ff4332e644ffd2e950d4758","templateCredsSetupCompleted":true},"name":"Generate Research-Backed Infographics with AI and kie.ai","tags":[],"nodes":[{"id":"50054b91-f707-4554-a4a5-fe16cc452f33","name":"Build Image Prompt","type":"@n8n/n8n-nodes-langchain.agent","position":[288,-96],"parameters":{"text":"=### ROLE\nYou are a world-class Art Director and Prompt Engineer specializing in generative AI for information design. Your goal is to take user requirements and convert them into a highly optimized image generation prompt for a diffusion model.\n\n### YOUR GOAL\nCreate a prompt that results in a clean, legible, and professional infographic. You must prioritize \"readability\" and \"composition\" over artistic flair.\n\n### INPUT DATA\n- Headline: {{ $json['Main Headline'] }}\n- Data Points: {{ $json['Key Data Points'] }}\n- Layout: {{ $json['Layout Structure'] }}\n- Visualization Types: {{ $json['Visualization Options'] }}\n- Tone of Voice: {{ $json['Tone of Voice'] }}\n- Style: {{ $json['Art Style'] }}\n- Information Density: {{ $json['Information Density'] }}\n- Font Family: {{ $json['Font Family'] }}\n- Colors: {{ $json['Color Palette'] }}\n\n### TOOLS\nUse the \"Researcher\" model, which has access to the Internet, to gather the \"Data Points\" that are needed for the infographic.\n\n### PROMPT STRUCTURE RULES\n1. **Subject & Layout:** Start by defining the image type strictly (e.g., \"A vertical infographic vector illustration...\").\n2. **Text Handling:** Modern AI models (like Flux or SD3) can render text if it is capitalized and wrapped in quotes. You MUST extract the \"Headline\" and place it in the prompt as: text \"HEADLINE HERE\". Do not try to fit all data points as literal text; summarize them as visual icons or short labels.\n3. **Style Descriptors:** Use keywords that enforce cleanliness: \"white space,\" \"margins,\" \"grid layout,\" \"vector graphics,\" \"adobe illustrator style,\" \"high resolution.\"\n4. **Negative Weighting (Implicit):** phrasing matters. Avoid \"cluttered,\" \"messy,\" \"illegible.\"\n\n### OUTPUT FORMAT\nReturn ONLY the raw prompt string to be sent to the image generator. Do not add conversational filler or the URLs of the sources for \"Data Points\".\n\n### DYNAMIC PROMPT TEMPLATE (Use this logic)\n\"[Style] infographic featuring text ' [Headline] ' at the top. The layout is [Layout]. Preferred visualization types: [Visualization Types]. Tone of voice: [Tone of Voice]. Art style: [Style]. Information density: [Information Density]. Preferred font family [Font Family]. The design uses a [Colors] color scheme.\nKey visual elements include: [Convert 'Data Points' into visual metaphors, e.g., if data is 'costs down', describe a downward arrow or coin stack].\nHigh quality, professional graphic design, flat vector art, precise lines, extra white space for readability, typography focused.\"","options":{},"promptType":"define"},"typeVersion":3},{"id":"3ec9937d-8285-40eb-97b4-446bacd33325","name":"On form submission","type":"n8n-nodes-base.formTrigger","position":[32,-96],"webhookId":"93666a9c-8cea-4e39-8a1c-7338226cc491","parameters":{"options":{"appendAttribution":false},"formTitle":"Infographics Maker","formFields":{"values":[{"fieldType":"textarea","fieldLabel":"Main Headline","placeholder":"The Future of Solar Energy (5-7 words)","requiredField":true},{"fieldType":"textarea","fieldLabel":"Key Data Points","placeholder":"What the infographic is about (Global Market Outlook for Solar Power 2025-2030)","requiredField":true},{"fieldType":"dropdown","fieldLabel":"Target Audience","fieldOptions":{"values":[{"option":"Corporate"},{"option":"Educational"},{"option":"Social Media"},{"option":"Technical"}]},"requiredField":true},{"fieldType":"dropdown","fieldLabel":"Tone of Voice","fieldOptions":{"values":[{"option":"Professional"},{"option":"Marketing"},{"option":"Neutral"},{"option":"Urgent"},{"option":"Casual"}]},"requiredField":true},{"fieldType":"dropdown","fieldLabel":"Visualization Options","fieldOptions":{"values":[{"option":"Prioritize Charts/Graphs"},{"option":"Use Icons & Illustrations"},{"option":"Incorporate Maps"},{"option":"Use Photo Realistic Elements"}]},"requiredField":true},{"fieldType":"dropdown","fieldLabel":"Art Style","fieldOptions":{"values":[{"option":"Flat Vector"},{"option":"Isometric"},{"option":"Corporate Memphis"},{"option":"Neon/Cyberpunk"},{"option":"Hand-Drawn/Sketch"},{"option":"Retro Pop Art"}]},"requiredField":true},{"fieldLabel":"Color Palette","placeholder":"Teal and Orange, Monochrome Blue, Pastel, etc.","requiredField":true},{"fieldType":"dropdown","fieldLabel":"Layout Structure","fieldOptions":{"values":[{"option":"Vertical flow from top to bottom"},{"option":"Horizontal linear flow from left to right"},{"option":"Comparison: Split screen (Left vs Right)"},{"option":"Central Hub / Mindmap"},{"option":"Step-by-Step: Numbered list layout"},{"option":"Modular Grid"}]},"requiredField":true},{"fieldType":"dropdown","fieldLabel":"Font Family","fieldOptions":{"values":[{"option":"Modern Sans (Roboto/Helvetica)"},{"option":"Classic Serif (Garamond/Times)"},{"option":"Bold Headline (Oswald/Impact)"},{"option":"Tech/Code (Courier/Monospace)"},{"option":"Handwritten (Marker Style)"},{"option":"Elegant/Script (Cursive)"}]},"requiredField":true},{"fieldType":"radio","fieldLabel":"Information Density","fieldOptions":{"values":[{"option":"Minimalist"},{"option":"Balanced"},{"option":"Detailed"}]},"requiredField":true},{"fieldType":"dropdown","fieldLabel":"Aspect Ratio","fieldOptions":{"values":[{"option":"9:16"},{"option":"2:3"},{"option":"3:4"},{"option":"4:5"},{"option":"1:1"},{"option":"5:4"},{"option":"4:3"},{"option":"3:2"},{"option":"16:9"},{"option":"21:9"}]},"requiredField":true},{"fieldType":"radio","fieldLabel":"Resolution","fieldOptions":{"values":[{"option":"1K"},{"option":"2K"},{"option":"4K"}]},"requiredField":true},{"fieldType":"radio","fieldLabel":"Output Format","fieldOptions":{"values":[{"option":"png"},{"option":"jpg"}]},"requiredField":true}]},"formDescription":"Use AI to Generate Well-Researched, High-Quality Infographics"},"typeVersion":2.3},{"id":"6225a140-0da7-4c7d-bafb-424f00a82b73","name":"Generate Infographic","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[640,-96],"parameters":{"url":"https://api.kie.ai/api/v1/jobs/createTask","method":"POST","options":{"response":{"response":{"neverError":true}}},"jsonBody":"={\n \"model\": \"nano-banana-pro\",\n \"input\": {\n \"prompt\": {{ JSON.stringify($json.output) }},\n \"aspect_ratio\": \"{{ $('On form submission').item.json['Aspect Ratio'] }}\",\n \"resolution\": \"{{ $('On form submission').item.json.Resolution }}\",\n \"output_format\": \"{{ $('On form submission').item.json['Output Format'] }}\"\n }\n}","sendBody":true,"specifyBody":"json","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth"},"credentials":{"httpHeaderAuth":{"id":"credential-id","name":"kie.ai API"}},"typeVersion":4.3},{"id":"38f42d17-7e68-4740-887d-0b073bc65a15","name":"Route by Job Status","type":"n8n-nodes-base.switch","position":[1248,-368],"parameters":{"rules":{"values":[{"outputKey":"success","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"6d7bc14d-465e-4b88-b48d-0503d907df91","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.state }}","rightValue":"success"}]},"renameOutput":true},{"outputKey":"pending","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"or","conditions":[{"id":"783eaa29-4339-479f-8069-60344d0210fb","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.state }}","rightValue":"waiting"},{"id":"pending-generating","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.state }}","rightValue":"generating"}]},"renameOutput":true},{"outputKey":"fail","conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"1db6f4f3-e726-4874-8b48-403809b1cbb4","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.data.state }}","rightValue":"fail"}]},"renameOutput":true}]},"options":{"fallbackOutput":2}},"typeVersion":3.3},{"id":"3ebb7db3-b3b4-46d6-9c36-f67fea80dc0c","name":"Download Generated Image","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[1568,-720],"parameters":{"url":"={{ JSON.parse($json.data.resultJson).resultUrls[0] }}","options":{"response":{"response":{"neverError":true}}}},"typeVersion":4.3},{"id":"bde80cd1-0270-4049-b649-d3aedd645b6b","name":"Email Image to User","type":"n8n-nodes-base.gmail","position":[1840,-736],"webhookId":"2358cbe0-2b28-44a3-9a77-43a737850c38","parameters":{"sendTo":"user@example.com","message":"Hi, the new infographic is attached to this email.","options":{"attachmentsUi":{"attachmentsBinary":[{}]},"appendAttribution":false},"subject":"New infographic generated"},"credentials":{"gmailOAuth2":{"id":"credential-id","name":"Gmail account"}},"typeVersion":2.1},{"id":"0fd7d6f2-5eeb-46ee-b5ed-5fad5645e3af","name":"Researcher","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[288,96],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4.1-mini"},"options":{},"builtInTools":{"webSearch":{"searchContextSize":"medium"}}},"credentials":{"openAiApi":{"id":"credential-id","name":"OpenAi account"}},"typeVersion":1.3},{"id":"a135b4c8-37c4-4ab4-8b04-2e0d291eab11","name":"Polling Delay (15s)","type":"n8n-nodes-base.wait","position":[880,-160],"webhookId":"b1574e93-c8fb-4a6d-af7c-1e7bdc98ab8d","parameters":{"amount":15},"typeVersion":1.1},{"id":"903cdf74-b9c7-4643-97db-b3b9ef74e54b","name":"Increment Retry","type":"n8n-nodes-base.code","position":[1584,-384],"parameters":{"jsCode":"const staticData = $getWorkflowStaticData('global');\n\n// Auto-reset for each new workflow execution\nif (staticData.lastExecutionId !== $execution.id) {\n staticData.retryCount = 0;\n staticData.lastExecutionId = $execution.id;\n}\n\nconst retryCount = (staticData.retryCount || 0) + 1;\nstaticData.retryCount = retryCount;\n\nconst taskId = $input.first().json.data?.taskId || $input.first().json.taskId;\n\nreturn [{ json: { retryCount, taskId } }];"},"typeVersion":2},{"id":"68103b4d-db4c-47a0-8eed-14c76b24db0f","name":"Check Timeout","type":"n8n-nodes-base.if","position":[1760,-384],"parameters":{"options":{},"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"timeout-check","operator":{"type":"number","operation":"gt"},"leftValue":"={{ $json.retryCount }}","rightValue":20}]}},"typeVersion":2.2},{"id":"80fda454-4c5d-410c-a1fd-06201e06ca8c","name":"Check Job Status","type":"n8n-nodes-base.httpRequest","onError":"continueErrorOutput","position":[1072,-160],"parameters":{"url":"https://api.kie.ai/api/v1/jobs/recordInfo","options":{"response":{"response":{"neverError":true}}},"sendQuery":true,"authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","queryParameters":{"parameters":[{"name":"taskId","value":"={{ $json.data?.taskId ?? $json.taskId }}"}]}},"credentials":{"httpHeaderAuth":{"id":"credential-id","name":"kie.ai API"}},"typeVersion":4.3},{"id":"659856d2-8dbd-46cc-afd6-2670ec0a7b69","name":"Prepare Error Email","type":"n8n-nodes-base.code","position":[2192,-80],"parameters":{"jsCode":"const input = $input.first().json;\nconst formData = $('On form submission').item.json;\nlet subject, body;\n\nif (input.data?.state === 'fail') {\n subject = 'Infographic generation failed';\n body = `Hi,\\n\\nThe infographic generation failed.\\n\\n**Error Details:**\\n${input.data.errorMessage || 'Unknown error'}\\n\\n**Task ID:** ${input.data.taskId || input.taskId || 'unknown'}\\n\\n**Original Request:**\\n- Headline: ${formData['Main Headline']}\\n- Data Points: ${formData['Key Data Points']}\\n- Style: ${formData['Art Style']}\\n- Layout: ${formData['Layout Structure']}\\n- Aspect Ratio: ${formData['Aspect Ratio']}\\n- Resolution: ${formData['Resolution']}`;\n} else if (input.retryCount !== undefined) {\n subject = 'Infographic generation timed out';\n body = `Hi,\\n\\nThe infographic generation timed out after 20 polling attempts.\\n\\n**Task ID:** ${input.taskId || 'unknown'}\\n\\n**Original Request:**\\n- Headline: ${formData['Main Headline']}\\n- Data Points: ${formData['Key Data Points']}\\n- Style: ${formData['Art Style']}\\n- Layout: ${formData['Layout Structure']}\\n- Aspect Ratio: ${formData['Aspect Ratio']}\\n- Resolution: ${formData['Resolution']}\\n\\nPlease check the kie.ai dashboard for more details.`;\n} else {\n subject = 'Infographic API Error';\n body = `Hi,\\n\\nAn API error occurred during infographic generation.\\n\\n**Error Details:**\\n${JSON.stringify(input, null, 2)}\\n\\n**Original Request:**\\n- Headline: ${formData['Main Headline']}\\n- Data Points: ${formData['Key Data Points']}\\n- Style: ${formData['Art Style']}\\n- Layout: ${formData['Layout Structure']}`;\n}\n\nreturn [{ json: { subject, body } }];"},"typeVersion":2},{"id":"c7b29f15-8cbf-458d-b67b-21d671f3cabc","name":"Send Error Email","type":"n8n-nodes-base.gmail","position":[2368,-80],"webhookId":"16c69acf-83f9-4ee4-91ae-efb96c928890","parameters":{"sendTo":"user@example.com","message":"={{ $json.body }}","options":{"appendAttribution":false},"subject":"={{ $json.subject }}"},"credentials":{"gmailOAuth2":{"id":"credential-id","name":"Gmail account"}},"typeVersion":2.1},{"id":"75f9b6a5-a226-4b23-b7fb-fcc84871719c","name":"Overview","type":"n8n-nodes-base.stickyNote","position":[-576,-848],"parameters":{"color":4,"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- Marketers & content creators who need data-driven visuals fast\n- Educators and consultants producing professional infographics\n- Anyone who wants to turn a topic into a polished visual without Canva or Photoshop\n\n---\n\n### How it works\n1. User fills in a form (headline, topic, style, layout, colors, resolution, etc.)\n2. An AI Agent (GPT-4 with web search) researches the topic and writes an optimized image generation prompt\n3. The prompt is sent to **kie.ai** (nano-banana-pro model) to generate the infographic\n4. The workflow polls for completion every 15 seconds (up to 20 retries / ~5 min)\n5. On success: the image is downloaded and emailed as an attachment\n6. On failure or timeout: a detailed error email is sent instead\n\n---\n\n### Setup\n1. **OpenAI** - Add your OpenAI API key to the `Researcher` node credential\n2. **kie.ai** - Add your kie.ai Bearer token to a `Header Auth` credential and connect it to `Generate Infographic` and `Check Job Status`\n3. **Gmail** - Connect your Gmail account to `Email Image to User` and `Send Error Email`\n4. Update the recipient (To) email address in both Gmail nodes\n5. Activate the workflow and open the form URL"},"typeVersion":1},{"id":"b941f1b4-80d2-41d1-87c5-9adfc0e4a086","name":"Section: User Input","type":"n8n-nodes-base.stickyNote","position":[-32,-224],"parameters":{"color":5,"height":340,"content":"## ① User Input"},"typeVersion":1},{"id":"271fed77-dd09-4619-a75f-397241144bbb","name":"Section: AI Prompt Engineering","type":"n8n-nodes-base.stickyNote","position":[256,-336],"parameters":{"color":5,"width":280,"height":588,"content":"## ② AI Prompt Engineering\nGPT-4 with web search researches your topic and writes an optimized image generation prompt."},"typeVersion":1},{"id":"4f25c833-247e-4a8e-be96-ec1607e83143","name":"Section: Generate and Poll","type":"n8n-nodes-base.stickyNote","position":[576,-496],"parameters":{"color":5,"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)."},"typeVersion":1},{"id":"240f1056-2d02-4469-9d38-afb3b2b5d065","name":"Section: Success Path","type":"n8n-nodes-base.stickyNote","position":[1488,-848],"parameters":{"color":2,"width":560,"height":290,"content":"## ④ Success\nDownloads the generated image and emails it as an attachment."},"typeVersion":1},{"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."},"typeVersion":1}],"active":false,"pinData":{},"settings":{"callerPolicy":"workflowsFromSameOwner","errorWorkflow":"Nin8EYMkR9vuyKPp","timeSavedMode":"fixed","availableInMCP":false,"executionOrder":"v1","timeSavedPerExecution":300},"versionId":"d37a673b-86d1-4548-88e4-82dd45ede353","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}]]}}} \ No newline at end of file