8
n8n 中文网amn8n.com

通过 Telegram 使用 Pollinations 生成图像和 Gemini 2.5 生成博客文章

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 34 个节点。主要使用 If, Set, Code, Switch, Telegram 等节点。 通过 Telegram 使用 Pollinations 生成图像和 Gemini 2.5 生成博客文章

前置要求
  • Telegram Bot Token
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "ba73835d772fb31a8c93dbcda773c1ef34e21227b9c152c1ee6fdf0eab995f28",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ad8656b2-a542-4942-a978-23bfe85721db",
      "name": "Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        560,
        260
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite-preview-06-17"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "0F73fCXNqVx03YLr",
          "name": "Google Gemini(PaLM) Api account 2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae3d4575-e1c9-4fc8-b4ef-d2394e24acb1",
      "name": "触发 Telegram 消息",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1280,
        -220
      ],
      "webhookId": "7b019646-348f-4f01-b9ad-c25fb8cdaedc",
      "parameters": {
        "updates": [
          "callback_query",
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "CU5S8GReZfzUW955",
          "name": "Tele Image Generator"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "116ee884-b2ea-42af-addd-5e335197c990",
      "name": "分类 Telegram 输入",
      "type": "n8n-nodes-base.code",
      "position": [
        -1060,
        -220
      ],
      "parameters": {
        "jsCode": "let inputType = '';\n\nif ($json.hasOwnProperty(\"callback_query\")) {\n  const cbData = $json.callback_query.data || \"\";\n  \n  if (cbData.startsWith(\"style_\")) {\n    inputType = 'style';\n  } else {\n    inputType = 'callback_query';\n  }\n\n} else if (\n  $json.hasOwnProperty(\"message\") &&\n  $json.message.text === \"/start\"\n) {\n  inputType = 'message';\n\n} else if (\n  $json.hasOwnProperty(\"message\") &&\n  $json.message.text &&\n  $json.message.text.toLowerCase().startsWith(\"/help\")\n) {\n  inputType = \"help\";\n\n} else if (\n  $json.hasOwnProperty(\"message\") &&\n  $json.message.text\n) {\n  inputType = 'text';\n}\n\nreturn [\n  {\n    json: {\n      ...$json,\n      inputType\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7087e9ef-b1e6-486d-88f1-1a49397579c4",
      "name": "切换输入类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        -840,
        -240
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "58bd7d4b-4553-4e9c-85ee-a92b50e1e93b",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "message"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "e5b29bef-e663-45e1-9e6e-21dde7e2627e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "=callback_query"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "75121808-30dd-4205-adef-e4c4d062ad37",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "text"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6dd8132d-6c99-4b01-b55a-be53cab37bb2",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.inputType }}",
                    "rightValue": "style"
                  }
                ]
              }
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.2
    },
    {
      "id": "d5976879-6a5b-492c-82bd-e4189b4da648",
      "name": "向用户发送主菜单",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -620,
        -580
      ],
      "webhookId": "effd353c-0bfe-44d9-889e-8314d3034888",
      "parameters": {
        "text": "Please choose a menu:",
        "chatId": "={{$json[\"message\"][\"chat\"][\"id\"]}}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Generate Image",
                    "additionalFields": {
                      "callback_data": "image"
                    }
                  },
                  {
                    "text": "Blog Article",
                    "additionalFields": {
                      "callback_data": "blog"
                    }
                  },
                  {
                    "text": "❓ Help",
                    "additionalFields": {
                      "callback_data": "help"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "CU5S8GReZfzUW955",
          "name": "Tele Image Generator"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "01112b5e-05f5-4877-bf2d-16ed895b0801",
      "name": "切换回调选择",
      "type": "n8n-nodes-base.switch",
      "position": [
        -640,
        -400
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "56c41166-8753-4a92-ae59-68949a001b74",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "image"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bd80f13b-f7c6-4578-b23a-5490a04b41b5",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "blog"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "0274338b-4f92-4405-ba57-a80049db0b53",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "help"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "672826f4-1a49-41fe-ae3e-36365b5611c6",
      "name": "提示用户输入图片描述",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -360,
        -760
      ],
      "webhookId": "7f16cbe4-eab9-4690-b07e-4cc207cbc019",
      "parameters": {
        "text": "Please send an image prompt, start with image",
        "chatId": "={{ $json.callback_query.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "CU5S8GReZfzUW955",
          "name": "Tele Image Generator"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "09bc2384-c4c3-4a29-9910-e68622a0621d",
      "name": "提示用户输入博客标题",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -360,
        -580
      ],
      "webhookId": "99329519-a287-425d-84ad-5db503f88bd9",
      "parameters": {
        "text": "Please submit article title, start with blog",
        "chatId": "={{ $json.callback_query.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "CU5S8GReZfzUW955",
          "name": "Tele Image Generator"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9e8d3f41-0d4e-4a06-aab9-289fa374a3a7",
      "name": "验证命令格式",
      "type": "n8n-nodes-base.if",
      "position": [
        -640,
        -220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f8a7aca4-5637-44aa-b3ce-dab8fcb25aec",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.text.startsWith('image') || $json.message.text.startsWith('blog') }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "892747b0-9fcf-4cca-b781-29d22f782a81",
      "name": "检测基于文本的输入类型",
      "type": "n8n-nodes-base.set",
      "position": [
        -360,
        -240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a82b158b-21dc-4018-8887-1a936e50d525",
              "name": "=typeText",
              "type": "string",
              "value": "={{ $json.inputType === 'text' && $json.message.text && $json.message.text.toLowerCase().startsWith('blog') ? 'blog' : 'image' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0bf22449-827c-4b9a-991f-cf4d7b18b2c0",
      "name": "切换文本命令类型",
      "type": "n8n-nodes-base.switch",
      "position": [
        -120,
        -240
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8375ffa7-4f87-4dd6-ae62-6a908eb61b4f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.typeText }}",
                    "rightValue": "image"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bd572c93-d722-4953-a6d3-a3eb1c5f4e5f",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.typeText }}",
                    "rightValue": "=blog"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "7f184919-2d9e-4ec7-aa3b-f20720c42779",
      "name": "构建图片生成 URL",
      "type": "n8n-nodes-base.code",
      "position": [
        340,
        -340
      ],
      "parameters": {
        "jsCode": "const width = 1024;\nconst height = 1024;\nconst randomSeed = Math.floor(Math.random() * 100000);\n\nconst finalPrompt = $('Switch Input Type').first().json.message.text;\nconst imageUrl = `https://image.pollinations.ai/prompt/${encodeURIComponent(finalPrompt)}.jpg?width=${width}&height=${height}&seed=${randomSeed}&model=flux&nologo=true`;\n\nreturn [\n  {\n    json: {\n      text: finalPrompt,\n      imageUrl\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0699c5a1-a030-4a4f-be9e-8ff615dc4037",
      "name": "下载 AI 图片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        560,
        -340
      ],
      "parameters": {
        "url": "={{ $json.imageUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "58b67910-d5ed-4993-b71d-a5ca4c31a1f9",
      "name": "发送图片结果至 Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        780,
        -340
      ],
      "webhookId": "603fa444-2d96-40d2-8e88-37ef980e381c",
      "parameters": {
        "chatId": "={{ $('Trigger Telegram Message').item.json.message.chat.id }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "CU5S8GReZfzUW955",
          "name": "Tele Image Generator"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5ad1b4cd-102d-4786-a11e-329cf9150a81",
      "name": "记录图片提示到 Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        960,
        -340
      ],
      "parameters": {
        "columns": {
          "value": {
            "date": "={{ new Date().toLocaleString() }}",
            "type": "image",
            "output": "={{ $('Download AI Image').item.json.imageUrl }}",
            "prompt": "={{ $('Download AI Image').item.json.text }}",
            "user id": "={{ $('Validate Command Format').item.json.message.chat.id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "8SCk1D65lQur82YT",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "c89ca7b4-3338-4497-90f0-d003562b3487",
      "name": "上传图片到Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        780,
        -520
      ],
      "parameters": {
        "name": "={{ $json.text }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1afFdG_eCYtca7fNAz1t7deKxIOcqZ0tv",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1afFdG_eCYtca7fNAz1t7deKxIOcqZ0tv",
          "cachedResultName": "telegram img generator assets"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "en8M5JCW3g49rIK1",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "ef820546-a244-4b84-bead-914ddc4faeb0",
      "name": "通知无效输入格式",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -360,
        -80
      ],
      "webhookId": "55090118-c497-41a7-b808-979d49d6a544",
      "parameters": {
        "text": "❌ Invalid format. Please use image your prompt or blog your title.",
        "chatId": "={{ $('Switch Input Type').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "CU5S8GReZfzUW955",
          "name": "Tele Image Generator"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "de96a570-97cb-491b-bd2d-0c7d0798058c",
      "name": "显示文章响应的输入状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        100,
        -120
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot[your-token]/sendChatAction",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $('Switch Input Type').item.json.message.chat.id }}"
            },
            {
              "name": "action",
              "value": "typing"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7573c3f9-4c6c-45d5-b7d6-2ace53258d29",
      "name": "显示图片生成的输入状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        100,
        -340
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot[your-token]/sendChatAction",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $('Switch Input Type').item.json.message.chat.id }}"
            },
            {
              "name": "action",
              "value": "upload_photo"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "98ee826a-4cb5-415d-b974-23edd06b9a31",
      "name": "发送帮助说明",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -360,
        -400
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot{YOUR-TOKEN}/sendMessage",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $json.callback_query.message.chat.id }}"
            },
            {
              "name": "parse_mode",
              "value": "Markdown"
            },
            {
              "name": "text",
              "value": "=Welcome! Here's how to use this bot:\n\n🖼️ /image\nType the command:  \n`image of mountain scenery at sunrise`\n\n📝 /blog \nType the command:  \n`blog What is MongoDB`\n\n🧾 Format:\n- Start with the keyword `image` or `blog`\n- After that, write a description or title\n- Without quotation marks\n\n📌 Correct Example:\n- `image of a futuristic house on a cloud`\n- `blog How to Learn React Native for Beginners`\n\nIf you are still confused, type `/start` to open the main menu.\n\nThank you! 🙌\n\nTranslated with DeepL.com (free version)"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "06407eb2-aafd-40aa-bb22-8970d2f08100",
      "name": "发送文章样式选项",
      "type": "n8n-nodes-base.telegram",
      "position": [
        780,
        -120
      ],
      "webhookId": "f93e7b41-0c92-4c9a-97c9-d8e34cb16f66",
      "parameters": {
        "text": "Choose your preferred article style:",
        "chatId": "={{ $('Validate Command Format').item.json.message.chat.id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Formal",
                    "additionalFields": {
                      "callback_data": "style_formal"
                    }
                  },
                  {
                    "text": "Relax",
                    "additionalFields": {
                      "callback_data": "relax_style"
                    }
                  },
                  {
                    "text": "News",
                    "additionalFields": {
                      "callback_data": "news_style"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "CU5S8GReZfzUW955",
          "name": "Tele Image Generator"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7c4d2f57-d083-4a91-991f-6f58d1fef66d",
      "name": "存储博客提示",
      "type": "n8n-nodes-base.set",
      "position": [
        340,
        -120
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "30d22676-0174-4723-947e-5d8e604cd320",
              "name": "blogTitle",
              "type": "string",
              "value": "={{ $('Validate Command Format').item.json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c9503a8c-7a61-41db-bc3b-a1ea3c368a87",
      "name": "记录博客提示到 Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        560,
        -120
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $('Validate Command Format').item.json.message.date }}",
            "prompt": "={{ $json.blogTitle }}",
            "user id": "={{ $('Validate Command Format').item.json.message.chat.id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "8SCk1D65lQur82YT",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "452c93e8-4ee9-4b81-a2cc-5e4f65e43864",
      "name": "存储选定的文章样式",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -120,
        80
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "=",
            "style": "={{ $json.callback_query.data.replace('style_', '') }}",
            "user id": "={{ $json.callback_query.message.chat.id }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "user id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "gid=0"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "8SCk1D65lQur82YT",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "da632e75-b26c-44ea-8385-40710ae4259c",
      "name": "获取最后用户提示",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        100,
        80
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json['user id'] }}",
              "lookupColumn": "user id"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "8SCk1D65lQur82YT",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "a5de2e3d-cd42-4725-bb41-08f9eed810e1",
      "name": "提取最后博客提示",
      "type": "n8n-nodes-base.code",
      "position": [
        340,
        80
      ],
      "parameters": {
        "jsCode": "const userId = $('Switch Input Type').first().json.callback_query.message.chat.id || $('Switch Input Type').first().json.callback_query.message.chat.id\n\nconst rows = items.map(item => item.json);\n\n// Filter data according to User ID\nconst filtered = rows.filter(r => r['user id'] == userId);\n\n// Take the last line of the user\nconst lastRow = filtered[filtered.length - 1];\n\nreturn [{ json: lastRow }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e605824e-3934-4bb1-8303-5ad3a144dd57",
      "name": "使用 Gemini 生成文章",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        580,
        80
      ],
      "parameters": {
        "text": "={{ $json.prompt }}",
        "messages": {
          "messageValues": [
            {
              "message": "=Write an English blog post based on the title: {{ $json.Prompt }}.\\n\\nLength about 3 paragraphs. Use the article style {{ $json.Style }}\n\ndo not add any introduction. directly provide the output.\n\nFollow the json format below :\n\n\n  {\n    \"title\": \"title\",\n    \"content\": \"content\"\n  }\n"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "dc89f75a-1e6d-4cd1-9cdb-d9779663496f",
      "name": "解析 Gemini 响应",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        80
      ],
      "parameters": {
        "jsCode": "const raw = $json.text;\nconst clean = raw.replace(/```json|```/g, '').trim(); // optional: just in case the model still adds\nconst parsed = JSON.parse(clean);\nreturn [{ json: parsed }];"
      },
      "typeVersion": 2
    },
    {
      "id": "3107ddba-743b-4792-9731-bbd26873abcf",
      "name": "发送文章至 Telegram",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1180,
        80
      ],
      "parameters": {
        "url": "https://api.telegram.org/bot-YOURTOKEN/sendMessage",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $('Extract Last Blog Prompt').item.json['user id'] }}"
            },
            {
              "name": "text",
              "value": "={{ $json.title }}\n\n{{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5c5933cd-479e-4255-8ed4-115cfbbc1f01",
      "name": "记录最终文章到 Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1420,
        80
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "=",
            "date": "={{ new Date().toLocaleString() }}",
            "type": "blog",
            "output": "={{ $('Parse Gemini Response').item.json.content }}",
            "prompt": "={{ $('Parse Gemini Response').item.json.title }}",
            "user id": "={{ $json.result.chat.id }}",
            "row_number": "={{ $('Extract Last Blog Prompt').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "user id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "style",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "style",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dCxrF8eJqe_oYY6wZ1Zqo97v96SsXohVVzDgqUHVn1I/edit?usp=drivesdk",
          "cachedResultName": "History"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "8SCk1D65lQur82YT",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "50a9f952-da98-4940-b53a-6c39fb97965b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3420,
        -1660
      ],
      "parameters": {
        "width": 640,
        "height": 940,
        "content": "# 使用 Pollinations AI 生成图片和使用 Gemini 2.5 从 Telegram 生成博客文章"
      },
      "typeVersion": 1
    },
    {
      "id": "c1a9d6fd-2c5b-4450-a2da-4d1e57602703",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2720,
        -1660
      ],
      "parameters": {
        "color": 3,
        "width": 640,
        "height": 680,
        "content": "## ⚙️ 设置说明:"
      },
      "typeVersion": 1
    },
    {
      "id": "0f06dde2-108d-48b4-b2a9-ecd624c48c42",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2020,
        -1660
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 480,
        "content": "## 🔐 安全最佳实践:"
      },
      "typeVersion": 1
    },
    {
      "id": "f1271c8b-f7ba-4c62-93cc-02bb5504d767",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3420,
        -560
      ],
      "parameters": {
        "width": 920,
        "height": 1300,
        "content": "## 🔁 Google Sheets 集成 (📄 日志系统)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Download AI Image": {
      "main": [
        [
          {
            "node": "Send Image Result to Telegram",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload Image to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Article with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Store Blog Prompt": {
      "main": [
        [
          {
            "node": "Log Blog Prompt to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Input Type": {
      "main": [
        [
          {
            "node": "Send Main Menu to User",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch Callback Selection",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Validate Command Format",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Store Selected Article Style",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Gemini Response": {
      "main": [
        [
          {
            "node": "Send Article to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Last User Prompt": {
      "main": [
        [
          {
            "node": "Extract Last Blog Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Telegram Input": {
      "main": [
        [
          {
            "node": "Switch Input Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Command Format": {
      "main": [
        [
          {
            "node": "Detect Text-Based Input Type",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Invalid Input Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Last Blog Prompt": {
      "main": [
        [
          {
            "node": "Generate Article with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Article to Telegram": {
      "main": [
        [
          {
            "node": "Log Final Article to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Text Command Type": {
      "main": [
        [
          {
            "node": "Show Typing for Image Generation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Show Typing for Article Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Telegram Message": {
      "main": [
        [
          {
            "node": "Classify Telegram Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Callback Selection": {
      "main": [
        [
          {
            "node": "Prompt User for Image Description",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prompt User for Blog Title",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Help Instructions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Image Generation URL": {
      "main": [
        [
          {
            "node": "Download AI Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt User for Blog Title": {
      "main": [
        []
      ]
    },
    "Detect Text-Based Input Type": {
      "main": [
        [
          {
            "node": "Switch Text Command Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Article with Gemini": {
      "main": [
        [
          {
            "node": "Parse Gemini Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Selected Article Style": {
      "main": [
        [
          {
            "node": "Fetch Last User Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Image Result to Telegram": {
      "main": [
        [
          {
            "node": "Log Image Prompt to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Blog Prompt to Google Sheets": {
      "main": [
        [
          {
            "node": "Send Article Style Options",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Typing for Article Response": {
      "main": [
        [
          {
            "node": "Store Blog Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Show Typing for Image Generation": {
      "main": [
        [
          {
            "node": "Build Image Generation URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Image Prompt to Google Sheets": {
      "main": [
        []
      ]
    },
    "Log Final Article to Google Sheets": {
      "main": [
        []
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Fahmi Oktafian

Fahmi Oktafian

@fahmi3322

Hi! I’m Fahmi Oktafian, a developer and automation enthusiast with expertise in n8n, Node.js, and API integrations. I specialize in building smart, scalable workflows — from auto-publishing content to WordPress, sending automated Telegram notifications, to processing AI-based summaries and paraphrase. I’m passionate about helping businesses save time, increase efficiency, and automate their digital processes with clean and user-friendly solutions.

外部链接
在 n8n.io 查看

分享此工作流