Telegram机器人
中级
这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 Set, Switch, Telegram, Agent, TelegramTrigger 等节点。 构建支持文本和图像响应的Telegram机器人,集成Google Gemini 2.5 Flash
前置要求
- •Telegram Bot Token
- •Google Gemini API Key
使用的节点 (15)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "pl3YbOUdHMsDTYFE",
"meta": {
"instanceId": "f21041c58ebe9ae27fd386689e649a871f62f45682ca1c57f2ff2f2e3c9a5999"
},
"name": "TelegramBOT",
"tags": [],
"nodes": [
{
"id": "sticky-note-main",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1100,
-300
],
"parameters": {
"color": 4,
"width": 460,
"height": 640,
"content": "## 📋 TELEGRAM AI BOT - 设置指南"
},
"typeVersion": 1
},
{
"id": "sticky-note-trigger",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-820,
-80
],
"parameters": {
"color": 5,
"width": 280,
"height": 160,
"content": "## 🚀 触发器"
},
"typeVersion": 1
},
{
"id": "sticky-note-router",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-600,
-80
],
"parameters": {
"color": 6,
"width": 260,
"height": 140,
"content": "## 🔀 路由"
},
"typeVersion": 1
},
{
"id": "sticky-note-image",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-380,
160
],
"parameters": {
"color": 3,
"width": 360,
"height": 380,
"content": "## 🖼️ 图片处理"
},
"typeVersion": 1
},
{
"id": "sticky-note-agent",
"name": "便签 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
280,
-80
],
"parameters": {
"color": 2,
"width": 300,
"height": 180,
"content": "## 🤖 AI代理"
},
"typeVersion": 1
},
{
"id": "568a5011-79b3-4660-88d9-c8b4c7c4519d",
"name": "知识库代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
352,
64
],
"parameters": {
"text": "=Use these Descriptions to reply with a message to the user according to his question simply, shortly, and make sure he understand the thing he attaches:\n\n\"\" {{ $json.text }} \"\"\n\n\nI need your output message to be well spaced and formatted and look as attractive as possible for a telegram response!",
"options": {
"systemMessage": ""
},
"promptType": "define"
},
"typeVersion": 1.9
},
{
"id": "0c3f40bf-3773-4f7b-8b88-404e872d1188",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
400,
464
],
"parameters": {
"sessionKey": "=memory_{{ $('Telegram Trigger').item.json.message.message_id }}",
"sessionIdType": "customKey",
"contextWindowLength": 20
},
"typeVersion": 1.3
},
{
"id": "74a1218b-fb53-450c-8462-ccad268ad7ee",
"name": "映射图片提示",
"type": "n8n-nodes-base.set",
"position": [
128,
272
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "48af2dcc-4ce9-45fc-abfc-54f803930092",
"name": "text",
"type": "string",
"value": "=User image description:\n\n{{ $json.content.parts[0].text }}\n\nUser image caption: {{ $('Telegram Trigger').item.json.message.caption }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "85b4e665-2468-40c1-aa99-bd67e048d9fb",
"name": "映射文本提示",
"type": "n8n-nodes-base.set",
"position": [
-96,
-208
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "38aec976-a32c-4b0e-85f4-c90adc16abc9",
"name": "text",
"type": "string",
"value": "={{ $json.messages[0].text.body }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "482edd25-6a05-45cd-bb1f-c11d451938f5",
"name": "路由类型",
"type": "n8n-nodes-base.switch",
"position": [
-544,
64
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2fc5c912-629b-4cbe-b5e3-7e3f0651c628",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": "text"
}
]
},
"renameOutput": true
},
{
"outputKey": "Image",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "840b95b8-6559-4fb7-b32c-651451d6d0d2",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.photo[2] }}",
"rightValue": "image"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "5cf1706c-cd33-4def-a99d-958d51654088",
"name": "Google Gemini聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
240,
464
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"id": "dBVkcKvaggEaTZ3w",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "46fd3fa6-5261-4fcf-b148-52a7ce0b2c43",
"name": "分析图片",
"type": "@n8n/n8n-nodes-langchain.googleGemini",
"position": [
-96,
272
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "models/gemini-2.5-flash",
"cachedResultName": "models/gemini-2.5-flash"
},
"options": {},
"resource": "image",
"inputType": "binary",
"operation": "analyze"
},
"credentials": {
"googlePalmApi": {
"id": "dBVkcKvaggEaTZ3w",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "5b5f176c-7d2d-4db2-9f55-cc4dc18f6d4a",
"name": "Telegram触发器",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-768,
64
],
"webhookId": "049da2eb-7ce1-4efd-820f-6a700adea8b6",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"typeVersion": 1.2,
"alwaysOutputData": false
},
{
"id": "6489c29a-2c59-4362-916a-605f3e63c866",
"name": "获取文件",
"type": "n8n-nodes-base.telegram",
"position": [
-320,
272
],
"webhookId": "d1b193c3-236e-4bed-be47-d0e156960d35",
"parameters": {
"fileId": "={{ $json.message.photo[2].file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "Q0bwwwn2wzmbamLh",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "7b1b528f-4e3e-48d3-bc33-638fa4a3f446",
"name": "发送文本消息",
"type": "n8n-nodes-base.telegram",
"position": [
704,
64
],
"webhookId": "53b5dc25-a9ea-47b4-87b7-274984c1115d",
"parameters": {
"text": "={{ $json.output }}",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "Q0bwwwn2wzmbamLh",
"name": "Telegram account"
}
},
"typeVersion": 1.2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "332b36b7-0523-4d91-9ec6-0cb0b948d7f2",
"connections": {
"Get a file": {
"main": [
[
{
"node": "Analyze image",
"type": "main",
"index": 0
}
]
]
},
"Route Types": {
"main": [
[
{
"node": "Map text prompt",
"type": "main",
"index": 0
}
],
[
{
"node": "Get a file",
"type": "main",
"index": 0
}
]
]
},
"Analyze image": {
"main": [
[
{
"node": "Map image prompt",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "Knowledge Base Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Map text prompt": {
"main": [
[
{
"node": "Knowledge Base Agent",
"type": "main",
"index": 0
}
]
]
},
"Map image prompt": {
"main": [
[
{
"node": "Knowledge Base Agent",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger": {
"main": [
[
{
"node": "Route Types",
"type": "main",
"index": 0
}
]
]
},
"Knowledge Base Agent": {
"main": [
[
{
"node": "Send a text message",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Knowledge Base Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 内容创作, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
我的工作流
卡路里追踪与饮食记录(Telegram、Gemini AI和数据表)
If
Set
Code
+13
73 节点Gerald Denor
内容创作
使用 Telegram 和 Google Gemini 的个人助理机器人
基于 Telegram 和 Google Gemini 的多模态个人AI助手,集成生产力工具
Set
Code
Merge
+16
83 节点Anshul Chauhan
内容创作
Telegram AI代理基础模板
基于Claude和Gemini支持语音、图像和视频分析的多模态Telegram机器人
Set
Merge
Switch
+10
31 节点Keith Uy
内容创作
Nano Banana-Gemini 2.5多模态Telegram机器人
基于Nano Banana/Gemini 2.5的多模态Telegram机器人
If
Set
Code
+11
36 节点Denis
内容创作
使用OpenAI Whisper和Gemini将Telegram内容转换为多平台帖子
使用OpenAI Whisper和Gemini将Telegram内容转换为多平台帖子
If
Set
Switch
+10
63 节点Juan Carlos Cavero Gracia
内容创作
AI驱动的潜在客户抓取(使用APIFY爬虫、Gemini筛选,输出到Google Sheets)
基于AI的潜在客户处理:从Apify使用Gemini和Google Sheets
Wait
Telegram
Http Request
+7
19 节点Ahmed Sherif
内容创作