AutomationFlowsAI & RAG › Product Ingredient Safety Analyzer with Google Gemini via Whatsapp

Product Ingredient Safety Analyzer with Google Gemini via Whatsapp

ByRoshan Ramani @rawsun007 on n8n.io

This workflow creates an intelligent WhatsApp bot that analyzes product ingredients and provides instant safety assessments. Users can send either text queries (product names/brands) or images of product labels, and receive AI-powered analysis covering food, cosmetics, personal…

Event trigger★★★★☆ complexityAI-powered15 nodesWhatsApp TriggerWhatsAppHTTP RequestAgentGoogle Gemini ChatOutput Parser Structured
AI & RAG Trigger: Event Nodes: 15 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #9098 — we link there as the canonical source.

This workflow follows the Agent → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0e96888f-f71c-4e0e-8550-919c1fa4d40a",
      "name": "WhatsApp Trigger",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        -1216,
        -288
      ],
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1c9439dd-6cd0-4455-895f-bb6b26e9f8e6",
      "name": "Route By Message Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1008,
        -288
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "85e50000-c740-43e4-a519-d1de10c9bc82",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.messages[0].type }}",
                    "rightValue": "image"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "91ee10e4-fc37-4de7-9360-2060a9ec16dd",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.messages[0].type }}",
                    "rightValue": "text"
                  }
                ]
              }
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.3
    },
    {
      "id": "ac24a055-4e1c-4b0c-9046-1a3b63ce609a",
      "name": "Get Image Media URL",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        -800,
        -304
      ],
      "parameters": {
        "resource": "media",
        "operation": "mediaUrlGet",
        "mediaGetId": "={{ $json.messages[0].image.id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "56476b24-aa22-458f-a911-2b764e08e5d0",
      "name": "Download Image File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -608,
        -304
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        },
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "whatsAppApi"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "04d8e4e2-dd23-40b3-a7c6-e9c70ce78a86",
      "name": "Convert Image to Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -384,
        -304
      ],
      "parameters": {
        "options": {
          "encoding": "base64"
        },
        "operation": "binaryToPropery",
        "destinationKey": "data1",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "430083cc-2990-4e7e-aec2-d007a1a00f03",
      "name": "Extract Text via OCR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -144,
        -304
      ],
      "parameters": {
        "url": "=https://us-documentai.googleapis.com/v1/projects/YOUR_GOOGLE_PROJECT_ID/locations/us/processors/YOUR_PROCESSOR_ID:process",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"rawDocument\": {\n    \"content\": \"{{ $('Convert Image to Base64').item.json.data1 }}\",\n    \"mimeType\": \"{{ $('WhatsApp Trigger').item.json.messages[0].image.mime_type }}\"\n  }\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleApi"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 4.2
    },
    {
      "id": "073c2503-dd47-441d-ae55-5abecd83e325",
      "name": "Analyze Image Ingredients",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        96,
        -304
      ],
      "parameters": {
        "text": "=user message :- {{ $('WhatsApp Trigger').item.json.messages[0].image.caption || \"null\" }}\n\nocr :-  {{ $json.document.text }}",
        "options": {
          "systemMessage": "You are a professional product ingredient analyzer AI. Your task is to analyze OCR text extracted from ANY product images (food, cosmetics, personal care, hair care, etc.) and determine if the ingredients are safe or harmful for the user.\n\n**CRITICAL INSTRUCTIONS:**\n1. You will receive: user_message + ocr_text from a product image\n2. You MUST respond with ONLY valid JSON in this exact format:\n{\n\"is_ingredients\": 0 or 1,\n\"message\": \"your response message here\"\n}\n\n**Response Logic:**\n- Set \"is_ingredients\": 0 if:\n  - OCR text doesn't contain ingredient information\n  - Image is unclear/unreadable\n  - No product information found\n\n- Set \"is_ingredients\": 1 if:\n  - OCR text contains identifiable ingredients list\n  - Product information is readable\n\n**For is_ingredients: 0:**\n- Message should ask for clearer image\n- Keep message brief and WhatsApp-friendly\n- Use emojis appropriately\n\n**For is_ingredients: 1:**\n- First identify the product type (food, cosmetic, hair care, skincare, etc.)\n- Analyze ingredients based on product category\n- Identify harmful ingredients specific to that product type\n- Identify beneficial ingredients\n- Provide clear recommendation: \u2705 SAFE TO USE or \u26a0\ufe0f USE WITH CAUTION or \u274c AVOID\n- Keep message concise but informative\n- Use WhatsApp formatting (* for bold, _ for italic)\n- Include key points in bullet format if needed\n\n**Product-Specific Analysis Criteria:**\n\n**FOOD PRODUCTS:**\n- Red flags: Trans fats, high sodium (>600mg), artificial colors (Red 40, Yellow 5), MSG, high fructose corn syrup, excessive preservatives\n- Caution: High sugar content, saturated fats, artificial sweeteners\n- Positive: Natural ingredients, fiber, vitamins, minerals, organic certification\n\n**COSMETICS & PERSONAL CARE:**\n- Red flags: Parabens, phthalates, formaldehyde, synthetic fragrances, triclosan, coal tar, BHA\n- Caution: Alcohol (drying types), synthetic colors, strong preservatives\n- Positive: Natural oils, plant extracts, gentle preservatives, fragrance-free\n\n**HAIR CARE PRODUCTS:**\n- Red flags: Mineral oil, silicones (dimethicone), parabens, sulfates (SLS/SLES), formaldehyde, synthetic fragrances with phthalates\n- Caution: Alcohol (drying types), methylisothiazolinone (MIT)\n- Positive: Natural oils (argan, coconut, jojoba), plant extracts, sulfate-free formulas\n\n**SKINCARE PRODUCTS:**\n- Red flags: Hydroquinone, formaldehyde releasers, parabens, synthetic fragrances, alcohol denat\n- Caution: Strong acids without proper formulation, essential oils (for sensitive skin)\n- Positive: Hyaluronic acid, ceramides, niacinamide, natural moisturizers\n\n**General Safety Concerns Across All Products:**\n- Endocrine disruptors (parabens, phthalates)\n- Known carcinogens (formaldehyde, coal tar)\n- Strong allergens and irritants\n- Environmental toxins\n\n**Message Style:**\n- Conversational and friendly\n- WhatsApp appropriate (short paragraphs)\n- Use relevant emojis\n- Clear verdict at the end\n- Mention product type in analysis"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "972151e6-0d99-4f79-abdb-4b7297fc346d",
      "name": "Gemini Model (Image Branch)",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        96,
        -96
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "98007634-ddde-4e51-8988-68859c6f894c",
      "name": "JSON Parser (Image)",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        272,
        -96
      ],
      "parameters": {
        "jsonSchemaExample": "{\n     \"is_ingredients\": 0 ,\n     \"message\": \"your response message here\"\n   }"
      },
      "typeVersion": 1.3
    },
    {
      "id": "b3373a4e-901f-4bfa-be3c-5b3ef206e55c",
      "name": "Send Analysis of Image",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        480,
        -304
      ],
      "parameters": {
        "textBody": "={{ $json.output.message }}",
        "operation": "send",
        "phoneNumberId": "YOUR_WHATSAPP_PHONE_NUMBER_ID",
        "additionalFields": {},
        "recipientPhoneNumber": "=+{{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "208414de-bb89-494e-91e1-ac6fd871acab",
      "name": "Analyze Text Query",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -784,
        -16
      ],
      "parameters": {
        "text": "={{ $json.messages[0].text.body }}",
        "options": {
          "systemMessage": "# Professional Product Safety Analyzer AI\n\nYou are a WhatsApp-based product safety analyzer specializing in instant health and safety assessments for ANY product type (food, cosmetics, pharmaceuticals, household items, personal care, supplements).\n\n## CRITICAL: JSON Response Format\nYou MUST ALWAYS respond with ONLY valid JSON in this exact format:\n{\n  \"is_ingredients\": 0,\n  \"message\": \"your response message here\"\n}\n\n## Core Tasks\n\n### Task 1: Product Safety Analysis\nAnalyze product names, brands, ingredient lists (text or from images processed separately) and provide safety recommendations.\n\n### Task 2: Conversational Support\nHandle greetings, help requests, and unclear queries. Guide users on how to properly submit products for analysis.\n\n## Response Logic Rules\n\n### Set \"is_ingredients\": 1 (Perform Analysis) When:\n- Specific product name with brand provided (e.g., \"Coca Cola\", \"Dove soap\", \"Paracetamol 500mg\")\n- Complete or partial ingredient list provided in text\n- Clear product category identifiable (e.g., \"chocolate bar\", \"face cream\", \"dish soap\")\n- Sufficient information exists to provide meaningful safety assessment\n- User asks about specific product effects or safety concerns\n\n### Set \"is_ingredients\": 0 (Request More Info) When:\n- Greeting only: \"hi\", \"hello\", \"hey\", \"namaste\"\n- Vague queries: \"some cream\", \"a medicine\", \"that food\"\n- Help requests: \"how does this work?\", \"what can you do?\"\n- Insufficient information to identify product\n- User asks about general topics unrelated to product safety\n\n## Analysis Framework by Category\n\n### \ud83c\udf5c FOOD PRODUCTS\n**\u274c Red Flags:** Trans fats, high sodium (>600mg/serving), artificial colors (Red 40, Yellow 5, Tartrazine), MSG, high fructose corn syrup, BHA/BHT preservatives, hydrogenated oils\n**\u26a0\ufe0f Caution:** High sugar (>25g/serving), saturated fats (>5g), artificial sweeteners (aspartame, sucralose), excessive preservatives, refined carbs\n**\u2705 Positive:** Natural ingredients, fiber (>3g), vitamins, minerals, organic certification, whole grains, low sodium (<200mg)\n\n### \ud83d\udc84 COSMETICS/PERSONAL CARE\n**\u274c Red Flags:** Parabens (methylparaben, propylparaben), sulfates (SLS/SLES), phthalates, formaldehyde/releasers, mercury compounds, lead acetate, hydroquinone\n**\u26a0\ufe0f Caution:** Denatured alcohol, synthetic fragrances, mineral oil (for sensitive skin), silicones (long-term buildup)\n**\u2705 Positive:** Natural oils (argan, jojoba, coconut), hyaluronic acid, ceramides, niacinamide, dermatologist-tested, fragrance-free, paraben-free\n\n### \ud83d\udc8a PHARMACEUTICALS/SUPPLEMENTS\n**Focus Areas:** Active ingredients, appropriate dosage, known side effects, drug interactions, contraindications\n**\u26a0\ufe0f Check For:** Allergens, age restrictions, pregnancy/breastfeeding warnings, overdose risks, expiration concerns\n**\u2705 Positive:** FDA/regulatory approved, third-party tested, clear dosing guidelines, established safety profile\n\n### \ud83e\uddfd HOUSEHOLD/CLEANING\n**\u274c Red Flags:** Ammonia + bleach combinations, phosphates, VOCs, triclosan, chlorine bleach, artificial musks\n**\u26a0\ufe0f Caution:** Strong synthetic fragrances, aerosol propellants, strong acids/bases\n**\u2705 Positive:** Biodegradable, eco-certified, plant-based, phosphate-free, non-toxic\n\n## Message Style Guidelines\n\n**Be Concise:** Keep responses under 150 words for WhatsApp readability\n**Be Practical:** Give actionable advice and alternatives\n**Be Accurate:** Only analyze what you have information about\n**Be Encouraging:** Maintain friendly, supportive tone\n**Be Clear:** Use simple language, avoid technical jargon unless necessary"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "c73438f1-cb8c-4b75-a139-e0606f91a076",
      "name": "Gemini Model (Text Branch)",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -784,
        192
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fd20d4af-4a92-4564-b486-9d14f6523afd",
      "name": "JSON Parser (Text)",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -608,
        192
      ],
      "parameters": {
        "jsonSchemaExample": "{\n     \"is_ingredients\": 0 ,\n     \"message\": \"your response message here\"\n   }"
      },
      "typeVersion": 1.3
    },
    {
      "id": "8fd57b7f-8ba0-4c3e-bd59-219ac62e6522",
      "name": "Send Analysis of Text",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        -480,
        -16
      ],
      "parameters": {
        "textBody": "={{ $json.output.message }}",
        "operation": "send",
        "phoneNumberId": "YOUR_WHATSAPP_PHONE_NUMBER_ID",
        "additionalFields": {},
        "recipientPhoneNumber": "=+{{ $('WhatsApp Trigger').item.json.contacts[0].wa_id }}"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "06222313-1c77-48bf-8246-3ba4551bbbe3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1808,
        -672
      ],
      "parameters": {
        "width": 2560,
        "height": 1056,
        "content": "# \ud83d\udccb Product Ingredient Safety Analyzer with AI via WhatsApp\n\n## \ud83d\udd04 Flow Structure\n\n**Image Branch:**\nTrigger \u2192 Route \u2192 Get Media URL \u2192 Download \u2192 Base64 \u2192 OCR \u2192 AI \u2192 Send\n\n**Text Branch:**\nTrigger \u2192 Route \u2192 AI \u2192 Send\n\n---\n\n## \ud83d\udd27 Key Points\n\n**Switch Node:**\n- Output 0: `type === \"image\"`\n- Output 1: `type === \"text\"`\n\n**OCR Node:**\n- Google Document AI\n- Input: Base64 + MIME type\n- Output: `document.text`\n\n**AI Analysis:**\n- Model: Google Gemini\n- Output: JSON with `is_ingredients` (0/1) + `message`\n- is_ingredients = 0: Conversational/help\n- is_ingredients = 1: Product analysis\n\n**Send Response:**\n- Recipient: `contacts[0].wa_id`\n- Message: `output.message`\n\n---\n\n## \ud83d\udd12 Credentials Needed\n\n1. WhatsApp Business API\n2. Google Service Account (Document AI)\n3. Google Gemini API\n\n---\n\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "WhatsApp Trigger": {
      "main": [
        [
          {
            "node": "Route By Message Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Text Query": {
      "main": [
        [
          {
            "node": "Send Analysis of Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Parser (Text)": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze Text Query",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Download Image File": {
      "main": [
        [
          {
            "node": "Convert Image to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Image Media URL": {
      "main": [
        [
          {
            "node": "Download Image File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Parser (Image)": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze Image Ingredients",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text via OCR": {
      "main": [
        [
          {
            "node": "Analyze Image Ingredients",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route By Message Type": {
      "main": [
        [
          {
            "node": "Get Image Media URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Analyze Text Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Image to Base64": {
      "main": [
        [
          {
            "node": "Extract Text via OCR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Image Ingredients": {
      "main": [
        [
          {
            "node": "Send Analysis of Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Model (Text Branch)": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Text Query",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Model (Image Branch)": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Image Ingredients",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow creates an intelligent WhatsApp bot that analyzes product ingredients and provides instant safety assessments. Users can send either text queries (product names/brands) or images of product labels, and receive AI-powered analysis covering food, cosmetics, personal…

Source: https://n8n.io/workflows/9098/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Transform your salon/service business with this streamlined WhatsApp automation system featuring Claude integration, zero-setup database management, and intelligent conversation handling. Claude MCP I

WhatsApp Trigger, WhatsApp, Redis +11
AI & RAG

CashMate – Your AI-Powered WhatsApp Finance Agent Turn WhatsApp into a smart finance assistant that auto-registers you, logs transactions in natural language, extracts data from receipts and voice not

Tool Code, Output Parser Structured, Tool Calculator +6
AI & RAG

This workflow creates a complete AI-powered restaurant ordering system through WhatsApp. It receives customer messages, processes multimedia content (text, voice, images, PDFs, location), uses GPT-4 t

OpenAI Chat, Memory Postgres Chat, HTTP Request +6
AI & RAG

Top Branch Workflow A The Market Intelligence: Patrols the Market: Runs hourly to scrape competitor rates for future days. Gathers Intel: If prices spike, it instantly checks event announcements to se

HTTP Request, Data Table, Output Parser Structured +6
AI & RAG

This workflow implements an AI-powered WhatsApp booking assistant for a hair salon. The system allows customers to book, reschedule, or cancel appointments automatically via text or voice messages on

Google Calendar Tool, Google Sheets Tool, Error Trigger +15