用 n8n 搭建 Telegram AI 厨师机器人:自动生成食谱与餐厅风格食物图片
输入:Telegram 菜名消息 → 处理:n8n 工作流调用 OpenRouter 生成食谱与图像 → 输出:食谱文本 + 餐厅摆盘风格照片
- 给谁
- 需要在 Telegram 提供自动食谱与食物图片服务的运营者或开发者
- 你会得到
- 用户发送任意菜名,机器人自动回复详细食谱和餐厅风格摆盘图片
硬约束
前置条件:n8n 实例(需公网地址或支持 webhook 的托管环境)、Telegram Bot Token(通过 BotFather 获取)、OpenRouter API Key。费用:OpenRouter 按模型调用计费,gemini-2.5-flash-image-preview:free 为免费预览版,但免费额度与稳定性由 OpenRouter 决定。已知限制:Window Buffer Memory 使用 chat.id 作为 sessionKey,多用户共享同一聊天时记忆会混淆;图像生成依赖 OpenRouter 免费版可用性。
他们做了什么
作者创建了一个 n8n 工作流模板:用户通过 Telegram 发送菜名后,工作流依次调用 AI Agent 生成食谱文本、调用第二个 AI Agent 将食谱转换为图像生成提示词、通过 HTTP Request 调用 OpenRouter 的 gemini-2.5-flash-image-preview:free 生成图片、提取并转换图片格式后通过 Telegram 发回给用户。
效果如何
作者报告该机器人会回复完整食谱和餐厅摆盘风格图片(author_report)。效果未经本站实测验证。
值得知道
Window Buffer Memory 使用 chat.id 作为 sessionKey,同一聊天中的多用户会共享记忆上下文。图像生成节点使用 OpenRouter 免费预览模型,可用性和输出质量可能波动。工作流中的 HTTP Request 节点硬编码了 Authorization: Bearer $OPENROUTER_API_KEY 的头部格式,实际运行依赖 n8n 凭证系统的变量替换。建议搭建后先用简单菜名测试完整链路,再投入公开使用。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- OpenRouter Chat Model 节点:绑定openRouterApi 凭证。
- Telegram Trigger 节点:绑定Telegram API 凭证。
- Send a text message 节点:绑定Telegram API 凭证。
- Nano 🍌 节点:绑定openRouterApi 凭证。
- OpenRouter Chat Model1 节点:绑定openRouterApi 凭证。
- Send a photo message 节点:绑定Telegram API 凭证。
- 将 __UKH_BEARER_4__ 替换为实际密钥/令牌(原路径 /nodes/4/parameters/headerParameters/parameters/0/value;literal auth header)。
需要替换的配置
- 源模板来自 n8n 公开库 #8221(约 12 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。 另将 1 处字面量密钥替换为 __UKH_…__ 占位符。
模板获取日期: 2026-10-24
步骤
导入工作流并配置凭证
在 n8n 中导入此模板工作流。进入 Credentials,分别添加 telegramApi(填入 BotFather 提供的 Token)和 openRouterApi(填入 OpenRouter 的 API Key)。在工作流中确认两个节点已正确绑定凭证。
配置 AI Recipe 节点
打开 AI Recipe 节点(类型为 AI Agent),确认 promptType 为 define,text 字段为 `={{ $json.message.text }}`。在 Options 的 System Message 中填入以下系统提示词,用于定义虚拟厨师助手的角色与回复风格。
运行提示词 · 来源原文。AI Recipe 节点的 Options > System Message 字段
You are a friendly and professional Virtual Chef Assistant. Your role is to help users with cooking, recipes, meal planning, food substitutions, nutrition tips, and step-by-step cooking guidance. Guidelines: - Always reply in a clear, simple, and conversational tone. - Suggest recipes based on available ingredients, dietary preferences, or cuisine styles. - Provide step-by-step cooking instructions when asked. - Offer ingredient substitutions if something is missing. - Give nutrition advice when relevant, but do not provide medical advice. - Be creative, encouraging, and make cooking feel fun and easy. - If the user asks for meal plans, suggest balanced options (breakfast, lunch, dinner, snacks). - If the user asks general questions about food or cooking techniques, explain in an easy-to-understand way. - Do not provide unsafe cooking practices or harmful instructions. Your personality: - Warm, supportive, and encouraging like a personal chef. - Use a mix of professional cooking knowledge and friendly conversation. - Adapt tone depending on user: beginner = simple steps, experienced = more advanced techniques.
配置 Restaurant-Style Plating prompt 节点
打开 Restaurant-Style Plating prompt 节点(类型为 AI Agent),确认 promptType 为 define,text 字段为 `={{ $('AI Recipe').item.json.output }}`,即接收上一步生成的食谱文本。在 Options 的 System Message 中填入以下系统提示词,用于将食谱转换为图像生成提示词。
运行提示词 · 来源原文。Restaurant-Style Plating prompt 节点的 Options > System Message 字段
You are an expert AI prompt generator for text-to-image models. Your task is to read the recipe text provided and generate a single, clear, and detailed prompt suitable for a photorealistic image generation AI. Do not explain the recipe, do not add extra commentary, and do not output anything else except the image prompt. Focus only on visual details: - How the dish looks on a plate - Plating style and arrangement - Colors, textures, garnishes - Lighting and perspective - Use only plates and dishware typically found in professional restaurants (white ceramic, slate, glass, or elegant serving dishes) - Make it look like a high-end restaurant presentation The output should be concise, a single paragraph of text, fully descriptive, ready to feed directly into an image generation model and output should be in English.
配置图像生成与文件转换链路
确认 Nano 🍌 节点(HTTP Request)已配置为 POST 到 https://openrouter.ai/api/v1/chat/completions,模型为 google/gemini-2.5-flash-image-preview:free,请求体包含食谱文本作为图像生成提示词。Edit Fields 节点从响应中提取 image_url.url、base64 数据、MIME 类型和文件名。Convert to File 节点将 base64 字符串转换为二进制文件,供 Telegram 发送。
激活工作流并测试
保存并激活工作流。在 Telegram 中向机器人发送任意菜名(如 Polpette di pesce)。应收到:1) 详细食谱文本消息;2) 餐厅摆盘风格的食物照片。若未收到图片,检查 OpenRouter 免费版可用性及 n8n 执行日志中的错误信息。
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限
这一段是提示词,页面不会在这里插入广告。
你是一个 n8n 工作流搭建助手。用户想复现一个 Telegram AI 厨师机器人。请先确认用户是否已具备:1) 可接收 webhook 的 n8n 实例;2) Telegram Bot Token;3) OpenRouter API Key。然后按步骤指导导入模板、配置凭证、填入系统提示词、激活测试。不要替用户生成或修改提示词内容,仅使用来源提供的原文。
搭建前请确认 n8n 实例支持 webhook、已获取 Telegram Bot Token 和 OpenRouter API Key
来源
Generate custom recipes and restaurant-style food images with Telegram bot · shishirislam80 · n8n.io · 2025-09-03
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。