8
n8n 中文网amn8n.com

Telegram机器人模板

高级

这是一个自动化工作流,包含 35 个节点。主要使用 If, Set, Wait, Telegram, HttpRequest 等节点。 使用Telegram、Fal.AI和Facebook发布自动化产品广告创建

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
  • Facebook Graph API 凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "qE2VKgGPG7Hxh7fI",
  "meta": {
    "instanceId": "2c12b0b552404dc07af67cd5f092afd21d18c808d4fdabdb04cb4b064195b6fb",
    "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": "发送短信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        832,
        112
      ],
      "webhookId": "9d4e8875-5724-4e8f-a2fd-2020f646aae8",
      "parameters": {
        "text": "Waiting image ads on process...",
        "chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "64c80d0a-8369-4c22-9f61-8e05f049d76f",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        16
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "28LXl50ZdQjnkMJs",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "39ce8fb0-11c6-4c88-9121-4b909379ee34",
      "name": "结构化输出解析器",
      "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": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        -960,
        352
      ],
      "parameters": {
        "width": 2144,
        "height": 256,
        "content": "### 🟨 区域3:生成并确认广告图片(Fal.AI)"
      },
      "typeVersion": 1
    },
    {
      "id": "e989e099-1885-4aad-846d-ea353f643750",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        352,
        464
      ],
      "webhookId": "469c5fab-ee5c-41ec-8862-615f54d32b95",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "ac93bc19-c3a4-4a83-9433-847721bacd22",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -128,
        768
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "28LXl50ZdQjnkMJs",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8eca322c-5e42-41fe-920a-a8c2d02ac902",
      "name": "结构化输出解析器 1",
      "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": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        -960,
        112
      ],
      "parameters": {
        "color": 3,
        "width": 2144,
        "height": 224,
        "content": "#### 🟥 区域2:创建广告图片提示词"
      },
      "typeVersion": 1
    },
    {
      "id": "a5dd96e0-2158-4e34-bb16-fbdfdd66fb6a",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        -960,
        -128
      ],
      "parameters": {
        "color": 4,
        "width": 2144,
        "height": 224,
        "content": "### 🟩 区域1:产品图片分析"
      },
      "typeVersion": 1
    },
    {
      "id": "246a4cc8-4a13-4d04-8a98-de8d92ca2cb9",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        -960,
        624
      ],
      "parameters": {
        "color": 5,
        "width": 2144,
        "height": 288,
        "content": "### 🟦 区域4:创建社交媒体文案并发布到Facebook"
      },
      "typeVersion": 1
    },
    {
      "id": "32bba9a2-7f30-49fe-8166-88e6ae6ea192",
      "name": "接收产品图片(Telegram触发器)",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -160,
        -96
      ],
      "webhookId": "3bbd63a0-7cbc-4a27-a381-23d83301a19f",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5c693310-59db-474c-9f99-2a1f20d728f2",
      "name": "获取Telegram文件路径",
      "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": "分析产品图片(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": {
          "id": "28LXl50ZdQjnkMJs",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "9b8758fe-6705-4ee0-aee3-23461852eff4",
      "name": "生成广告提示词草稿(基于图片分析)",
      "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., “10.10”, “Christmas”, “Songkran”), 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., “create ads image for 10.10 campaign”)\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 — keep **color, shape, texture, and logo** accurate.\n2. If the caption includes a campaign (e.g., “10.10”, “Songkran”, “Christmas”), apply **seasonal or promotional context** naturally and brand-safely:\n   - **Halloween** → warm orange tones, moody light, pumpkins\n   - **Songkran** → water splash, outdoor, bright festive vibe\n   - **8.8 / 10.10 / 11.11** → energetic sale tone, bold accents, modern backgrounds\n   - **Christmas** → 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 — **no extra text** or explanation outside the JSON.\n6. If a detail cannot be inferred, set it to an empty string \"\".\n7. All “prompt” values must be **one-line**, no breaks or newlines.\n\n### Quality Rules\n- Use clear and visual language (e.g., “soft daylight on wooden desk”) 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 — 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": "组装提示词参数",
      "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": "用户审核:批准/拒绝广告提示词",
      "type": "n8n-nodes-base.telegram",
      "position": [
        48,
        128
      ],
      "webhookId": "b3340241-04c1-4a74-abf7-d4726c94c802",
      "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": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "e0ef10fc-fbe7-4e9a-aa6d-495c3dbba207",
      "name": "检查提示词批准状态(是/否)",
      "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": "根据反馈修改提示词",
      "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., “10.10”, “Christmas”, “Songkran”), 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., “create ads image for 10.10 campaign”)\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 — keep **color, shape, texture, and logo** accurate.\n2. If the caption includes a campaign (e.g., “10.10”, “Songkran”, “Christmas”), apply **seasonal or promotional context** naturally and brand-safely:\n   - **Halloween** → warm orange tones, moody light, pumpkins\n   - **Songkran** → water splash, outdoor, bright festive vibe\n   - **8.8 / 10.10 / 11.11** → energetic sale tone, bold accents, modern backgrounds\n   - **Christmas** → 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 — **no extra text** or explanation outside the JSON.\n6. If a detail cannot be inferred, set it to an empty string \"\".\n7. All “prompt” values must be **one-line**, no breaks or newlines.\n\n### Quality Rules\n- Use clear and visual language (e.g., “soft daylight on wooden desk”) 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 — 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": "准备Fal.AI输入字段",
      "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": "调用Fal.AI API(nano-banana模型)",
      "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": {
          "id": "8aXZ3G10Qvvsc8FY",
          "name": "Fal AI"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c35e12e6-dd35-4e9d-bda4-a21c241907c5",
      "name": "检查Fal.AI图片状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        32,
        384
      ],
      "parameters": {
        "url": "={{ $json.status_url }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "8aXZ3G10Qvvsc8FY",
          "name": "Fal AI"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "00965d0b-e5b9-4d29-a5ab-0b71e3827db5",
      "name": "验证图片生成完成",
      "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": "检索生成的图片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": {
          "id": "8aXZ3G10Qvvsc8FY",
          "name": "Fal AI"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "3095aa60-52b3-476d-960f-a5f2e061d478",
      "name": "发送生成图片到Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        640,
        368
      ],
      "webhookId": "fde28935-628e-432b-91ed-1f66b5bea421",
      "parameters": {
        "file": "={{ $json.images[0].url }}",
        "chatId": "={{ $('Receive Product Image (Telegram Trigger)').item.json.message.chat.id }}",
        "operation": "sendPhoto",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7c1967b4-0b28-4b64-952d-b2eaeb837cf8",
      "name": "用户审核:批准/拒绝生成图片",
      "type": "n8n-nodes-base.telegram",
      "position": [
        832,
        368
      ],
      "webhookId": "1c7a83ca-44ea-430f-81c1-779f34505e43",
      "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": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "626d2622-1b0a-4768-9d83-1a3d3633889a",
      "name": "检查图片批准状态(是/否)",
      "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": "分析最终广告图片(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": {
          "id": "28LXl50ZdQjnkMJs",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "186baedd-9631-4dfb-9e10-033d2abbbeda",
      "name": "生成社交媒体文案",
      "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 “facebook” or “instagram”.\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 — 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** → energetic, bold, focus on deals and excitement.\n  - **Christmas / New Year** → warm, cozy, gift-worthy, festive emojis.\n  - **Songkran / Summer** → refreshing, fun, bright energy, water/festival tone.\n  - **Halloween** → playful, moody, orange/black vibe.\n  - If none → clean, modern, lifestyle-oriented tone.\n- Use **emoji** naturally (2–5 total), matching platform tone.\n- Keep text **short (3–6 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 “Shop now”, “Try it today”, or “Limited-time offer”.\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": "用户审核:批准/拒绝文案",
      "type": "n8n-nodes-base.telegram",
      "position": [
        192,
        656
      ],
      "webhookId": "dfe8e316-4f3b-46ba-aa17-baaeb3bfb312",
      "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": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f9e12529-a657-4a65-9ab5-f1977ee6cf8e",
      "name": "检查文案批准状态(是/否)",
      "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": "预览帖子图片(Telegram)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        592,
        640
      ],
      "webhookId": "e663fbb9-f3ad-4e8f-a950-23b488aa4c41",
      "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": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "13e34a18-f867-4ef0-9216-8337e28270bd",
      "name": "预览帖子文案(Telegram)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        784,
        640
      ],
      "webhookId": "8fe5f776-19a2-4d79-8cc5-ce42132d720a",
      "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": {
          "id": "dnHXuiLgkL1Qfilg",
          "name": "Telegram_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7a05e115-49f0-4183-8252-8d2e1ad15cca",
      "name": "发布帖子到Facebook页面",
      "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": {
          "id": "7h2Q7242zCuR3sBQ",
          "name": "Facebook Post Ads Image"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "86d44dfd-06b8-405a-b651-86e149c646af",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        -960,
        928
      ],
      "parameters": {
        "color": 4,
        "width": 336,
        "height": 496,
        "content": "## 产品图片"
      },
      "typeVersion": 1
    },
    {
      "id": "ef71ceb6-8569-48f4-88e1-d1dcf96e9c59",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        -608,
        928
      ],
      "parameters": {
        "color": 4,
        "width": 1792,
        "height": 496,
        "content": "## 流程步骤"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "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
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量35
分类-
节点类型12
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Jaruphat J.

Jaruphat J.

@jaruphatj

Project Manager who passionate about Automation & AI and continuously explore innovative ways to improve business processes through intelligent workflow automation. Let’s connect and automate the future!

外部链接
在 n8n.io 查看

分享此工作流