GeminiCreativeWritingAI score · PendingAI-assisted edit · no obvious prompt-injection riskn8n.io

Analyze Product Ingredient Photos with Telegram & Gemini AI

User sends a product label photo or ingredient text via Telegram → n8n workflow calls Gemini to extract and analyze ingredients → returns use recommendation or detailed assessment based on caption presence

Some experienceStepsWorkflowPrompt
Who
Users who want to quickly check ingredient safety for skincare, food, supplements, or cleaning products
You get
Receive a Use/Do Not Use verdict with reasoning, or a structured report with advantages, disadvantages, recommended and not-recommended groups via a Telegram bot
You need
n8n · telegram

Constraints

Prerequisites: n8n instance (self-hosted or cloud), Telegram Bot Token from BotFather, Google Gemini API credentials (googlePalmApi type). Import the template workflow JSON into n8n, configure both credentials, and activate the workflow. Specific API pricing not provided.

What they did

Author parthpansuriya created an n8n workflow template where users send a product label photo or ingredient text via Telegram. The workflow automatically calls Google Gemini 2.5 Flash to extract ingredients, then returns a concise Use/Do Not Use recommendation if a caption is provided, or a detailed analysis with advantages, disadvantages, and recommended/not-recommended groups if no caption is given. A text-handling branch also processes greetings, ingredient lists, and off-topic queries.

How it went

Published as a template on n8n.io with node connections and prompt configurations shown (author_report). No independent effectiveness metrics or user-scale statistics provided by the source.

Worth knowing

1. The image extraction node uses photo[3].file_id (largest size in Telegram's multi-size photo array); if the photo set has fewer sizes this index may fail—test with actual photos to verify available indices. 2. The Gemini credential type in n8n is labeled googlePalmApi, which is legacy naming for Gemini models. 3. Structured output relies on JSON Schema examples without strict mode enabled; LLMs may still produce malformed output—consider adding output validation or retries for production. 4. Source does not cover API costs, rate limits, or error handling (e.g., Gemini timeouts, Telegram send failures). 5. Not tested by this site; reproduction=not_tested. All prompts and node parameters are from the original template and have not been verified by execution.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • Google Gemini Chat Model1 node: connect Google Gemini/PaLM API credentials.
  • Google Gemini Chat Model2 node: connect Google Gemini/PaLM API credentials.
  • Analyzes product images using Google Gemini node: connect Google Gemini/PaLM API credentials.
  • Retrieves photo file from Telegram node: connect Telegram API credentials.
  • Sends Use/Do Not Use recommendation node: connect Telegram API credentials.
  • Sends detailed ingredient analysis node: connect Telegram API credentials.
  • Sends conversational responses node: connect Telegram API credentials.

Configuration to replace

  • Source template is n8n public workflow #9112 (~17 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-24

Steps

  1. Set up Telegram Trigger

    Import the template workflow JSON into n8n. Add a Telegram Trigger node (Get a Message photo/text), set updates to ['message'], and listen for incoming photos or text messages from users.

  2. Check Message Type (Photo or Text)

    Add an IF node (Checks if message contains photo) that checks whether $json.message.photo[3].file_id exists. If yes, route to the photo branch; if no, route to the text branch.

  3. Retrieve Photo and Extract Ingredients

    Photo branch: first use a Telegram node (Retrieves photo file from Telegram) to fetch the photo file by file_id; then connect to a Google Gemini node (Analyzes product images using Google Gemini), pass the image as binary input, and call gemini-2.5-flash to extract the ingredient list.

    Execution prompt · Source text。Google Gemini node text parameter (image analysis prompt)

    =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.
  4. Route by Caption Presence

    Add a Switch node (Routes based on caption presence) that checks whether message.caption exists. If a caption is present, route to the recommendation branch; if absent, route to the detailed analysis branch.

  5. Analyze Ingredients and Return Result

    **With-caption branch**: an AI Agent node (Analyzes ingredients with user caption) sends the ingredient list plus user caption to a Gemini Chat Model, using a Structured Output Parser to require {"recommendation": "Use"|"Do Not Use", "reason": "..."}; a Telegram node then sends the bold recommendation and reason.**Without-caption branch**: another AI Agent node (Analyzes ingredients without caption) receives only the ingredient list and requests advantages/disadvantages/recommended_for/not_recommended_for with 3 points each; a Telegram node formats and sends the structured report.

    Execution prompt · Source text。AI Agent node user message field (with-caption branch)

    =Product ingredients :- {{ $json.content.parts[0].text }}
    
    User's Caption :- {{ $('Get a Message photo/text').item.json.message.caption }}

    Execution prompt · Source text。AI Agent node systemMessage field (with-caption branch)

    =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.

    Execution prompt · Source text。Telegram node text parameter (with-caption branch reply template)

    =** {{ $json.output.recommendation }} **
    
    {{ $json.output.reason }}

    Execution prompt · Source text。AI Agent node user message field (without-caption branch)

    =Product ingredients :- {{ $('Analyzes product images using Google Gemini').item.json.content.parts[0].text }}

    Execution prompt · Source text。AI Agent node systemMessage field (without-caption branch)

    =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.

    Execution prompt · Source text。Telegram node text parameter (without-caption branch reply template)

    =**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] }}
  6. Handle Text Messages

    Text branch: an AI Agent node (Handles text messages and greetings) receives message.text and is driven by a Gemini Chat Model. The system prompt distinguishes three scenarios: structured analysis when the user provides an ingredient list, friendly guidance to upload a photo for greetings, and polite redirection for off-topic queries. A Telegram node then sends the reply.

    Execution prompt · Source text。AI Agent node systemMessage field (text handling branch)

    =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.

Prompt you can copy

Setup guidance · Editorial suggestion。Hand to setup assistant; confirm inputs and permissions first

This block is the prompt. Ads are never placed here.

Please build the Telegram ingredient-analysis bot in n8n using the following materials:
1. Import the workflow JSON template;
2. Configure Telegram Bot Token and Google Gemini API credentials;
3. Connect trigger, branch, image extraction, AI Agent, and reply nodes step by step;
4. Before activating, test with a sample photo to verify photo[3].file_id and caption routing.

Before building, confirm you have an n8n instance, a Telegram Token from BotFather, and a Google Gemini API Key.

Source

Analyze product ingredient photos with Telegram & Gemini 2.5 Flash · parthpansuriya · n8n.io · 2025-09-30

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related