This workflow corresponds to n8n.io template #9561 — we link there as the canonical source.
This workflow follows the Agent → Facebookgraphapi recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "qE2VKgGPG7Hxh7fI",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Telegram_Bot_Template",
"tags": [
{
"id": "vQcdMpzndwlrDhbx",
"name": "n8n_official_template",
"createdAt": "2025-07-02T13:54:20.087Z",
"updatedAt": "2025-07-02T13:54:20.087Z"
}
],
"nodes": [
{
"id": "bccb5336-76f0-4373-b35f-9d12798ccd1d",
"name": "Send a text message",
"type": "n8n-nodes-base.telegram",
"position": [
832,
112
],
"parameters": {
"text": "Waiting image ads on process...",
"chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "64c80d0a-8369-4c22-9f61-8e05f049d76f",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
448,
16
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "39ce8fb0-11c6-4c88-9121-4b909379ee34",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
608,
16
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"properties\": {\n \"image_url\": { \"type\": \"string\" },\n \"caption\": { \"type\": \"string\" },\n \"analyzed_description\": { \"type\": \"string\" },\n \"num_variations\": { \"type\": \"integer\", \"minimum\": 1 },\n \"variations\": {\n \"type\": \"array\",\n \"minItems\": 1,\n \"items\": {\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"properties\": {\n \"variation_id\": { \"type\": \"integer\" },\n \"prompt\": { \"type\": \"string\" },\n \"style\": { \"type\": \"string\" },\n \"scene\": { \"type\": \"string\" },\n \"lighting\": { \"type\": \"string\" },\n \"camera\": { \"type\": \"string\" },\n \"composition\": { \"type\": \"string\" },\n \"background\": { \"type\": \"string\" },\n \"color_mood\": { \"type\": \"string\" },\n \"post_process\": { \"type\": \"string\" },\n \"marketing_angle\": { \"type\": \"string\" }\n },\n \"required\": [\"variation_id\", \"prompt\"]\n }\n }\n },\n \"required\": [\"image_url\", \"caption\", \"analyzed_description\", \"num_variations\", \"variations\"]\n}\n"
},
"typeVersion": 1.3
},
{
"id": "a9569805-f999-40e4-9374-1c2a1aef0d72",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"disabled": true,
"position": [
-960,
352
],
"parameters": {
"width": 2144,
"height": 256,
"content": "### \ud83d\udfe8 Zone 3: Generate & Confirm Ad Image (Fal.AI)\n**Purpose:** \nSend the prepared prompt to Fal.AI API to generate an advertising image, \nthen let the user confirm the result.\n**Main Steps:**\n1. **Prepare Fal.AI Input Fields** \u2013 Format prompt, image URL, and parameters for Fal.AI API. \n2. **Call Fal.AI API** \u2013 Generate the ad image using the given prompt. \n3. **Check Fal.AI Image Status** \u2013 Poll until image generation is completed. \n4. **Send Photo Message** \u2013 Deliver the generated image to the user on Telegram. \n5. **User Review: Approve/Reject Generated Image** \u2013 Ask the user to confirm the result. \n6. **Check Image Approval (Yes/No)** \u2013 Proceed only if user confirms."
},
"typeVersion": 1
},
{
"id": "e989e099-1885-4aad-846d-ea353f643750",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
352,
464
],
"parameters": {
"amount": 10
},
"typeVersion": 1.1
},
{
"id": "ac93bc19-c3a4-4a83-9433-847721bacd22",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-128,
768
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "8eca322c-5e42-41fe-920a-a8c2d02ac902",
"name": "Structured Output Parser1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
32,
768
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"platform\": \"facebook or instagram\",\n \"campaign\": \"string\",\n \"post_text\": \"string\",\n \"hashtags\": [\"#brand\", \"#product\", \"#promotion\", \"#campaign\"]\n}"
},
"typeVersion": 1.3
},
{
"id": "0165ada9-4d77-4a46-8eb6-7b2d675aa8e4",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"disabled": true,
"position": [
-960,
112
],
"parameters": {
"color": 3,
"width": 2144,
"height": 224,
"content": "#### \ud83d\udfe5 Zone 2: Create Advertising Image Prompt\n**Purpose:** \nGenerate an AI-ready advertising prompt using the analyzed image description and user input from Telegram.\n\n**Main Steps:**\n1. **User Review: Approve/Reject Ad Prompt** \u2013 Ask user for campaign details (e.g. \"10.10 Sale\"). \n2. **Revise Prompt Based on Feedback** \u2013 Create a clean, production-ready ad image prompt. \n3. **Send Text Message** \u2013 Send the generated prompt back to the user for review or confirmation."
},
"typeVersion": 1
},
{
"id": "a5dd96e0-2158-4e34-bb16-fbdfdd66fb6a",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"disabled": true,
"position": [
-960,
-128
],
"parameters": {
"color": 4,
"width": 2144,
"height": 224,
"content": "### \ud83d\udfe9 Zone 1: Product Image Analysis\n**Purpose:** \nReceive a product image from Telegram, extract the file path, and analyze the visual details of the product.\n\n**Main Steps:**\n1. **Receive Product Image (Telegram Trigger)** \u2013 Receive product photo or message from the user. \n2. **Get Telegram File Path** \u2013 Get the actual image file path via Telegram API. \n3. **Analyze Product Image** \u2013 Detect and describe product details such as brand, color, material, and packaging. \n4. **Generate Ad Prompt Draft** \u2013 Convert the analysis into structured text for later prompt generation.\n"
},
"typeVersion": 1
},
{
"id": "246a4cc8-4a13-4d04-8a98-de8d92ca2cb9",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"disabled": true,
"position": [
-960,
624
],
"parameters": {
"color": 5,
"width": 2144,
"height": 288,
"content": "### \ud83d\udfe6 Zone 4: Create Social Media Caption & Post to Facebook\n**Purpose:** \nAnalyze the final ad image, write a social media caption, and post automatically to Facebook or Instagram.\n**Main Steps:**\n1. **Analyze Final Ad Image (OpenAI Vision)** \u2013 Analyze the approved ad image for visual cues. \n2. **Generate Social Media Caption (AI Copywriter)** \u2013 Generate engaging Facebook/Instagram post text with emojis and hashtags. \n3. **User Review: Approve/Reject Caption** \u2013 Ask the user to approve the caption. \n4. **Check Caption Approval (Yes/No)** \u2013 Continue only if user approves. \n5. **Preview Post Image (Telegram)** \u2013 Show the preview of the post back to the user. \n6. **Publish Post to Facebook Page** \u2013 Upload the image and caption to Facebook Page automatically."
},
"typeVersion": 1
},
{
"id": "32bba9a2-7f30-49fe-8166-88e6ae6ea192",
"name": "Receive Product Image (Telegram Trigger)",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-160,
-96
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "5c693310-59db-474c-9f99-2a1f20d728f2",
"name": "Get Telegram File Path",
"type": "n8n-nodes-base.httpRequest",
"position": [
32,
-96
],
"parameters": {
"url": "=https://api.telegram.org/bot<YourBotToken>/getFile?file_id={{ $('Receive Product Image (Telegram Trigger)').item.json.message.photo[2].file_id }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "163841fd-657c-4bce-888e-52cc2e009a73",
"name": "Analyze Product Image (OpenAI Vision)",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
256,
-96
],
"parameters": {
"text": "=Depcribe the product and brand in this image in full detail. Fully ignore the background. Focus ONLY on the product.",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
},
"options": {},
"resource": "image",
"simplify": false,
"imageUrls": "=https://api.telegram.org/file/bot<YourBotToken>/{{ $json.result.file_path }}",
"operation": "analyze"
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.8
},
{
"id": "9b8758fe-6705-4ee0-aee3-23461852eff4",
"name": "Generate Ad Prompt Draft (from Image Analysis)",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
464,
-96
],
"parameters": {
"text": "=You will receive:\nhttps://api.telegram.org/file/bot<YourBotToken>/{{ $('Get Telegram File Path').item.json.result.file_path }}\n\n2. Caption: {{ $('Receive Product Image (Telegram Trigger)').item.json.message.caption }}\n3. Analyzed description: {{ $json.choices[0].message.content }}\n4. Number of variations: 1\n\nAnalyze them and generate **1** distinct, advertising-ready image generation prompts.\nUse the image as the factual base and the caption to infer campaign or creative direction.\n\nIf the caption mentions a campaign (e.g., \u201c10.10\u201d, \u201cChristmas\u201d, \u201cSongkran\u201d), apply its mood subtly and naturally.\nIf not, make general high-quality ad visuals.\n\nReturn **only** the JSON according to the schema in the system prompt.",
"options": {
"systemMessage": "=You are an **Advertising Image Prompt Designer**.\n\n### Inputs\nYou will receive:\n- product_image_url: the Telegram image URL of the real product (treat as ground truth)\n- caption: a short instruction describing what to create (e.g., \u201ccreate ads image for 10.10 campaign\u201d)\n- analyzed_description: AI-generated analysis text describing the product image (e.g., material, color, form, background)\n\n### Goal\nAnalyze both the **product image** and the **caption** to generate exactly **N distinct, production-ready advertising image prompts**.\nEach prompt should be visually distinct and directly usable with image generation models (e.g., SDXL, Midjourney, Flux, Veo).\n\n### Core Requirements\n1. Treat the product image as factual \u2014 keep **color, shape, texture, and logo** accurate.\n2. If the caption includes a campaign (e.g., \u201c10.10\u201d, \u201cSongkran\u201d, \u201cChristmas\u201d), apply **seasonal or promotional context** naturally and brand-safely:\n - **Halloween** \u2192 warm orange tones, moody light, pumpkins\n - **Songkran** \u2192 water splash, outdoor, bright festive vibe\n - **8.8 / 10.10 / 11.11** \u2192 energetic sale tone, bold accents, modern backgrounds\n - **Christmas** \u2192 cozy, pine, soft warm light, red/green accents\n3. If no campaign is mentioned or caption is generic, generate clean, timeless ad concepts.\n4. For each variation, vary **at least one** of these:\n - Scene / environment \n - Lighting setup \n - Camera angle or lens \n - Composition \n - Background texture or palette \n - Style or art direction \n5. Follow strictly the JSON schema below \u2014 **no extra text** or explanation outside the JSON.\n6. If a detail cannot be inferred, set it to an empty string \"\".\n7. All \u201cprompt\u201d values must be **one-line**, no breaks or newlines.\n\n### Quality Rules\n- Use clear and visual language (e.g., \u201csoft daylight on wooden desk\u201d) instead of vague adjectives.\n- Avoid fantasy or surrealism unless explicitly stated.\n- Favor **brand-safe, realistic advertising aesthetics**: packshots, lifestyle, editorial, cinematic.\n- Preserve the identity of the product \u2014 do not modify colors, text, or logos.\n- Include camera and lighting suggestions for realism.\n\n### Return Format\nReturn a **single JSON object only** (no commentary), following this schema:"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "c9b449e9-59b1-4f0d-8a26-e5a1831d03ac",
"name": "Assemble Prompt Parameters",
"type": "n8n-nodes-base.set",
"position": [
-160,
128
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "6cf14a49-26a8-4b61-8e85-effc1d930143",
"name": "caption",
"type": "string",
"value": "={{ $json.output.caption }}"
},
{
"id": "a2731356-2066-4aaa-9522-bc13aa45c6d4",
"name": "prompt",
"type": "string",
"value": "={{ $json.output.variations[0].prompt }}"
},
{
"id": "2d9ea9cd-de6e-41db-8e02-f4a2f4f2d820",
"name": "style",
"type": "string",
"value": "={{ $json.output.variations[0].style }}"
},
{
"id": "815948ae-196b-431e-bcc0-93c971e01596",
"name": "scene",
"type": "string",
"value": "={{ $json.output.variations[0].scene }}"
},
{
"id": "f98c06f9-ba7c-46ab-bb2a-5adc164a7127",
"name": "lighting",
"type": "string",
"value": "={{ $json.output.variations[0].lighting }}"
},
{
"id": "4a8cab78-9679-44f9-b307-9b70f656cc6b",
"name": "camera",
"type": "string",
"value": "={{ $json.output.variations[0].camera }}"
},
{
"id": "db2068bf-a273-40d2-a3e2-4d9348826688",
"name": "composition",
"type": "string",
"value": "={{ $json.output.variations[0].composition }}"
},
{
"id": "10bd62f1-44f6-4372-86e8-b22c2072a84e",
"name": "background",
"type": "string",
"value": "={{ $json.output.variations[0].background }}"
},
{
"id": "c81ebe8b-683e-4004-9382-e340190fc5f4",
"name": "color_mood",
"type": "string",
"value": "={{ $json.output.variations[0].color_mood }}"
},
{
"id": "1dd5535f-e410-45c1-8386-5981f0c55cd5",
"name": "marketing_angle",
"type": "string",
"value": "={{ $json.output.variations[0].marketing_angle }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "5500ed80-3304-456c-85b6-e28133d14337",
"name": "User Review: Approve/Reject Ad Prompt",
"type": "n8n-nodes-base.telegram",
"position": [
48,
128
],
"parameters": {
"chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
"message": "=**Caption:** {{ $json.caption }}\n\n**Prompt:** {{ $json.prompt }}\n\n**Style:** {{ $json.style }}\n\n**Scene:** {{ $json.scene }}\n\n**Lighting:** {{ $json.lighting }}\n\n**Camera:** {{ $json.camera }}\n\n**Composition:**{{ $json.composition }}\n\n**Background:** {{ $json.background }}\n\n**Color Mood:** {{ $json.color_mood }}\n\n**Marketing Angle:** {{ $json.marketing_angle }}",
"options": {
"appendAttribution": false
},
"operation": "sendAndWait",
"formFields": {
"values": [
{
"fieldType": "radio",
"fieldLabel": "Approval",
"fieldOptions": {
"values": [
{
"option": "Approve"
},
{
"option": "Reject"
}
]
},
"requiredField": true
},
{
"fieldLabel": "Comment",
"placeholder": "If you Reject, please comment to revise."
}
]
},
"responseType": "customForm"
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"executeOnce": true,
"typeVersion": 1.2
},
{
"id": "e0ef10fc-fbe7-4e9a-aa6d-495c3dbba207",
"name": "Check Prompt Approval (Yes/No)",
"type": "n8n-nodes-base.if",
"position": [
272,
128
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "26f47c7f-6a13-4bbe-87e3-cb980d86d2ea",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.data.Approval }}",
"rightValue": "Approve"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "065e5b88-011d-4c22-abbd-6988026aafe9",
"name": "Revise Prompt Based on Feedback",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
464,
144
],
"parameters": {
"text": "=You will receive:\n1.Product Image: https://api.telegram.org/file/bot<YourBotToken>/{{ $('Get Telegram File Path').item.json.result.file_path }}\n\n2. Caption: {{ $('Receive Product Image (Telegram Trigger)').item.json.message.caption }}\n3. Analyzed description: {{ $('Analyze Product Image (OpenAI Vision)').item.json.choices[0].message.content }}\n4. Number of variations: 1\n\n5. Additional Comment: {{ $json.data.Comment }}\n\nAnalyze them and generate **1** distinct, advertising-ready image generation prompts.\nUse the image as the factual base and the caption to infer campaign or creative direction.\n\nIf the caption mentions a campaign (e.g., \u201c10.10\u201d, \u201cChristmas\u201d, \u201cSongkran\u201d), apply its mood subtly and naturally.\nIf not, make general high-quality ad visuals.\n\nReturn **only** the JSON according to the schema in the system prompt.",
"options": {
"systemMessage": "=You are an **Advertising Image Prompt Designer**.\n\n### Inputs\nYou will receive:\n- product_image_url: the Telegram image URL of the real product (treat as ground truth)\n- caption: a short instruction describing what to create (e.g., \u201ccreate ads image for 10.10 campaign\u201d)\n- analyzed_description: AI-generated analysis text describing the product image (e.g., material, color, form, background)\n\n### Goal\nAnalyze both the **product image** and the **caption** to generate exactly **N distinct, production-ready advertising image prompts**.\nEach prompt should be visually distinct and directly usable with image generation models (e.g., SDXL, Midjourney, Flux, Veo).\n\n### Core Requirements\n1. Treat the product image as factual \u2014 keep **color, shape, texture, and logo** accurate.\n2. If the caption includes a campaign (e.g., \u201c10.10\u201d, \u201cSongkran\u201d, \u201cChristmas\u201d), apply **seasonal or promotional context** naturally and brand-safely:\n - **Halloween** \u2192 warm orange tones, moody light, pumpkins\n - **Songkran** \u2192 water splash, outdoor, bright festive vibe\n - **8.8 / 10.10 / 11.11** \u2192 energetic sale tone, bold accents, modern backgrounds\n - **Christmas** \u2192 cozy, pine, soft warm light, red/green accents\n3. If no campaign is mentioned or caption is generic, generate clean, timeless ad concepts.\n4. For each variation, vary **at least one** of these:\n - Scene / environment \n - Lighting setup \n - Camera angle or lens \n - Composition \n - Background texture or palette \n - Style or art direction \n5. Follow strictly the JSON schema below \u2014 **no extra text** or explanation outside the JSON.\n6. If a detail cannot be inferred, set it to an empty string \"\".\n7. All \u201cprompt\u201d values must be **one-line**, no breaks or newlines.\n\n### Quality Rules\n- Use clear and visual language (e.g., \u201csoft daylight on wooden desk\u201d) instead of vague adjectives.\n- Avoid fantasy or surrealism unless explicitly stated.\n- Favor **brand-safe, realistic advertising aesthetics**: packshots, lifestyle, editorial, cinematic.\n- Preserve the identity of the product \u2014 do not modify colors, text, or logos.\n- Include camera and lighting suggestions for realism.\n\n### Return Format\nReturn a **single JSON object only** (no commentary), following this schema:"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "ee5c3f1d-8de9-42cd-8d37-65e11740f108",
"name": "Prepare Fal.AI Input Fields",
"type": "n8n-nodes-base.set",
"position": [
-320,
384
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "62a409c6-c607-452b-9bbb-f3d29c86dddf",
"name": "product_image_URL",
"type": "string",
"value": "=https://api.telegram.org/bot<YourBotToken>/getFile?file_id={{ $('Receive Product Image (Telegram Trigger)').item.json.message.photo[2].file_id }}"
},
{
"id": "a4bbbfad-d9e6-4e0f-a9fa-76b1d04694b0",
"name": "image_prompt",
"type": "string",
"value": "=caption: {{ $('Assemble Prompt Parameters').item.json.caption }}\nprompt: {{ $('Assemble Prompt Parameters').item.json.prompt }}\nstyle: {{ $('Assemble Prompt Parameters').item.json.style }}\nscene: {{ $('Assemble Prompt Parameters').item.json.scene }}\nlighting: {{ $('Assemble Prompt Parameters').item.json.lighting }}\ncamera: {{ $('Assemble Prompt Parameters').item.json.camera }}\ncomposition: {{ $('Assemble Prompt Parameters').item.json.composition }}\nbackground: {{ $('Assemble Prompt Parameters').item.json.background }}\ncolor_mood: {{ $('Assemble Prompt Parameters').item.json.color_mood }}\nmarketing_angle: {{ $('Assemble Prompt Parameters').item.json.marketing_angle }}"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "71b27b74-f6de-4fbf-a9a1-d4c1683ea424",
"name": "Call Fal.AI API (nano-banana model)",
"type": "n8n-nodes-base.httpRequest",
"position": [
-144,
384
],
"parameters": {
"url": "=https://queue.fal.run/fal-ai/nano-banana/edit",
"method": "=POST",
"options": {},
"jsonBody": "={\n \"prompt\": {{ JSON.stringify(($json.image_prompt || '').replace(/\\r?\\n/g, ' ')) }},\n \"image_urls\": [\n \"https://api.telegram.org/file/bot<YourBotToken>/{{ $('Get Telegram File Path').item.json.result.file_path }}\"\n ],\n \"num_images\": 1,\n \"output_format\": \"jpeg\"\n}",
"sendBody": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "c35e12e6-dd35-4e9d-bda4-a21c241907c5",
"name": "Check Fal.AI Image Status",
"type": "n8n-nodes-base.httpRequest",
"position": [
32,
384
],
"parameters": {
"url": "={{ $json.status_url }}",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "00965d0b-e5b9-4d29-a5ab-0b71e3827db5",
"name": "Verify Image Generation Completed",
"type": "n8n-nodes-base.if",
"position": [
208,
384
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "38f5427f-4fc7-4c07-87d5-fa7f5964deb2",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.status }}",
"rightValue": "=COMPLETED"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "8042ab3f-e00b-4ea1-81ab-a2309dd3d48f",
"name": "Retrieve Generated Image URL",
"type": "n8n-nodes-base.httpRequest",
"position": [
464,
368
],
"parameters": {
"url": "=https://queue.fal.run/fal-ai/nano-banana/requests/{{ $json.request_id }}",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"retryOnFail": true,
"typeVersion": 4.2,
"alwaysOutputData": false
},
{
"id": "3095aa60-52b3-476d-960f-a5f2e061d478",
"name": "Send Generated Image to Telegram",
"type": "n8n-nodes-base.telegram",
"position": [
640,
368
],
"parameters": {
"file": "={{ $json.images[0].url }}",
"chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
"operation": "sendPhoto",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "7c1967b4-0b28-4b64-952d-b2eaeb837cf8",
"name": "User Review: Approve/Reject Generated Image",
"type": "n8n-nodes-base.telegram",
"position": [
832,
368
],
"parameters": {
"chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
"message": "Do you OK with image that AI generated.? If OK we will generate Caption for social media post.",
"options": {
"appendAttribution": false
},
"operation": "sendAndWait",
"formFields": {
"values": [
{
"fieldType": "radio",
"fieldLabel": "Approval",
"fieldOptions": {
"values": [
{
"option": "Approve"
},
{
"option": "Reject"
}
]
},
"requiredField": true
}
]
},
"responseType": "customForm"
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"executeOnce": true,
"typeVersion": 1.2
},
{
"id": "626d2622-1b0a-4768-9d83-1a3d3633889a",
"name": "Check Image Approval (Yes/No)",
"type": "n8n-nodes-base.if",
"position": [
1008,
368
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "26f47c7f-6a13-4bbe-87e3-cb980d86d2ea",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.data.Approval }}",
"rightValue": "Approve"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "44723af0-e3e3-4799-bb67-1cac6167cabc",
"name": "Analyze Final Ad Image (OpenAI Vision)",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-288,
656
],
"parameters": {
"text": "=Depcribe the product and brand in this image in full detail. Fully ignore the background. Focus ONLY on the product.",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
},
"options": {},
"resource": "image",
"simplify": false,
"imageUrls": "={{ $('Retrieve Generated Image URL').item.json.images[0].url }}",
"operation": "analyze"
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.8
},
{
"id": "186baedd-9631-4dfb-9e10-033d2abbbeda",
"name": "Generate Social Media Caption",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-112,
656
],
"parameters": {
"text": "=You will receive:\n\n- caption: {{ $('Receive Product Image (Telegram Trigger)').item.json.message.caption }}\n- analyzed_description: {{ $('Analyze Final Ad Image (OpenAI Vision)').item.json.choices[0].message.content }}\n- platform: \"facebook\"\n\nCreate a social media post for {{ $('Analyze Final Ad Image (OpenAI Vision)').item.json.choices[0].message.content }} suitable for Facebook and Instagram.\nInclude emojis and hashtags that match the campaign tone.\nReturn only JSON as defined in the system prompt.",
"options": {
"systemMessage": "=You are a **Social Media Copywriter AI** specialized in creating engaging Facebook and Instagram posts for product marketing.\n\n### Inputs\nYou will receive:\n- **analyzed_description**: a short text analysis of the product image (from vision AI), describing its appearance, brand, material, packaging, color, or promotional context.\n- **platform**: either \u201cfacebook\u201d or \u201cinstagram\u201d.\n- **campaign** (optional): may include terms like \"10.10\", \"Christmas\", \"Songkran\", \"none\", etc.\n\n### Goal\nWrite 1 social media post that is engaging, concise, and visually descriptive \u2014 optimized for the given platform. \nMake the product the hero of the post, highlight its uniqueness, and create emotional or promotional appeal.\n\n### Writing Style Rules\n- If **campaign** is provided, subtly adapt tone and visuals:\n - **10.10 / 11.11 / 12.12** \u2192 energetic, bold, focus on deals and excitement.\n - **Christmas / New Year** \u2192 warm, cozy, gift-worthy, festive emojis.\n - **Songkran / Summer** \u2192 refreshing, fun, bright energy, water/festival tone.\n - **Halloween** \u2192 playful, moody, orange/black vibe.\n - If none \u2192 clean, modern, lifestyle-oriented tone.\n- Use **emoji** naturally (2\u20135 total), matching platform tone.\n- Keep text **short (3\u20136 lines)** for readability.\n- Avoid hashtags inside sentences; list them at the end.\n- Do **not** fabricate information not found in the analyzed description.\n- Mention product features using emotional and visual cues.\n- Include **call-to-action (CTA)** such as \u201cShop now\u201d, \u201cTry it today\u201d, or \u201cLimited-time offer\u201d.\n\n### Output Format (JSON only)\nReturn a **single JSON object**:\n"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "a61e084a-4593-4beb-883e-4fef5289e51b",
"name": "User Review: Approve/Reject Caption",
"type": "n8n-nodes-base.telegram",
"position": [
192,
656
],
"parameters": {
"chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
"message": "=This caption for facebook post:\n\n{{ $json.output }}",
"options": {
"appendAttribution": false
},
"operation": "sendAndWait",
"approvalOptions": {
"values": {
"approvalType": "double"
}
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "f9e12529-a657-4a65-9ab5-f1977ee6cf8e",
"name": "Check Caption Approval (Yes/No)",
"type": "n8n-nodes-base.if",
"position": [
368,
656
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "d541205b-6bdb-477c-b8e2-67672228995a",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.data.approved.toString() }}",
"rightValue": "true"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "f4f50eb3-a4e9-47b1-8521-3164c09bf99c",
"name": "Preview Post Image (Telegram)",
"type": "n8n-nodes-base.telegram",
"position": [
592,
640
],
"parameters": {
"file": "={{ $('Retrieve Generated Image URL').item.json.images[0].url }}",
"chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
"operation": "sendPhoto",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "13e34a18-f867-4ef0-9216-8337e28270bd",
"name": "Preview Post Caption (Telegram)",
"type": "n8n-nodes-base.telegram",
"position": [
784,
640
],
"parameters": {
"text": "={{ $('Generate Social Media Caption').item.json.output }}",
"chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "7a05e115-49f0-4183-8252-8d2e1ad15cca",
"name": "Publish Post to Facebook Page",
"type": "n8n-nodes-base.facebookGraphApi",
"position": [
992,
640
],
"parameters": {
"edge": "photos",
"node": "me",
"options": {
"queryParameters": {
"parameter": [
{
"name": "url",
"value": "={{ $('Retrieve Generated Image URL').item.json.images[0].url }}"
},
{
"name": "message",
"value": "={{ $json.result.text }}"
}
]
}
},
"graphApiVersion": "v23.0",
"httpRequestMethod": "POST"
},
"credentials": {
"facebookGraphApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "86d44dfd-06b8-405a-b651-86e149c646af",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"disabled": true,
"position": [
-960,
928
],
"parameters": {
"color": 4,
"width": 336,
"height": 496,
"content": "## Product Image\n"
},
"typeVersion": 1
},
{
"id": "ef71ceb6-8569-48f4-88e1-d1dcf96e9c59",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"disabled": true,
"position": [
-608,
928
],
"parameters": {
"color": 4,
"width": 1792,
"height": 496,
"content": "## Process Step\n   "
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "5c02da28-f114-4aec-bd0a-523916d96ffb",
"connections": {
"Wait": {
"main": [
[
{
"node": "Check Fal.AI Image Status",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Generate Ad Prompt Draft (from Image Analysis)",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Revise Prompt Based on Feedback",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Generate Social Media Caption",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Send a text message": {
"main": [
[
{
"node": "Prepare Fal.AI Input Fields",
"type": "main",
"index": 0
}
]
]
},
"Get Telegram File Path": {
"main": [
[
{
"node": "Analyze Product Image (OpenAI Vision)",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Generate Ad Prompt Draft (from Image Analysis)",
"type": "ai_outputParser",
"index": 0
},
{
"node": "Revise Prompt Based on Feedback",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Check Fal.AI Image Status": {
"main": [
[
{
"node": "Verify Image Generation Completed",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser1": {
"ai_outputParser": [
[
{
"node": "Generate Social Media Caption",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Assemble Prompt Parameters": {
"main": [
[
{
"node": "User Review: Approve/Reject Ad Prompt",
"type": "main",
"index": 0
}
]
]
},
"Prepare Fal.AI Input Fields": {
"main": [
[
{
"node": "Call Fal.AI API (nano-banana model)",
"type": "main",
"index": 0
}
]
]
},
"Retrieve Generated Image URL": {
"main": [
[
{
"node": "Send Generated Image to Telegram",
"type": "main",
"index": 0
}
]
]
},
"Check Image Approval (Yes/No)": {
"main": [
[
{
"node": "Analyze Final Ad Image (OpenAI Vision)",
"type": "main",
"index": 0
}
],
[
{
"node": "Prepare Fal.AI Input Fields",
"type": "main",
"index": 0
}
]
]
},
"Generate Social Media Caption": {
"main": [
[
{
"node": "User Review: Approve/Reject Caption",
"type": "main",
"index": 0
}
]
]
},
"Preview Post Image (Telegram)": {
"main": [
[
{
"node": "Preview Post Caption (Telegram)",
"type": "main",
"index": 0
}
]
]
},
"Check Prompt Approval (Yes/No)": {
"main": [
[
{
"node": "Send a text message",
"type": "main",
"index": 0
}
],
[
{
"node": "Revise Prompt Based on Feedback",
"type": "main",
"index": 0
}
]
]
},
"Check Caption Approval (Yes/No)": {
"main": [
[
{
"node": "Preview Post Image (Telegram)",
"type": "main",
"index": 0
}
],
[
{
"node": "Generate Social Media Caption",
"type": "main",
"index": 0
}
]
]
},
"Preview Post Caption (Telegram)": {
"main": [
[
{
"node": "Publish Post to Facebook Page",
"type": "main",
"index": 0
}
]
]
},
"Revise Prompt Based on Feedback": {
"main": [
[
{
"node": "Assemble Prompt Parameters",
"type": "main",
"index": 0
}
]
]
},
"Send Generated Image to Telegram": {
"main": [
[
{
"node": "User Review: Approve/Reject Generated Image",
"type": "main",
"index": 0
}
]
]
},
"Verify Image Generation Completed": {
"main": [
[
{
"node": "Retrieve Generated Image URL",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Call Fal.AI API (nano-banana model)": {
"main": [
[
{
"node": "Check Fal.AI Image Status",
"type": "main",
"index": 0
}
]
]
},
"User Review: Approve/Reject Caption": {
"main": [
[
{
"node": "Check Caption Approval (Yes/No)",
"type": "main",
"index": 0
}
]
]
},
"Analyze Product Image (OpenAI Vision)": {
"main": [
[
{
"node": "Generate Ad Prompt Draft (from Image Analysis)",
"type": "main",
"index": 0
}
]
]
},
"User Review: Approve/Reject Ad Prompt": {
"main": [
[
{
"node": "Check Prompt Approval (Yes/No)",
"type": "main",
"index": 0
}
]
]
},
"Analyze Final Ad Image (OpenAI Vision)": {
"main": [
[
{
"node": "Generate Social Media Caption",
"type": "main",
"index": 0
}
]
]
},
"Receive Product Image (Telegram Trigger)": {
"main": [
[
{
"node": "Get Telegram File Path",
"type": "main",
"index": 0
}
]
]
},
"User Review: Approve/Reject Generated Image": {
"main": [
[
{
"node": "Check Image Approval (Yes/No)",
"type": "main",
"index": 0
}
]
]
},
"Generate Ad Prompt Draft (from Image Analysis)": {
"main": [
[
{
"node": "Assemble Prompt Parameters",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
facebookGraphApihttpHeaderAuthopenAiApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow automates the entire process of creating and publishing social media ads — directly from Telegram. By simply sending a product photo to your Telegram bot, the system analyzes the image, generates an AI-based advertising prompt, creates a marketing image via Fal.AI,…
Source: https://n8n.io/workflows/9561/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Generate AI viral videos with NanoBanana & VEO3, shared on socials via Blotato 2. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 94 nodes.
RAG CHATBOT Main. Uses telegram, telegramTrigger, lmChatOpenAi, n8n-nodes-mcp. Event-driven trigger; 87 nodes.
Digital marketers, content creators, social media managers, and businesses who want to use AI marketing automation for YouTube Shorts without spending hours on production. This AI workflow helps anyon
Transform your salon/service business with this streamlined Telegram automation system featuring Claude integration, zero-setup database management, and intelligent conversation handling. Claude MCP I
This template is designed for marketers, content creators, and e-commerce brands who want to automate the creation of professional ad videos at scale. It’s ideal for teams looking to generate consiste