8
n8n 中文网amn8n.com

Nano Banana-Gemini 2.5多模态Telegram机器人

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 36 个节点。主要使用 If, Set, Code, Switch, Telegram 等节点。 基于Nano Banana/Gemini 2.5的多模态Telegram机器人

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "1e7a9324ab9334116f824c649ad91453265a99b04bad06eba0c9ec33cc653365",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "e71e263a-fad6-474d-b146-d1d3548c16f1",
      "name": "Analyze Image",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -2912,
        -544
      ],
      "parameters": {
        "text": "=You are an advanced image description AI assistant . Your primary function is to provide detailed, accurate descriptions of images submitted through Telegram.\n\nCORE FUNCTIONALITY:\n- When presented with an image, you will analyze it thoroughly and provide a comprehensive description in English.\n- Your descriptions should capture both the obvious and subtle elements within the image.\n\nIMAGE DESCRIPTION GUIDELINES:\n- Begin with a broad overview of what the image contains\n- Describe key subjects, people, objects, and their relationships\n- Note significant visual elements such as colors, lighting, composition, and perspective\n- Identify any text visible in the image\n- Describe the setting or environment\n- Mention any notable actions or events taking place\n- Comment on mood, tone, or atmosphere when relevant\n- If applicable, identify landmarks, famous people, or cultural references\n\nRESPONSE FORMAT:\n- Start with \"Image Description:\" followed by your analysis\n- Structure your description in a logical manner (general to specific)\n- Use clear, precise language appropriate for visual description\n- Format longer descriptions with paragraphs to enhance readability\n- End with any notable observations that might require special attention\n\nLIMITATIONS:\n- If the image is blurry, low resolution, or difficult to interpret, acknowledge these limitations\n- If an image contains potentially sensitive content, provide a factual description without judgment\n- Do not make assumptions about elements that cannot be clearly determined\n\nYour descriptions should be informative, objective, and thorough, enabling someone who cannot see the image to form an accurate mental picture of its contents.",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {
          "detail": "auto"
        },
        "resource": "image",
        "imageUrls": "=https://api.telegram.org/file/bot8206525642:AAGRow3u-k7esKLpsbHXRS5QDI6mRLkgFvQ/{{ $json.result.file_path }}",
        "operation": "analyze"
      },
      "credentials": {
        "openAiApi": {
          "id": "yFsTgVI1r1htMsxI",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "800db8b5-4447-4cb2-ad1b-d23689e01f99",
      "name": "下载音频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3216,
        -224
      ],
      "parameters": {
        "url": "=https://api.telegram.org/file/bot[token]/{{ $json.result.file_path }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "kxH90BT7Yd5H4p3N",
          "name": "Slack ZEP"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f654f6ec-e0ef-44a6-8031-bb4a0dc39d4b",
      "name": "转录音频",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -2976,
        -224
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "id": "yFsTgVI1r1htMsxI",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "d52f513d-7410-4d99-bc7b-a80ac58c25fe",
      "name": "下载文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3072,
        48
      ],
      "parameters": {
        "url": "=https://api.telegram.org/file/bot[token]/{{ $json.result.file_path }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "25ff1a7c-cb0d-4ff3-9459-df45f176c3ff",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -2816,
        48
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "98bccc88-fdf7-4b1d-ace7-59d15ec3cdc9",
      "name": "仅限 PDF 文件",
      "type": "n8n-nodes-base.if",
      "position": [
        -3584,
        64
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f52d2aaa-e0b2-45e5-8c4b-ceef42182a0d",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.document.mime_type }}",
              "rightValue": "application/pdf"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0208339a-c498-4508-9793-7519a50cf1ce",
      "name": "文本",
      "type": "n8n-nodes-base.set",
      "position": [
        -3072,
        -848
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c53cd9f9-77c1-4331-98ff-bfc9bdf95a3c",
              "name": "text",
              "type": "string",
              "value": "={{ $json.messageBody }}"
            },
            {
              "id": "ac2fb759-aeec-4f5d-b1d2-cf25a00d7882",
              "name": "userId",
              "type": "string",
              "value": "={{ $json.userTelegramId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "053d2572-9db1-4e87-80c6-2068fdaefb8f",
      "name": "音频",
      "type": "n8n-nodes-base.set",
      "position": [
        -2720,
        -224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "219577d5-b028-48fc-90be-980f4171ab68",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2438466f-a360-407c-a95f-02f1c1150ada",
      "name": "图像",
      "type": "n8n-nodes-base.set",
      "position": [
        -2656,
        -544
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "67552183-de2e-494a-878e-c2948e8cb6bb",
              "name": "text",
              "type": "string",
              "value": "=User request on the image:\n{{ \"Describe the following image\" || $('WhatsApp Trigger').item.json.messages[0].image.caption }}\n\nImage description:\n{{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "64981293-1695-4452-bc2b-d0199e1baa4b",
      "name": "文件",
      "type": "n8n-nodes-base.set",
      "position": [
        -2560,
        48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "67552183-de2e-494a-878e-c2948e8cb6bb",
              "name": "text",
              "type": "string",
              "value": "=User request on the file:\n{{ \"Describe this file\" || $('Only PDF File').item.json.messages[0].document.caption }}\n\nFile content:\n{{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "87ebeb21-e550-4fc0-b427-d3ac7114cf23",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3664,
        -880
      ],
      "parameters": {
        "width": 1340,
        "height": 240,
        "content": "## 文本"
      },
      "typeVersion": 1
    },
    {
      "id": "32304790-e742-473a-9ffd-a286ad6557ff",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3664,
        -304
      ],
      "parameters": {
        "width": 1340,
        "height": 240,
        "content": "## 语音"
      },
      "typeVersion": 1
    },
    {
      "id": "1a3f6a1a-e6ed-4a41-8d54-b4984a22c257",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3664,
        -592
      ],
      "parameters": {
        "width": 1340,
        "height": 240,
        "content": "## 图像"
      },
      "typeVersion": 1
    },
    {
      "id": "ef6122b2-eaf0-484f-b266-1a0fc773237e",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3664,
        -16
      ],
      "parameters": {
        "width": 1340,
        "height": 240,
        "content": "## 文档"
      },
      "typeVersion": 1
    },
    {
      "id": "1c8c28b9-d415-4afe-800a-d2e745101bc5",
      "name": "设置初始数据",
      "type": "n8n-nodes-base.set",
      "position": [
        -4240,
        -416
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0eefb762-7841-4458-8699-3e04dea2ce8a",
              "name": "userTelegramId",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.from.id }}"
            },
            {
              "id": "df6f9634-fc87-4687-b956-2debcd2bc965",
              "name": "messageBody",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.text || ($('Telegram Trigger').item.json.message.photo ? '[Image]' : '[Media]') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3f665f5b-76c8-4137-9b53-07c80c8ec93c",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        -4000,
        -448
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b5fbcbf9-7e9c-4e24-85aa-a76abf8e051f",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Photo",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8fb9c737-5d8d-4fa6-89d2-b0b56a600d26",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "aaba3cb1-3725-41a9-ab30-101c28436ca7",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.voice }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Document",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "90859e8d-90e5-4088-9d34-b5c35f00e761",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.document }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.2
    },
    {
      "id": "852a18f3-4f8f-430b-bcb3-566c9cb0faba",
      "name": "获取图片 URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3376,
        -544
      ],
      "parameters": {
        "url": "=https://api.telegram.org/bot[token]/getFile",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "file_id",
              "value": "={{ $('Telegram Trigger').item.json.message.photo[$('Telegram Trigger').item.json.message.photo.length - 1].file_id }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "197c7647-e1e2-4491-9321-e5edcc27cf6c",
      "name": "获取文件 URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3312,
        48
      ],
      "parameters": {
        "url": "=https://api.telegram.org/[botToken]/getFile",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "file_id",
              "value": "={{ $('Telegram Trigger').item.json.message.document.file_id }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e2dec616-34bb-49dd-bb30-f9e0def62fab",
      "name": "格式不正确",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -3440,
        272
      ],
      "webhookId": "dc7db36b-9f0f-46e5-975e-c5cf869b7186",
      "parameters": {
        "text": "=Sorry but you can only send PDF files",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "D8cTjdtZFrinmqtQ",
          "name": "Telegram Nail Salon"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "42d8728f-cc33-4629-a5e7-209c2bbaf5e4",
      "name": "获取音频 URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3456,
        -224
      ],
      "parameters": {
        "url": "=https://api.telegram.org/bot[token]/getFile",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "file_id",
              "value": "={{ $('Telegram Trigger').item.json.message.voice.file_id }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "86952773-c6c8-4772-86ac-61c43ac6f8ee",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -4448,
        -416
      ],
      "webhookId": "6d8fe1d8-06f2-4339-92dd-d1f66a6c9973",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": true
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "D8cTjdtZFrinmqtQ",
          "name": "Telegram Nail Salon"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f3691eb7-108d-4588-86da-2ca61d334437",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4832,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 1112,
        "height": 388,
        "content": "## 🚀 TELEGRAM 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "bdfd6ba1-b3fa-4197-a0a0-e14033f6cdc6",
      "name": "生成器代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -2064,
        -544
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=# Role\nYou are an Expert Prompt Design Assistant for AI Image Generation using Nano Banana (Gemini 2.5 Flash Image).\n\n# Your Mission\nHelp users create amazing images by:\n1. Understanding what they want to create\n2. Asking clarifying questions to improve their vision\n3. Crafting optimized prompts for Nano Banana\n4. Using the generateImage tool when ready\n5. **Remembering previous prompts for modifications**\n\n# Memory & Modifications\n- **Always remember the last generated prompt** in our conversation\n- When users say \"modify this\", \"change this image\", \"make it darker\", etc., use the previous prompt as base\n- For modifications:\n  - Take the original prompt\n  - Apply the requested changes\n  - Keep the good elements from the original\n  - Explain what you're changing\n\n# Conversation Style\n- Be creative, enthusiastic, and helpful\n- Ask specific questions to understand their vision\n- Suggest improvements to make prompts more detailed\n- Explain why certain prompt elements work better\n\n# Prompt Optimization Guidelines\nFor Nano Banana, great prompts include:\n- **Subject**: What's the main focus?\n- **Style**: Photorealistic, cartoon, artistic, etc.\n- **Composition**: Close-up, wide shot, angle, perspective\n- **Lighting**: Natural, dramatic, soft, golden hour, etc.\n- **Colors**: Specific color schemes or moods\n- **Details**: Textures, emotions, atmosphere, setting\n- **Quality keywords**: \"high quality\", \"detailed\", \"professional\"\n\n# Examples of Good Prompts:\n- \"A majestic golden retriever sitting in a sunlit meadow, professional portrait photography, shallow depth of field, warm golden hour lighting, detailed fur texture\"\n- \"Futuristic cyberpunk cityscape at night, neon lights reflecting on wet streets, dramatic perspective from street level, high contrast, ultra-detailed\"\n\n# Process:\n1. When user describes what they want, ask 1 clarifying question. Don't ask too many questions.\n2. Suggest prompt improvements\n3. When they're happy, use generateImage tool\n4. If they want changes, help refine and regenerate\n5. **Remember prompts for future modifications**\n\n# Tools Available:\n- generateImage: Use this when the prompt is ready\n\nAlways be encouraging and help them create their best possible image!\n\n# IMPORTANT OUTPUT RULES:\nWhen you have gathered enough information and are ready to generate an image, output EXACTLY this format with NO OTHER TEXT:\nREADY_TO_GENERATE: [your final optimized prompt here]\n\nWhen you're still asking questions or chatting, just respond normally.\n\nExamples:\n- Still gathering info: \"What style would you like? Realistic or cartoon?\"\n- Ready to generate: \"READY_TO_GENERATE: A majestic golden dragon sitting on a mountain peak, fantasy art style, dramatic lighting, detailed scales, 4K quality\"\n\nCRITICAL: NO explanatory text when generating. Just the READY_TO_GENERATE line.\n\nExamples:\n- Still gathering info: \"What style would you like? Realistic or cartoon?\"\n- Ready to generate: \"READY_TO_GENERATE: A majestic golden dragon sitting on a mountain peak, fantasy art style, dramatic lighting, detailed scales, 4K quality\"\n- **Modifying previous**: \"I'll modify the dragon to be silver instead of golden. READY_TO_GENERATE: A majestic silver dragon sitting on a mountain peak, fantasy art style, dramatic lighting, detailed scales, 4K quality\"\n\nCRITICAL:\n\nDO NOT OUTPUT YOUR THOUGHTS SUCH AS \"Saved as the current prompt.\" OR ANYTHING SIMILIAR."
        },
        "promptType": "define",
        "needsFallback": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "82c24cf5-a950-4d0d-b4fb-902e3498795f",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1792,
        -272
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "86875aaf-bd50-46e3-bf61-4383075c6541",
      "name": "发送照片消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -368,
        -560
      ],
      "webhookId": "a3ea8b6c-5338-44b8-8174-e48fd9506187",
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {},
        "binaryPropertyName": "photo"
      },
      "credentials": {
        "telegramApi": {
          "id": "D8cTjdtZFrinmqtQ",
          "name": "Telegram Nail Salon"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cf8a0425-e75e-42bd-96ea-0ee6279d5a9a",
      "name": "Nano Banana API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -864,
        -560
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [{\n    \"parts\": [\n      {\"text\": \"{{ $json.prompt }}\"}\n    ]\n  }]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "ydUA3JE9hfcmAyhb",
          "name": "Nano Banana"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "983a59f7-18dd-49ad-b2ed-9c14803d0d6a",
      "name": "发送文本消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -864,
        -352
      ],
      "webhookId": "6b9d7322-1c51-41bc-beb1-f30406447ee3",
      "parameters": {
        "text": "={{ $json.text }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "D8cTjdtZFrinmqtQ",
          "name": "Telegram Nail Salon"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9e1b3b4a-fcd8-4a2d-91fb-9a6dc62a4fa8",
      "name": "修复 JSON 输出",
      "type": "n8n-nodes-base.code",
      "position": [
        -1504,
        -544
      ],
      "parameters": {
        "jsCode": "const output = $json.output;\n\nif (output.startsWith('READY_TO_GENERATE')) {\n  const prompt = output.replace('READY_TO_GENERATE: ', '');\n  return [{\n    json: {\n      type: 'image',\n      prompt: prompt,\n    }\n  }];\n} else {\n  return [{\n    json: {\n      type: 'text',\n      text: output,\n    }\n  }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "2ae1d8f4-f1aa-4bac-95d2-328a4cae0a97",
      "name": "将图像转换为二进制",
      "type": "n8n-nodes-base.code",
      "position": [
        -608,
        -560
      ],
      "parameters": {
        "jsCode": "const response = $json;\n\nif (response.candidates?.[0]?.content?.parts) {\n  const imagePart = response.candidates[0].content.parts.find(part => part.inlineData);\n  if (imagePart) {\n    // Convert base64 to binary buffer\n    const binaryData = Buffer.from(imagePart.inlineData.data, 'base64');\n    \n    return [{\n      json: {\n        success: true\n      },\n      binary: {\n        photo: {\n          data: binaryData,\n          mimeType: 'image/jpeg',\n          fileName: 'generated_image.jpg'\n        }\n      }\n    }];\n  }\n}\n\nreturn [{ json: { error: \"Failed\" } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "2157bf4d-2b41-4530-aeaa-ed8fe349eee1",
      "name": "gpt-5-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -2192,
        -272
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini",
          "cachedResultName": "gpt-5-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "yFsTgVI1r1htMsxI",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3acee557-8b45-4c1a-80e0-c86ce83406fd",
      "name": "gemini-2.5-flash",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1984,
        -272
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "BLzfW3y9cX6frBrq",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dc819c6d-19f5-4f5d-b9f7-29e400b55ae2",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2256,
        -880
      ],
      "parameters": {
        "color": 5,
        "width": 608,
        "height": 736,
        "content": "## 🤖 双模型生成器代理"
      },
      "typeVersion": 1
    },
    {
      "id": "0dd2dec0-bdfa-43c5-b993-94c5ecc78431",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1584,
        -816
      ],
      "parameters": {
        "color": 6,
        "width": 592,
        "height": 448,
        "content": "## 📤 智能输出处理器"
      },
      "typeVersion": 1
    },
    {
      "id": "d16bd214-3bf1-405e-bc1c-a78ab7775362",
      "name": "图像生成就绪?",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1200,
        -544
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f90ce935-a205-4acd-b9ed-e631e140e602",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "47a4059f-a9e8-43ed-aaf1-553e16063477",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "text"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "4fa46023-c38c-4064-9622-73460e47f42c",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -816
      ],
      "parameters": {
        "color": 4,
        "width": 768,
        "height": 640,
        "content": "## 🎨 NANO BANANA 图像处理流程"
      },
      "typeVersion": 1
    },
    {
      "id": "9e61fa7d-392c-4da7-8ddd-44da91aab644",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5632,
        -848
      ],
      "parameters": {
        "color": 5,
        "width": 736,
        "height": 2080,
        "content": "# AI 图像生成器 Telegram 机器人设置指南"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "File": {
      "main": [
        [
          {
            "node": "Generator Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text": {
      "main": [
        [
          {
            "node": "Generator Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audio": {
      "main": [
        [
          {
            "node": "Generator Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image": {
      "main": [
        [
          {
            "node": "Generator Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Image Url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Audio Url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Only PDF File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gpt-5-mini": {
      "ai_languageModel": [
        [
          {
            "node": "Generator Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get File Url": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Image": {
      "main": [
        [
          {
            "node": "Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Audio Url": {
      "main": [
        [
          {
            "node": "Download Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image Url": {
      "main": [
        [
          {
            "node": "Analyze Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only PDF File": {
      "main": [
        [
          {
            "node": "Get File Url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Incorrect format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Generator Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Download Audio": {
      "main": [
        [
          {
            "node": "Transcribe Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fix JSON Output": {
      "main": [
        [
          {
            "node": "Image Generation Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generator Agent": {
      "main": [
        [
          {
            "node": "Fix JSON Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Nano Banana API": {
      "main": [
        [
          {
            "node": "Convert Image to Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Initial Data": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Set Initial Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe Audio": {
      "main": [
        [
          {
            "node": "Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gemini-2.5-flash": {
      "ai_languageModel": [
        [
          {
            "node": "Generator Agent",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Image to Binary": {
      "main": [
        [
          {
            "node": "Send a photo message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image Generation Ready?": {
      "main": [
        [
          {
            "node": "Nano Banana API",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量36
分类2
节点类型14
难度说明

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

外部链接
在 n8n.io 查看

分享此工作流