Telegram 全能 AI 助手:语音照片记忆笔记一体化
Telegram 消息 → n8n 路由处理 → GPT-4o-mini 分析 → Baserow 长期记忆/笔记存储 → Telegram 回复
- 给谁
- 需要为 Telegram 搭建多模态 AI 助手、具备长期记忆与笔记管理能力的自动化搭建者
- 你会得到
- Telegram 机器人可处理语音、照片、文本,自动提取信息存入 Baserow 数据库,并在后续对话中调用记忆生成个性化回复
硬约束
前置条件:n8n 实例(自托管或云)、Telegram Bot Token(通过 BotFather 获取)、OpenAI API Key、PostgreSQL 数据库(用于对话记忆缓冲)、Baserow 账号与 API Token。费用:OpenAI API 按用量计费(语音转录、图像分析、聊天补全),Baserow 有免费额度。来源未提供具体费用估算。
他们做了什么
作者 xxbean-sproutxx 在 n8n 模板市场发布了一个工作流模板,将 Telegram 机器人配置为多模态 AI 个人助手。工作流通过 Webhook 接收 Telegram 消息,使用 Switch 节点按语音/文本/照片路由,语音经 OpenAI Whisper 转录、照片经 GPT-4o-mini 图像分析、文本直接提取,所有内容汇入 AI Tools Agent。Agent 调用 GPT-4o-mini 处理,结合 PostgreSQL 中的短期对话记忆和 Baserow 中的长期记忆/笔记,生成个性化回复并通过 Telegram 返回。
效果如何
来源报告该模板可处理语音、照片(含文字说明)、文本三种输入,自动保存记忆与笔记,并基于历史信息生成上下文相关的回复(author_report)。模板在 n8n.io 获得 27,000 次查看。本站未实测运行效果。
值得知道
1. 用户验证硬编码在 Validation 节点中(first_name/last_name/id),需替换为实际 Telegram 信息,否则未授权用户会收到 "Unable to process your message"。2. Baserow 工具节点中的 databaseId(122)/tableId(639,640)/fieldId(6022,6024,6025,6027) 是模板示例值,必须替换为你自己 Baserow 实例的实际 ID。3. AI Agent 的 systemMessage 中时区写死为 America/Chicago,建议按实际部署位置修改。4. 模板含可选的额外工具占位符(Contacts, Calendar, Web Search, Qdrant Vector Retrieval),但未提供具体配置,需自行扩展。5. 语音处理链:Get Audio File → Transcribe Recording(OpenAI audio transcribe),照片处理链:Get Image → Extract from File to Base64 → Convert to Image File → Analyze Image(OpenAI image analyze)。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- gpt-4o-mini 节点:绑定OpenAI API 凭证。
- Telegram Response 节点:绑定Telegram API 凭证。
- Get Audio File 节点:绑定Telegram API 凭证。
- Analyze Image 节点:绑定OpenAI API 凭证。
- Transcribe Recording 节点:绑定OpenAI API 凭证。
- Get Image 节点:绑定Telegram API 凭证。
- Postgres Chat Memory 节点:绑定Postgres 凭证。
- Save Note Tool 节点:绑定baserowApi 凭证。
- Save Memory 节点:绑定baserowApi 凭证。
- Error message 节点:绑定Telegram API 凭证。
- Baserow Retrieve Memories 节点:绑定baserowApi 凭证。
- Baserow Retrieve Notes 节点:绑定baserowApi 凭证。
需要替换的配置
- 源模板来自 n8n 公开库 #2986(约 48 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-24
步骤
配置 Telegram 机器人与 Webhook
在 Telegram 中通过 @BotFather 创建机器人,获取 Bot Token。在 n8n 中配置 Telegram 凭证(telegramApi),并设置 Webhook 接收消息。验证节点(Validation + Check User & Chat ID)需填入你的 Telegram 姓名与 Chat ID,确保只有授权用户可触发工作流。
配置 Baserow 数据库与凭证
在 Baserow 创建 Workspace "Memories and Notes",建立两张表:Memory Table(字段:Memory-long text, Date Added-US date with time)和 Notes Table(复制 Memory Table 后重命名,字段:Notes, Date Added)。在 n8n 中配置 Baserow 凭证(baserowApi),记录 databaseId 和 tableId。
导入工作流并连接核心节点
从 n8n 模板市场导入 workflow JSON(模板 ID 2986)。确认核心节点连接:Webhook(Listen for Telegram Events)→ Switch(Message Router)→ 三条分支(语音/文本/图片)→ 各自预处理后汇入 AI Tools Agent。AI Tools Agent 连接 gpt-4o-mini(语言模型)、Postgres Chat Memory(短期记忆)、Window Memory(简易记忆)、Save Memory / Save Note Tool(Baserow 工具)。
配置 AI Agent 提示词
在 AI Tools Agent 节点的 Options → System Message 中填入以下系统提示词(定义 AI 角色、记忆/笔记管理规则、用户信息调用、当前时间等)。该提示词决定 AI 何时自动保存记忆/笔记、如何引用历史信息、如何称呼用户。
运行提示词 · 来源原文。AI Tools Agent 节点的 Options → System Message 字段
=## ROLE You are a friendly, attentive, and helpful AI assistant. Your primary goal is to assist the user while maintaining a personalized and engaging interaction. When possible, address the user by their first name to create a warmer, more personal experience. --- ## KEY TOOLS: MEMORY & NOTE MANAGEMENT These are the core features of this workflow. **You do not need permission to save notes and memories; it’s your decision based on the conversation.** ### Memory Management - **When to Use:** Evaluate each incoming message for noteworthy or personal information (e.g., preferences, habits, goals, important events, etc.). - **Action:** If the message contains such details, autonomously use the **Save Memory** Baserow tool to store a clear, concise summary. - **Response:** Always provide a meaningful reply that naturally acknowledges the input without revealing that a memory was saved. ### Note Management - **When to Use:** If the user shares specific instructions, reminders, or standalone pieces of information meant to be retained, use the **Save Note** Baserow tool. - **Action:** Save these as concise notes without asking for permission. - **Response:** Your reply should integrate the note context naturally, ensuring that the note’s purpose is honored without overemphasizing the saving action. --- ## GENERAL RULES 1. **Context Awareness:** - Use stored memories and notes to craft contextually relevant and personalized responses. - Always consider the date and time when a memory or note was collected to ensure your responses are up-to-date. 2. **User-Centric Responses:** - Tailor your responses based on the user's preferences and past interactions. - If the user’s first name is provided in the user info section, address them by name when it feels natural and appropriate. - Be proactive in recalling relevant details from memory or notes without overwhelming the conversation. 3. **Privacy and Sensitivity:** - Handle all user data with care. Do not share or expose stored information unless it directly enhances the interaction. - Never store passwords or usernames. 4. **Fallback Responses:** - If no specific task or question arises (e.g., when only saving information), respond in a way that keeps the conversation flowing naturally: - “Thanks for sharing that, [First Name]! Is there anything else I can help you with today?” - DO NOT tell jokes as a fallback response. 5. **Additional Tools:** - The remaining tools (Contacts, Calendar, Web Search, Qdrant Vector Retrieval) are available as extra features. They can be used when relevant but are secondary to the core Memory and Note management functionalities. --- ## USER INFO - **First Name**: {{ $('Listen for Telegram Events').item.json.body.message.from.first_name }} - **Age**: (if provided) - **Location**: (if provided) - **Job/Profession**: (if provided) Utilize this information to personalize your responses. For example, if the user's first name is available, begin responses with “Hi [First Name], …” --- ## REMAINING TOOLS ### <More Tools> - <if you add more tools, add them here and add descriptions> --- ## MEMORIES ### Recent Noteworthy Memories Here are the most recent memories collected from the user, including their date and time of collection: **{{ $json.data.map(item => item.Memory).join('\n') }}** **Guidelines:** - Prioritize recent memories while considering older ones if still relevant. - Cross-reference memories for consistency (e.g., if conflicting details are present, clarify as needed). --- ## NOTES ### Recent Notes Collected from User: Here are the most recent notes collected from the user: **{{ $json.data.map(item => item.Notes).join('\n') }}** **Guidelines:** - Use notes for specific instructions or reminders. - Keep note content distinct from general memory content. --- ## ADDITIONAL INSTRUCTIONS - Think critically before responding to ensure your answers are thoughtful and accurate. - Strive to build trust with the user by being consistent, reliable, and personable. - Avoid robotic or overly formal language; aim for a conversational tone that is both friendly and helpful. ## CURRENT DATE - {{ $now.setZone('America/Chicago').toISO() }} (Set Timezone Accordingly)运行提示词 · 来源原文。AI Tools Agent 节点的 Text 输入字段(动态选择文本/语音转录/图片分析结果)
={{ (() => { try { return $('Edit Fields').item.json.text; } catch (e) { return undefined; } })() || (() => { try { return $('Edit Fields1').item.json.text; } catch (e) { return undefined; } })() || (() => { try { return $('Transcribe Recording').item.json.text; } catch (e) { return undefined; } })() || 'default value' // optional default if all are undefined }}配置 Baserow 表结构(按模板要求)
按模板 sticky note 要求精确创建表结构。Memory Table 和 Notes Table 的字段类型、日期格式必须与模板一致,否则 AI Agent 的 $fromAI 工具调用可能失败。
搭建指导 · 来源原文。Baserow 后台手动配置;对应节点 Sticky Note4
## Baserow Set-up: - Create a new Workspace called "Memories and Notes" - Create a table within the new workspace called "Memory Table" - Within the "Memory Table" table, create two fields - First field is called "Memory" (select "long text" as the field type) - Second field is called "Date Added" (select 'US' date format, and check include time ## Notes Setup: - For the notes table we can simply "Duplicate" the "Memory Table" table that we just created - Rename the table to "Notes Table" - Rename the first from "Memory" to "Notes" - **Make sure time and date are on and set correctly in "Date Added" field.**
搭建指导 · 来源原文。Baserow 后台字段配置参考图;对应节点 Sticky Note16
## Baserow Memory Table Setup:  ## Name first field "Memory" and set to "Long Text":  ## Name second field "Date Added" and set to 'US' date format 
测试与部署
激活工作流后,向 Telegram 机器人发送文本、语音、带文字说明的照片,验证:1) 消息被正确路由;2) Baserow 中新增记忆/笔记记录;3) AI 回复引用历史信息。检查 n8n 执行日志排查凭证或节点错误。
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限,再按步骤执行
这一段是提示词,页面不会在这里插入广告。
你正在搭建一个基于 n8n 的 Telegram AI 助手,集成语音/照片/文本处理、GPT-4o-mini 分析、Baserow 长期记忆与笔记存储。请先确认你已准备好:n8n 实例、Telegram Bot Token、OpenAI API Key、PostgreSQL 数据库、Baserow 账号。然后按步骤配置凭证、导入工作流、设置 AI Agent 系统提示词、创建 Baserow 表结构,最后测试多模态消息流。
搭建前务必在 n8n 中配置好四种凭证:openAiApi、telegramApi、postgres、baserowApi。AI Agent 的 System Message 已提供原文,可直接复制到节点中。Baserow 的 databaseId/tableId/fieldId 需与你实际创建的表对应,模板中的 ID(如 122/639/640)仅为示例。
来源
All-in-one Telegram/Baserow AI assistant 🤖🧠 Voice/Photo/Save notes/Long term mem · xxbean-sproutxx · n8n.io · 2025-02-23
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。