8
n8n 中文网amn8n.com

通过Telegram使用LLM增强提示和Gemini/Leonardo.AI生成动漫图像

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 22 个节点。主要使用 Set, Wait, SplitOut, Telegram, HttpRequest 等节点。 通过Telegram使用LLM增强提示和Gemini/Leonardo.AI生成动漫图像

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "702596a9719c2ee1ff81772a5069e7af986ac325ce905b7dfad8a8c8c8c9c76c"
  },
  "nodes": [
    {
      "id": "0290ceba-fc2d-426b-bcb3-4caa37b4d690",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "disabled": true,
      "position": [
        0,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 1220,
        "height": 92,
        "content": "# 使用 Gemini 进行图像生成 [使用 GCP 账户可免费 90 天]"
      },
      "typeVersion": 1
    },
    {
      "id": "f9b5e427-a030-4323-b8fb-69928e2b44ae",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        64,
        192
      ],
      "webhookId": "cdfeedc2-f811-4dbe-bca7-863ac47dd841",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "chatIds": ""
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "DCT0rTb6lDEXngOg",
          "name": "LXirein Bot (SMS)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f2edb1fd-dfd1-48d5-a20d-5c48a603c9b0",
      "name": "HTTP- Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1424,
        320
      ],
      "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.description) }}\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"responseModalities\": [\n      \"TEXT\",\n      \"IMAGE\"\n    ]\n  }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "o1FK0fi6w4RpYPp2",
          "name": "Gemini(PaLM) [api.Gmail]"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f117d6fd-bcbd-4ce9-b10c-3810e603eacd",
      "name": "设置 base64",
      "type": "n8n-nodes-base.set",
      "position": [
        1648,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "31a2b3db-78a0-41b8-815f-ffb6c572279d",
              "name": "base64",
              "type": "string",
              "value": "={{\n  $json.candidates && $json.candidates[0] && $json.candidates[0].content && $json.candidates[0].content.parts && (\n    ($json.candidates[0].content.parts[1] && $json.candidates[0].content.parts[1].inlineData && $json.candidates[0].content.parts[1].inlineData.data) ||\n    ($json.candidates[0].content.parts[0] && $json.candidates[0].content.parts[0].inlineData && $json.candidates[0].content.parts[0].inlineData.data)\n  )\n}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "487b7016-35d2-459f-b1d3-5e16fcaa5681",
      "name": "等待 10 秒",
      "type": "n8n-nodes-base.wait",
      "position": [
        2080,
        320
      ],
      "webhookId": "74276acc-e402-42a8-9cd5-dffc3cb51c58",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "226d63d1-6e09-46e8-abd4-ad6d9b63a939",
      "name": "图像计数",
      "type": "n8n-nodes-base.set",
      "position": [
        304,
        192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6c546bd1-389e-47e3-bd85-58a37750b6a2",
              "name": "User_Prompt",
              "type": "string",
              "value": "={{ $json.message.text }}"
            },
            {
              "id": "d15f7ae7-5203-4f48-9d4a-357444253c89",
              "name": "num_of_Images",
              "type": "number",
              "value": 4
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "376700cb-8da4-42b3-b5db-527a336040bd",
      "name": "循环遍历提示",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1104,
        192
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "41a30836-c00f-49ae-ade1-7ad04a4a7a96",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1872,
        320
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "base64"
      },
      "typeVersion": 1.1
    },
    {
      "id": "59590e2f-7150-4c12-988a-577b81f9c515",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        224
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 300,
        "content": "## 使用 gemini 模型"
      },
      "typeVersion": 1
    },
    {
      "id": "117c00f6-14fd-4a78-ae8c-f71e15a6016b",
      "name": "HTTP- Leonardo AI",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1360,
        704
      ],
      "parameters": {
        "url": "https://cloud.leonardo.ai/api/rest/v1/generations",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "height",
              "value": "768"
            },
            {
              "name": "modelId",
              "value": "e71a1c2f-4f80-4800-934f-2c68979d8cc8"
            },
            {
              "name": "num_images",
              "value": "1"
            },
            {
              "name": "prompt",
              "value": "={{ JSON.stringify($json.description) }}"
            },
            {
              "name": "width",
              "value": "1024"
            },
            {
              "name": "public",
              "value": "true"
            },
            {
              "name": "promptMagic",
              "value": "true"
            },
            {
              "name": "guidance_scale",
              "value": "7"
            },
            {
              "name": "alchemy",
              "value": "true"
            },
            {
              "name": "photoReal",
              "value": "false"
            },
            {
              "name": "presetStyle",
              "value": "ANIME"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "b8Ao8Jb2KoJezTx5",
          "name": "Relevance.ai [cocaina.Gmail]"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cbc60c2f-5f6e-4ff7-8afd-69559c9746d6",
      "name": "拆分出提示",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        880,
        192
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "7b9caa6d-84e2-4014-8fac-ff8b9bb84a6f",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        592
      ],
      "parameters": {
        "color": 4,
        "width": 440,
        "height": 300,
        "content": "## 使用 Leonardo.AI 生成图像"
      },
      "typeVersion": 1
    },
    {
      "id": "25e7606d-3adc-466a-861e-9b2640be6578",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        704,
        400
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"description\": {\n        \"type\": \"string\",\n        \"description\": \"The full, detailed prompt for the anime background, including artistic style, lighting, mood, and specific elements, suitable for an AI image model.\"\n      }\n    },\n    \"required\": [\"description\"]\n  }\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "0dd62df2-6ffe-4d20-a327-d0aaa383aad1",
      "name": "提示生成器(用户启发)",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        512,
        192
      ],
      "parameters": {
        "text": "=Enhance My Anime Image Prompt!\n\nI have a basic idea for an anime image, but I need your help to make it more detailed and visually appealing for AI image generation.\nPlease take my simple prompt below and transform it into *{{ $('Image-count').item.json.num_of_Images }}* highly detailed and compelling prompts. Make sure to include a rich character description, a vivid background description, specific artistic style instructions, and an emotional/narrative hook. Keep the output moderately detailed, focusing on impactful elements.\n\nHere's my amateur prompt:\n{{ $('Image-count').item.json.User_Prompt }}",
        "messages": {
          "messageValues": [
            {
              "message": "=You are an expert anime artist and prompt generator for AI image generation models. Your goal is to take a user's initial, amateur prompt for an anime character or scene and transform it into a highly detailed, compelling, and visually attractive prompt. The refined prompt should resonate deeply with anime lovers and the general public, focusing on visual appeal, emotional impact, and storytelling potential.\n\n\n***Input: You will receive a user-provided prompt, which may be brief or lack specific detail.***\n\n***Output: Generate one highly refined and enhanced anime character and background prompt. This prompt must include:***\n\n* A highly detailed character description: Elaborating on appearance, clothing, accessories, and a clear expression of personality/mood.\n* A highly detailed background description: Richly setting the scene, time of day, atmosphere, lighting, and key elements, ensuring it complements the character.\n* Specific artistic style and rendering instructions: To ensure a polished, professional anime look, including terms like \"masterpiece,\" \"trending on ArtStation,\" and specific anime studio or artist influences if appropriate.\n* Emotional resonance/narrative hook: Something that draws the viewer in and suggests a deeper story or feeling.\n\n\n\n***Chain of Thought for Refining Prompts:***\n\n\n**Deconstruct User Input:**\n\n* Identify the core character concept (e.g., \"girl,\" \"hero,\" \"student\").\n* Identify the core background concept (e.g., \"city,\" \"nature,\" \"room\").\n* Note any existing details, however sparse (e.g., \"blue hair,\" \"sunset\").\n* Assess the implied mood or genre (e.g., \"cute,\" \"sad,\" \"action\").\n\n**Expand Character Details:**\n\n* Appearance: Add specific hair color, style, length (e.g., \"long, flowing auburn hair,\" \"short, spiky black hair with undercut\"). Define eye color and shape (e.g., \"large, expressive emerald eyes,\" \"sharp, piercing golden eyes\").\n* Clothing: Go beyond generic descriptions. Specify fabric, style, layering, accessories (e.g., \"oversized, cable-knit cardigan in cream,\" \"sleek, futuristic battle armor with glowing energy conduits,\" \"vintage floral sundress with lace trim\").\n* Personality/Mood: Infuse subtle cues through expression, pose, or implied action (e.g., \"gentle, contemplative gaze,\" \"playful smirk,\" \"determined stance\"). Consider what they might be doing or thinking.\n\n** Elaborate Background Details:**\n\n* Scene: Expand on the type of location (e.g., \"bustling Shibuya crossing at night,\" \"serene bamboo grove with a hidden shrine,\" \"cozy, book-filled attic room with a skylight\").\n* Time/Atmosphere: Specify time of day and how it impacts lighting (e.g., \"golden hour with long, soft shadows,\" \"moonlit night with shimmering reflections,\" \"overcast morning with a cool, muted palette\").\n* Key Elements: Add specific objects, weather, or environmental effects (e.g., \"gentle rain leaving reflections on wet pavement,\" \"steam rising from manholes,\" \"cherry blossoms drifting through the air,\" \"ancient stone lanterns glowing softly\").\n* Depth & Perspective: Consider foreground, midground, and background elements.\n\n\n** Inject Artistic Style & Rendering Instructions:**\n\n* Translate the implied genre or mood into specific anime art styles (e.g., \"Makoto Shinkai-esque for atmospheric beauty,\" \"Kyoto Animation style for expressive characters,\" \"dynamic shonen art for action\").\n* Add quality descriptors: \"masterpiece,\" \"ultra-detailed,\" \"cinematic lighting,\" \"volumetric lighting,\" \"trending on ArtStation,\" \"concept art,\" \"8K.\"\n* Suggest color palettes: \"vibrant neon colors,\" \"soft pastel hues,\" \"muted earth tones.\"\n\n\n**Enhance Emotional/Narrative Hook:**\n\n* Consider the feeling the image should evoke (e.g., \"nostalgia,\" \"wonder,\" \"solitude,\" \"excitement,\" \"peace\").\n* Suggest a subtle narrative: Is the character waiting? Reflecting? Embarking on a journey? Interacting with the environment?\n\n\n***Review and Optimize:***\n\n* Read the complete prompt aloud. Does it flow well?\n* Is it specific enough for an AI to interpret accurately?\n* Is it evocative and appealing?\n* Are there strong adjectives and verbs?\n* Remove redundancies.\n* Ensure consistency between character and background mood.\n\n\n**Example Prompts (Your output should follow this structure):**\n\n*Example 1: Schoolgirl at Sunset*\nUser's Amateur Prompt:\n\"Anime girl in a school uniform at sunset.\"\n\nLLM's Moderately Detailed Prompt:\nA vibrant anime illustration of a cheerful young girl with shoulder-length brown hair and bright, sparkling blue eyes, wearing a standard Japanese school uniform (white blouse, navy blazer, red ribbon). She stands with a gentle smile, holding her school bag.\nThe background is a serene school courtyard at golden hour sunset. Warm, soft light bathes the brick building and illuminates the rustling leaves of a nearby cherry tree. Long shadows stretch across the ground, and the sky displays a beautiful gradient of orange, pink, and soft purple hues. A sense of peaceful nostalgia fills the air.\nArt Style: Kyoto Animation style, warm color palette, detailed lighting, masterpiece, trending on ArtStation.\n\n\n*Example 2: Fantasy Adventurer*\nUser's Amateur Prompt:\n\"Fantasy guy with a sword in a cave.\"\n\nLLM's Moderately Detailed Prompt:\nA dynamic anime illustration of a determined young man with short, spiky black hair and intense, glowing green eyes. He wears worn leather armor over a dark tunic and wields a glowing runic sword in a ready stance. His expression is focused and resolute.\nThe background is a dark, mystical cave illuminated by bioluminescent crystals. Faint blue and green light emanates from glowing formations on the damp rock walls. A small, cascading waterfall creates a soft mist in the air. The atmosphere is mysterious and adventurous, with hints of ancient magic.\nArt Style: Dynamic action anime, dark fantasy elements, volumetric lighting, highly detailed, concept art, trending on ArtStation.\n\n\n*Example 3: Cozy Café Scene*\nUser's Amateur Prompt:\n\"Anime character in a cafe.\"\n\nLLM's Moderately Detailed Prompt:\nA charming anime illustration of a relaxed young woman with long, wavy blonde hair and warm, inviting brown eyes. She sips from a steaming coffee mug, wearing a comfortable, oversized beige sweater. Her expression is one of calm contentment.\nThe background is a cozy, warmly lit café interior on a rainy afternoon. Soft light filters through the window, highlighting gentle raindrops sliding down the glass. Bookshelves filled with eclectic titles line the walls, and a few potted plants add warmth. The ambiance is peaceful and inviting, perfect for quiet reflection.\nArt Style: Slice-of-life anime, soft lighting, warm color palette, aesthetically pleasing, masterpiece, comforting mood."
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.5
    },
    {
      "id": "41523fb6-2de7-4123-9276-f12e906f94d1",
      "name": "来自 OpenRouter 的 DeepSeek",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        480,
        400
      ],
      "parameters": {
        "model": "deepseek/deepseek-chat-v3-0324:free",
        "options": {
          "topP": 0.8,
          "temperature": 0.7
        }
      },
      "credentials": {
        "openRouterApi": {
          "id": "oPGlise3ZkYmOynS",
          "name": "OpenRouter [Api.Gmail]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "bf7ec591-bba2-4f11-9139-311e5040acc6",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -224
      ],
      "parameters": {
        "color": 6,
        "width": 598,
        "height": 1280,
        "content": "# 🎨 动漫图像生成器 — 设置与说明"
      },
      "typeVersion": 1
    },
    {
      "id": "b060f972-79f4-42dd-8def-2acc3b63eb47",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2016,
        192
      ],
      "parameters": {
        "width": 256,
        "height": 288,
        "content": "## Not necessary\nUsed to avoid rate limits"
      },
      "typeVersion": 1
    },
    {
      "id": "1c590870-8030-4b6f-85a8-7ccf5c78c8e9",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        64
      ],
      "parameters": {
        "color": 3,
        "height": 256,
        "content": "## Configure Me!\nPaste your own chatID in the \"Restrict to Chat IDs\" field"
      },
      "typeVersion": 1
    },
    {
      "id": "6b04e902-842e-4550-b6b0-e94decd4a859",
      "name": "Send pics via Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1504,
        -48
      ],
      "webhookId": "fb21d8df-f012-4bdb-908f-457610cbe930",
      "parameters": {
        "chatId": "=",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "DCT0rTb6lDEXngOg",
          "name": "LXirein Bot (SMS)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "72ba948d-eb4c-4ee1-ba22-a441ddfcec4d",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        -160
      ],
      "parameters": {
        "color": 3,
        "height": 256,
        "content": "## Configure Me!\nPaste your own chatID in the \"ChatID\" field"
      },
      "typeVersion": 1
    },
    {
      "id": "e8584025-bf4d-44af-8680-00b28a39bda0",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        128
      ],
      "parameters": {
        "width": 704,
        "height": 80,
        "content": "## Generates 4 images for an image query"
      },
      "typeVersion": 1
    },
    {
      "id": "f417031a-195f-409c-9584-02f4e9844f11",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        864
      ],
      "parameters": {
        "width": 544,
        "height": 80,
        "content": "You cn try using different models for image generation here.\nGemini - [Good quality, 90 free trial with GCP account] (With nano-banana)\nLeonardo.AI - [Better quality, Paid API]\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Wait 10s": {
      "main": [
        [
          {
            "node": "Loop Over Prompts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set base64": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image-count": {
      "main": [
        [
          {
            "node": "Prompt generator (USER_Inspired)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP- Gemini": {
      "main": [
        [
          {
            "node": "Set base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Wait 10s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Image-count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Prompts": {
      "main": [
        [
          {
            "node": "Send pics via Telegram",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP- Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out Prompts": {
      "main": [
        [
          {
            "node": "Loop Over Prompts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeepSeek from OpenRouter": {
      "ai_languageModel": [
        [
          {
            "node": "Prompt generator (USER_Inspired)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Prompt generator (USER_Inspired)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Prompt generator (USER_Inspired)": {
      "main": [
        [
          {
            "node": "Split Out Prompts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Diptamoy Barman

Diptamoy Barman

@diptamoy-barman

Heya 👋 I’m Diptamoy, an AI enthusiast who loves sharing & teaching n8n automation to build real workflows that scale and solve real problems. Have questions? Drop them in the comments — I'm always open to help!

外部链接
在 n8n.io 查看

分享此工作流