用 Telegram 与 Gemini AI 分析产品成分照片
用户通过 Telegram 发送产品标签照片或成分文本 → n8n 工作流调用 Gemini 提取并分析成分 → 按有无说明返回使用建议或详细评估
- 给谁
- 需要快速检查护肤品、食品、补充剂或清洁产品成分安全性的用户
- 你会得到
- 通过 Telegram 机器人获得产品成分的使用建议/不建议决定,或包含优缺点、适用/不适用人群的详细分析
硬约束
前置条件:n8n 实例(自托管或云端)、Telegram Bot Token(通过 BotFather 获取)、Google Gemini API 凭证(googlePalmApi 类型)。将模板 workflow JSON 导入 n8n,配置两个凭证,激活工作流即可。未提供具体 API 费用信息。
他们做了什么
作者 parthpansuriya 在 n8n 创建了一个工作流模板:用户通过 Telegram 发送产品标签照片或成分文本,工作流自动调用 Google Gemini 2.5 Flash 提取成分,并根据用户是否附带说明(caption),返回「使用/不建议使用」的简洁建议,或输出优缺点、适用/不适用人群的详细分析。工作流还包含纯文本分支,可处理问候语、成分列表和离题查询。
效果如何
模板在 n8n.io 发布,展示节点连接与提示词配置(author_report)。来源未提供独立的效果验证数据或用户规模统计。
值得知道
1. 图像提取节点使用 photo[3].file_id(Telegram 多尺寸照片中的最大版本),若照片尺寸不足可能导致索引失败;建议测试时检查实际可用的 photo 数组长度。 2. Gemini 凭证类型在 n8n 中显示为 googlePalmApi,实际调用的是 Gemini 模型,属于 n8n 的遗留命名。 3. 结构化输出依赖 JSON Schema 示例,未启用严格模式,LLM 仍可能输出不符合格式的内容;建议在生产环境增加输出校验或重试。 4. 来源未提供 API 费用、速率限制或错误处理(如 Gemini 超时、Telegram 发送失败)的配置。 5. 本站未实测,reproduction=not_tested;上述提示词与节点参数均来自模板原文,未经验证运行。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- Google Gemini Chat Model1 节点:绑定Google Gemini/PaLM API 凭证。
- Google Gemini Chat Model2 节点:绑定Google Gemini/PaLM API 凭证。
- Analyzes product images using Google Gemini 节点:绑定Google Gemini/PaLM API 凭证。
- Retrieves photo file from Telegram 节点:绑定Telegram API 凭证。
- Sends Use/Do Not Use recommendation 节点:绑定Telegram API 凭证。
- Sends detailed ingredient analysis 节点:绑定Telegram API 凭证。
- Sends conversational responses 节点:绑定Telegram API 凭证。
需要替换的配置
- 源模板来自 n8n 公开库 #9112(约 17 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-24
步骤
设置 Telegram 触发器
在 n8n 中导入模板 workflow JSON。添加 Telegram Trigger 节点(Get a Message photo/text),配置 updates 为 ['message'],监听用户发来的照片或文本消息。
判断消息类型(照片或文本)
添加 IF 节点(Checks if message contains photo),检查 $json.message.photo[3].file_id 是否存在。存在则进入照片分支,不存在则进入文本分支。
提取照片并识别成分
照片分支:先用 Telegram 节点(Retrieves photo file from Telegram)通过 file_id 获取照片文件;再接入 Google Gemini 节点(Analyzes product images using Google Gemini),以 binary 形式传入图片,调用 gemini-2.5-flash 提取成分列表。
运行提示词 · 来源原文。Google Gemini 节点的 text 参数(图像分析提示词)
=Analyze this product image and extract only the list of ingredients. Ignore other text like brand names, slogans, or nutritional info. Return the ingredients as clean text in order and What the product is.
按是否附带说明路由
添加 Switch 节点(Routes based on caption presence),检查 message.caption 是否存在。有说明进入「使用建议」分支,无说明进入「详细分析」分支。
分析成分并返回结果
**有说明分支**:AI Agent 节点(Analyzes ingredients with user caption)将成分列表与用户说明一并送入 Gemini Chat Model,通过 Structured Output Parser 要求输出 {"recommendation": "Use"|"Do Not Use", "reason": "..."};再由 Telegram 节点发送加粗的推荐结果与理由。**无说明分支**:另一 AI Agent 节点(Analyzes ingredients without caption)仅输入成分列表,要求输出 advantages/disadvantages/recommended_for/not_recommended_for 各 3 点;Telegram 节点按模板格式发送结构化报告。
运行提示词 · 来源原文。AI Agent 节点的 user message 字段(有说明分支)
=Product ingredients :- {{ $json.content.parts[0].text }} User's Caption :- {{ $('Get a Message photo/text').item.json.message.caption }}运行提示词 · 来源原文。AI Agent 节点的 systemMessage 字段(有说明分支)
=You are a product safety and health advisor. You will receive two inputs: 1. A list of product ingredients. 2. A caption/description of the product. Your task is to: - Analyze the ingredients for safety, health impact, and potential concerns (like allergens, harmful chemicals, artificial additives, or beneficial elements). - Consider the product’s purpose (from the caption). - Decide if the user **should use this product or not**. Output Format: { "recommendation": "Use" or "Do Not Use", "reason": "Detailed explanation covering positives, negatives, and potential risks or benefits." } add only necessary information not include unnecessary information on reason.运行提示词 · 来源原文。Telegram 节点的 text 参数(有说明分支回复模板)
=** {{ $json.output.recommendation }} ** {{ $json.output.reason }}运行提示词 · 来源原文。AI Agent 节点的 user message 字段(无说明分支)
=Product ingredients :- {{ $('Analyzes product images using Google Gemini').item.json.content.parts[0].text }}运行提示词 · 来源原文。AI Agent 节点的 systemMessage 字段(无说明分支)
=You are a product health and safety advisor. You will be given a list of ingredients from a product. Your job is to analyze them and provide a structured, detailed output. Rules: - Do not invent ingredients that are not present. - Base all reasoning strictly on the provided ingredient list. - Be clear, factual, and practical for everyday users. give only 3 main points in each.
运行提示词 · 来源原文。Telegram 节点的 text 参数(无说明分支回复模板)
=**Advantages** • {{ $json.output.advantages[0] }} • {{ $json.output.advantages[1] }} • {{ $json.output.advantages[2] }} **Disadvantages** • {{ $json.output.disadvantages[0] }} • {{ $json.output.disadvantages[1] }} • {{ $json.output.disadvantages[2] }} **Recommended For** • {{ $json.output.recommended_for[0] }} • {{ $json.output.recommended_for[1] }} • {{ $json.output.recommended_for[2] }} **Not-Recommended For** • {{ $json.output.not_recommended_for[0] }} • {{ $json.output.not_recommended_for[1] }} • {{ $json.output.not_recommended_for[2] }}处理纯文本消息
文本分支:AI Agent 节点(Handles text messages and greetings)接收 message.text,由 Gemini Chat Model 驱动。系统提示词区分三种场景:用户直接提供成分列表时返回结构化分析;问候语时友好引导上传照片;离题话题时礼貌重定向。最后通过 Telegram 节点发送回复。
运行提示词 · 来源原文。AI Agent 节点的 systemMessage 字段(文本处理分支)
=You are an ingredient analysis assistant. Your main job is to analyze product ingredients and provide insights such as: - Advantages - Disadvantages - Who should use it - Who should avoid it - Final Verdict (Use / Do Not Use) Rules: --- If the user provides a list of ingredients, respond with a structured analysis using markdown format with bold headers: **Advantages** **Disadvantages** **Recommended For** **Not Recommended For** **Final Verdict** --- If the user greets you or sends casual small-talk (e.g., "hi", "hello", "how are you"), reply in a friendly way. Example: "Hey! I’m fine 😃 Please upload a photo of the product’s ingredients and I’ll tell you whether you should use it or not." --- If the user asks about something unrelated to ingredients (e.g., sports, politics, weather), politely redirect them. Example: "⚠️ I can only help with product ingredient analysis. Please share product ingredients or upload a photo of the label for review." 4. Always keep the tone clear, helpful, and user-friendly.
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限
这一段是提示词,页面不会在这里插入广告。
请根据以下材料在 n8n 中搭建 Telegram 成分分析机器人: 1. 导入 workflow JSON 模板; 2. 配置 Telegram Bot Token 与 Google Gemini API 凭证; 3. 按步骤连接触发器、分支、图像提取、AI Agent 与回复节点; 4. 激活前先用测试照片验证 photo[3].file_id 与 caption 路由是否正常。
搭建前请确认已拥有 n8n 实例、BotFather 的 Telegram Token 以及 Google Gemini API Key。
来源
Analyze product ingredient photos with Telegram & Gemini 2.5 Flash · parthpansuriya · n8n.io · 2025-09-30
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。