Telegram AI 聊天机器人
第 6 部分 · 案例 1.1 · 🤖 AI 助手
# 复制后到 n8n 画布右键 → Paste 即导入
难度 🟢 简单 · 耗时 ~15 分钟 · 核心节点 Telegram Trigger × AI Agent × Memory
把一个 OpenAI Chat 接到 Telegram,5 个节点就能让你拥有一个能记得对话上下文的私人 AI 助手。这是入门 AI 自动化最好的第一个项目——你能立刻在手机上聊到。
- 你想要一个手机随时能聊的 AI 助手,又不想付 ChatGPT 订阅
- 想给家人/朋友做个共享 bot,每人记忆隔离
- 当作其他更复杂 AI workflow 的”入口”测试床
🔍 工作流连线图
Section titled “🔍 工作流连线图” ▦ workflow telegram-ai-bot.workflow.json Lv.1
📋 关键节点配置
Section titled “📋 关键节点配置”Telegram Trigger
Section titled “Telegram Trigger”去 Telegram 找 @BotFather 注册一个 bot,拿到 token,在 n8n 配 Telegram Credentials。然后:
⚙ telegram-trigger.txt
Updates: [message]
Credentials: <your-telegram-bot>
AI Agent
Section titled “AI Agent” ⚙ ai-agent.txt
Prompt: ={{ $json.message.text }}
System Message:
你是一个友好的中文 AI 助手,回答要简洁、有温度。
Max Iterations: 5
Window Buffer Memory(关键!)
Section titled “Window Buffer Memory(关键!)” ⚙ memory.txt
Session Key: ={{ $('Telegram Trigger').item.json.message.from.id }}
Context Window Length: 10
⚠ Session Key 必须用 Telegram user id 才能做到"每人独立记忆"
Send Telegram Reply
Section titled “Send Telegram Reply” ⚙ send-reply.txt
Chat ID: ={{ $('Telegram Trigger').item.json.message.chat.id }}
Text: ={{ $json.output }}
📥 一键复制 Workflow JSON
Section titled “📥 一键复制 Workflow JSON” 📋 telegram-ai-bot.workflow.json