8
n8n 中文网amn8n.com

Telegram 图片生成

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 Telegram, HttpRequest, ConvertToFile, TelegramTrigger, ChainLlm 等节点。 通过 Telegram 机器人使用 Google Gemini 和增强提示进行文生图

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "0tEmax45Rzaq4xP9",
  "meta": {
    "instanceId": "d06afcec45b6881aa3c2bd3e34579ea44e46952db235308e9371e2bb743e4b43",
    "templateCredsSetupCompleted": true
  },
  "name": "Telegram 图片生成",
  "tags": [
    {
      "id": "VwtLS6Wfn3QdKdqW",
      "name": "Production",
      "createdAt": "2025-07-08T10:23:28.983Z",
      "updatedAt": "2025-07-08T10:23:28.983Z"
    }
  ],
  "nodes": [
    {
      "id": "d7a28ef5-499f-44f6-b07e-baad9c655c62",
      "name": "生成图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -200,
        60
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-preview-image-generation:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": {{ JSON.stringify($json.output.enhanced_prompt) }}\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"responseModalities\": [\n      \"TEXT\",\n      \"IMAGE\"\n    ]\n  }\n}",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "=key",
              "value": "Your API Key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "28fe131a-f506-4609-868e-4d7edaf64772",
      "name": "发送图片消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        520,
        60
      ],
      "webhookId": "26f2518c-133d-4079-8e9a-08d81196e62d",
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "fMxwJibijQHmlmqI",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7d61ed5b-a176-4404-9cb1-cbef1ead9f51",
      "name": "生成提示词",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -680,
        60
      ],
      "parameters": {
        "text": "=You are an expert prompt engineer specialized in creating detailed, high-quality prompts for AI image generation models. Your task is to take a user's basic image request and expand it into a comprehensive, detailed prompt that will produce stunning visual results.\n\n**Users Request:**{{ $json.message.text }}\n\nINSTRUCTIONS:\n1. Analyze the user's input and identify the core subject, style, and intent\n2. Expand the basic request into a detailed description including:\n   - Visual style and artistic approach\n   - Lighting conditions and mood\n   - Composition and framing\n   - Color palette and atmosphere\n   - Technical quality specifications\n   - Specific details that enhance the image\n\n3. Structure your response as a single, well-formatted prompt ready for image generation\n\nENHANCEMENT GUIDELINES:\n- Add specific artistic styles (e.g., \"photorealistic,\" \"oil painting,\" \"digital art,\" \"cinematic\")\n- Include lighting details (e.g., \"golden hour lighting,\" \"dramatic shadows,\" \"soft diffused light\")\n- Specify camera angles and composition (e.g., \"wide shot,\" \"close-up,\" \"bird's eye view\")\n- Add mood and atmosphere descriptors\n- Include quality enhancers like \"highly detailed,\" \"8K resolution,\" \"professional photography\"\n- Mention relevant artistic influences when appropriate\n\nEXAMPLE:\nUser input: \"a cat sitting on a windowsill\"\nYour output: \"A majestic tabby cat sitting gracefully on a wooden windowsill, bathed in warm golden afternoon sunlight streaming through vintage lace curtains. The scene captures a cozy, nostalgic atmosphere with soft shadows and gentle light rays creating a dreamy ambiance. Shot in the style of fine art photography with shallow depth of field, the background shows a blurred garden view. Highly detailed fur texture, expressive amber eyes, and warm color palette dominated by golds, creams, and soft browns. Professional photography quality, 8K resolution, cinematic lighting.\"\n\nNow take the user's image request and create a detailed, enhanced prompt for optimal image generation results.",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "174c56fc-a0d0-4740-bcd6-532e63a307bd",
      "name": "结构化提示词",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -500,
        240
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"enhanced_prompt\": \"...\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "bcf4736a-73b7-474b-8af7-ed18b9acb43e",
      "name": "Telegram触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -980,
        60
      ],
      "webhookId": "9db7782c-0c92-421b-90b1-45ee474615e8",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "fMxwJibijQHmlmqI",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "612e2726-0641-4362-8e84-49b5efa978fd",
      "name": "转换为图片",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        160,
        60
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "candidates[0].content.parts[1].inlineData.data"
      },
      "typeVersion": 1.1
    },
    {
      "id": "abeaddbe-2ba2-462f-b7d2-b8aae24f4a1c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1080,
        -160
      ],
      "parameters": {
        "width": 300,
        "height": 520,
        "content": "## 📱 Telegram 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "303ecc4f-3759-462e-9430-23feb81a8943",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -760,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 420,
        "height": 520,
        "content": "## 🧠 生成提示词"
      },
      "typeVersion": 1
    },
    {
      "id": "0444fb7e-b578-4575-9bf4-ae6100c21432",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -160
      ],
      "parameters": {
        "color": 2,
        "width": 340,
        "height": 520,
        "content": "## 🎨 生成图片"
      },
      "typeVersion": 1
    },
    {
      "id": "dec96747-332b-464b-82a8-604a82120603",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -160
      ],
      "parameters": {
        "color": 6,
        "width": 340,
        "height": 520,
        "content": "## 📁 转换为图片"
      },
      "typeVersion": 1
    },
    {
      "id": "1b1af43f-7c73-42d2-8610-34e0950248f1",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -160
      ],
      "parameters": {
        "color": 3,
        "width": 340,
        "height": 520,
        "content": "## 📤 发送照片消息"
      },
      "typeVersion": 1
    },
    {
      "id": "2b60768c-bd3a-4815-9553-a46e3a89875e",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1440,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 520,
        "content": "## 🔄 工作流摘要"
      },
      "typeVersion": 1
    },
    {
      "id": "0d39319b-7bb4-4335-88aa-741d0ffe0f4b",
      "name": "Gemini 2.5 Pro",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -680,
        240
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-pro"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "ngL4RI02lM8v6drj",
          "name": "Google Gemini API"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4eb1654f-28a2-4367-9fbd-72fd8bf52b2b",
  "connections": {
    "Gemini 2.5 Pro": {
      "ai_languageModel": [
        [
          {
            "node": "Generate prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image": {
      "main": [
        [
          {
            "node": "Convert to Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate prompt": {
      "main": [
        [
          {
            "node": "Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to Image": {
      "main": [
        [
          {
            "node": "Send a photo message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Generate prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Prompt": {
      "ai_outputParser": [
        [
          {
            "node": "Generate prompt",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类2
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
AppStoneLab Technologies LLP

AppStoneLab Technologies LLP

@appstonelab

Dive into the digital era with a trusted partner. From idea to execution, we transform visions into interactive realities. Let's shape the future, together.

外部链接
在 n8n.io 查看

分享此工作流