{
  "id": "2awBbs4kwz2DghoQ",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Handle WhatsApp customer inquiries with AI and intent routing",
  "tags": [],
  "nodes": [
    {
      "id": "18ede450-1342-4afc-ae8a-e77cd6e0f5b3",
      "name": "Sticky Note - Main Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        1104
      ],
      "parameters": {
        "color": 4,
        "width": 566,
        "height": 960,
        "content": "## \ud83d\udcac WhatsApp Customer Support Bot\n### \u2728 Universal Template for ANY Business\n\n**What it does:**\n- Receives WhatsApp messages automatically\n- Classifies customer intent (product, contact, support)\n- Routes to pre-built responses (fast) or AI agent (smart)\n- Sends professional replies with product info & prices\n- Remembers conversation context\n\n**Works for:** Fashion | Electronics | Food | Furniture | Beauty | ANY store!\n\n**Requirements:**\n- WhatsApp Business API (Twilio/360Dialog/Meta)\n- Google Gemini API key\n- n8n instance\n\n**Quick Setup:**\n\n1\ufe0f\u20e3 **Connect WhatsApp** - Add API credentials to WhatsApp nodes\n\n2\ufe0f\u20e3 **Customize Products** - Edit \"Classify User Intent\" node with YOUR categories\n\n3\ufe0f\u20e3 **Add Product List** - Update \"Generate Product Response\" with YOUR items & prices\n\n4\ufe0f\u20e3 **Company Info** - Fill YOUR details in \"Build AI System Prompt\" node\n\n5\ufe0f\u20e3 **Test & Launch** - Send test messages, verify, activate!\n\n**Customize (No Coding!):**\n- Products: Edit \"Generate Product Response\"\n- Categories: Update \"Classify User Intent\"\n- Store info: Modify \"Generate Contact Info Response\"\n- AI behavior: Adjust \"Build AI System Prompt\"\n\n**Hybrid Approach = Cost Savings:**\n- 80% queries \u2192 Pre-built responses (instant, free)\n- 20% queries \u2192 AI agent (smart, low cost)\n\n**Result:** Save 80% on AI costs while maintaining quality!\n\n\ud83d\udca1 **Pro Tip:** Start with pre-built FAQs, let AI handle the rest!"
      },
      "typeVersion": 1
    },
    {
      "id": "bcd03e0f-491a-4403-9415-1cbebb03990c",
      "name": "Sticky Note - Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        1072
      ],
      "parameters": {
        "color": 7,
        "width": 324,
        "height": 401,
        "content": "## \ud83d\udcf1 Step 1: Receive WhatsApp Message\n\nWhatsApp Business API triggers the workflow when a customer sends a message.\n\nCaptures:\n- Chat ID\n- User ID\n- User name\n- Message text\n- Timestamp\n\nSupports text messages (media handling can be added)."
      },
      "typeVersion": 1
    },
    {
      "id": "1dd7b535-b77a-43e3-a0c8-8ea2c5ef6f10",
      "name": "Sticky Note - Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        1072
      ],
      "parameters": {
        "color": 7,
        "width": 324,
        "height": 443,
        "content": "## \ud83e\udde0 Step 2: Intent Classification\n\nAnalyzes the message to determine what the customer wants:\n\n**Intents Recognized:**\n- \ud83d\udecd\ufe0f Product inquiry (monitors, CPUs, GPUs, etc.)\n- \ud83d\udcde Contact information\n- \ud83d\udc4b Greeting\n- \ud83d\ude4f Thanks\n- \ud83d\udcb0 Price inquiry\n- \ud83c\udd98 Support request\n- \u2753 General inquiry\n\nUses keyword matching and pattern recognition for fast, accurate classification."
      },
      "typeVersion": 1
    },
    {
      "id": "9d8b4954-a7ed-44d1-b0f5-722f129450b3",
      "name": "Sticky Note - Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        1072
      ],
      "parameters": {
        "color": 7,
        "width": 314,
        "height": 378,
        "content": "## \ud83d\udd00 Step 3: Intelligent Routing\n\nRoutes to the best response handler based on intent:\n\n**Route 1**: Product inquiries \u2192 Pre-built catalog responses (fast, cost-effective)\n\n**Route 2**: Contact/hours \u2192 Static information response\n\n**Route 3**: Complex questions \u2192 AI agent with full context\n\nThis hybrid approach balances speed, cost, and intelligence."
      },
      "typeVersion": 1
    },
    {
      "id": "185a07f9-2406-4ff8-9e26-c7897dc483e7",
      "name": "Sticky Note - Step 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        1056
      ],
      "parameters": {
        "color": 7,
        "width": 334,
        "height": 393,
        "content": "## \ud83e\udd16 Step 4: AI Agent (For Complex Queries)\n\nGoogle Gemini AI handles:\n- Custom product recommendations\n- Comparison questions\n- Technical specifications\n- Build suggestions\n- Multi-step conversations\n\nFeatures:\n- Conversation memory (remembers context)\n- Company knowledge (products, policies)\n- Natural language understanding\n- Markdown-formatted responses"
      },
      "typeVersion": 1
    },
    {
      "id": "9c249b38-41a9-4446-befb-a07aaa1076c4",
      "name": "Sticky Note - Step 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        1056
      ],
      "parameters": {
        "color": 7,
        "width": 324,
        "height": 354,
        "content": "## \ud83d\udce4 Step 5: Send WhatsApp Response\n\nFormats and sends the response back to the customer via WhatsApp.\n\nSupports:\n- Markdown formatting (bold, italic, lists)\n- Emojis for engagement\n- Links to products\n- Multi-line messages\n\nResponses are friendly, professional, and on-brand."
      },
      "typeVersion": 1
    },
    {
      "id": "7fb04cfb-53c6-4424-96a4-0a28d0e2c551",
      "name": "WhatsApp Trigger - Receive Messages",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        176,
        1664
      ],
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "06578f8a-5296-4b4e-a8d8-5757a5a346ca",
      "name": "Parse WhatsApp Message Data",
      "type": "n8n-nodes-base.code",
      "position": [
        384,
        1664
      ],
      "parameters": {
        "jsCode": "// Extract and structure message data\nconst message = $input.item.json.message;\nconst chatId = message.chat.id;\nconst userId = message.from.id;\nconst userName = message.from.first_name || 'Customer';\nconst userText = message.text || '';\nconst messageId = message.message_id;\n\n// Store session data for downstream nodes\nconst sessionData = {\n  chatId: chatId,\n  userId: userId,\n  userName: userName,\n  messageText: userText.toLowerCase(), // Lowercase for intent matching\n  originalText: userText, // Keep original for AI\n  messageId: messageId,\n  timestamp: new Date().toISOString()\n};\n\nreturn [sessionData];"
      },
      "typeVersion": 2
    },
    {
      "id": "d5e00bfe-a374-46f6-a058-e5c6d9bab965",
      "name": "Classify User Intent",
      "type": "n8n-nodes-base.code",
      "position": [
        608,
        1664
      ],
      "parameters": {
        "jsCode": "// Intent Classification with Pattern Matching\nconst text = $input.item.json.messageText;\nconst originalText = $input.item.json.originalText;\n\nlet intent = 'general_inquiry';\nlet entities = {\n  category: null,\n  brand: null,\n  priceRange: null\n};\n\n// Priority 1: Contact/Location queries (check first)\nif (/where.*store|store.*locat|address|location|contact|phone|email|visit.*store|shop.*address/i.test(text)) {\n  intent = 'contact_info';\n  return [{...($input.item.json), intent, entities}];\n}\n\n// Priority 2: Greetings (only exact greetings)\nif (/^(hi|hello|hey|good morning|good evening|good afternoon|start|greetings)$/i.test(text)) {\n  intent = 'greeting';\n  return [{...($input.item.json), intent, entities}];\n}\n\n// Priority 3: Thanks\nif (/thank|thanks|appreciate|grateful/i.test(text)) {\n  intent = 'thanks';\n  return [{...($input.item.json), intent, entities}];\n}\n\n// Priority 4: Product categories\n// CUSTOMIZE THESE PATTERNS FOR YOUR BUSINESS TYPE\nconst categories = [\n  // Electronics/Tech Store Examples:\n  { pattern: /(monitor|display|screen|tv)/i, category: 'monitors' },\n  { pattern: /(laptop|notebook|computer)/i, category: 'laptops' },\n  { pattern: /(phone|mobile|smartphone)/i, category: 'phones' },\n  { pattern: /(headphone|earphone|earbuds|airpods)/i, category: 'audio' },\n  \n  // Fashion Store Examples:\n  { pattern: /(shirt|tshirt|top|blouse)/i, category: 'clothing' },\n  { pattern: /(jeans|pants|trousers)/i, category: 'bottomwear' },\n  { pattern: /(dress|gown|saree)/i, category: 'ethnic' },\n  { pattern: /(shoe|footwear|sneaker|sandal)/i, category: 'footwear' },\n  { pattern: /(bag|purse|wallet)/i, category: 'accessories' },\n  \n  // Home/Furniture Examples:\n  { pattern: /(sofa|couch|chair|seating)/i, category: 'furniture' },\n  { pattern: /(bed|mattress|bedroom)/i, category: 'bedroom' },\n  { pattern: /(table|desk|dining)/i, category: 'tables' },\n  { pattern: /(decor|decoration|wall art)/i, category: 'decor' },\n  \n  // Beauty/Cosmetics Examples:\n  { pattern: /(skincare|cream|serum|moisturizer)/i, category: 'skincare' },\n  { pattern: /(makeup|lipstick|foundation)/i, category: 'makeup' },\n  { pattern: /(perfume|fragrance|cologne)/i, category: 'fragrance' },\n  \n  // Food/Grocery Examples:\n  { pattern: /(grocery|groceries|food)/i, category: 'groceries' },\n  { pattern: /(vegetable|fruit|produce)/i, category: 'fresh' },\n  { pattern: /(snack|chips|biscuit)/i, category: 'snacks' },\n  \n  // Add YOUR business-specific categories here\n  // { pattern: /YOUR_KEYWORD/i, category: 'YOUR_CATEGORY' },\n];\n\nfor (const cat of categories) {\n  if (cat.pattern.test(text)) {\n    intent = 'product_inquiry';\n    entities.category = cat.category;\n    break;\n  }\n}\n\n// Priority 5: Order tracking\nif (/track.*order|order.*status|where.*order|order.*id/i.test(text)) {\n  intent = 'order_tracking';\n}\n\n// Priority 6: Price queries (if not already classified)\nif (intent !== 'contact_info' && /price|cost|how much|budget|expensive|cheap|rate/i.test(text)) {\n  intent = 'price_inquiry';\n}\n\n// Priority 7: Shipping/Delivery\nif (/shipping|delivery|courier|dispatch|arrive|reach/i.test(text)) {\n  intent = 'shipping_inquiry';\n}\n\n// Priority 8: Return/Refund\nif (/return|refund|exchange|replace|cancel/i.test(text)) {\n  intent = 'return_request';\n}\n\n// Priority 9: Support queries\nif (/help|support|problem|issue|complaint|not working/i.test(text)) {\n  intent = 'support_request';\n}\n\nreturn [{...($input.item.json), intent, entities}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7445df59-15a2-4734-a871-2d1559546523",
      "name": "Route by Intent",
      "type": "n8n-nodes-base.switch",
      "position": [
        848,
        1648
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "product_inquiry",
              "conditions": {
                "options": {
                  "caseSensitive": false
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "product_inquiry"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "contact_info",
              "conditions": {
                "options": {
                  "caseSensitive": false
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "contact_info"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "81f8deee-e06b-496d-9c3b-b7edde36a79a",
      "name": "Generate Product Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        1488
      ],
      "parameters": {
        "jsCode": "// Generate Product Catalog Response\nconst category = $input.item.json.entities.category;\nconst userName = $input.item.json.userName;\n\nlet response = '';\n\n// YOUR_AWS_SECRET_KEY_HERE\n// CUSTOMIZE WITH YOUR ACTUAL PRODUCTS\n// YOUR_AWS_SECRET_KEY_HERE\n// The examples below show different business types\n// Replace with YOUR products, prices, and categories\n\n// EXAMPLE 1: Electronics Store\nif (category === 'monitors') {\n  response = `Great choice, ${userName}! Check out our *MONITORS*:\\n\\n`;\n  response += `1. *24\" Full HD Monitor*\\n   \ud83d\udcb0 \u20b98,999\\n   \u2705 In Stock\\n   \ud83d\udd17 https://yourstore.com/monitors\\n\\n`;\n  response += `2. *27\" 4K Professional Display*\\n   \ud83d\udcb0 \u20b922,999\\n   \ud83c\udf89 20% OFF!\\n   \ud83d\udd17 https://yourstore.com/monitors\\n\\n`;\n}\n\n// EXAMPLE 2: Fashion Store\nelse if (category === 'clothing') {\n  response = `Hi ${userName}! Here are our trending *CLOTHING* items:\\n\\n`;\n  response += `\ud83d\udc55 *Men's Cotton T-Shirts*\\n   \ud83d\udcb0 Starting at \u20b9399\\n   \ud83d\udd17 https://yourstore.com/mens-tshirts\\n\\n`;\n  response += `\ud83d\udc57 *Women's Summer Dresses*\\n   \ud83d\udcb0 \u20b91,299 - \u20b92,999\\n   \ud83c\udf89 Buy 2 Get 10% OFF\\n   \ud83d\udd17 https://yourstore.com/dresses\\n\\n`;\n}\n\n// EXAMPLE 3: Home Decor Store\nelse if (category === 'furniture') {\n  response = `Wonderful choice, ${userName}! Our *FURNITURE* collection:\\n\\n`;\n  response += `\ud83d\udecb\ufe0f *3-Seater Sofa Set*\\n   \ud83d\udcb0 \u20b924,999\\n   \ud83d\ude9a Free Delivery\\n   \ud83d\udd17 https://yourstore.com/sofas\\n\\n`;\n  response += `\ud83e\ude91 *Dining Table (6-Seater)*\\n   \ud83d\udcb0 \u20b915,999\\n   \u2705 Solid Wood\\n   \ud83d\udd17 https://yourstore.com/dining\\n\\n`;\n}\n\n// EXAMPLE 4: Beauty & Cosmetics\nelse if (category === 'skincare') {\n  response = `Great selection, ${userName}! Our *SKINCARE* products:\\n\\n`;\n  response += `\u2728 *Vitamin C Face Serum*\\n   \ud83d\udcb0 \u20b9599\\n   \ud83c\udf3f 100% Natural\\n   \ud83d\udd17 https://yourstore.com/skincare\\n\\n`;\n  response += `\ud83d\udc86 *Anti-Aging Night Cream*\\n   \ud83d\udcb0 \u20b9899\\n   \u2b50 Bestseller!\\n   \ud83d\udd17 https://yourstore.com/skincare\\n\\n`;\n}\n\n// EXAMPLE 5: Food & Grocery\nelse if (category === 'groceries') {\n  response = `Perfect, ${userName}! Check our *GROCERIES*:\\n\\n`;\n  response += `\ud83c\udf3e *Organic Rice (5kg)*\\n   \ud83d\udcb0 \u20b9450\\n   \ud83c\udf31 Chemical-free\\n   \ud83d\udd17 https://yourstore.com/groceries\\n\\n`;\n  response += `\ud83e\uded8 *Mixed Nuts Pack (500g)*\\n   \ud83d\udcb0 \u20b9299\\n   \ud83d\udcaa High Protein\\n   \ud83d\udd17 https://yourstore.com/dry-fruits\\n\\n`;\n}\n\n// Default: Show all categories\nelse {\n  response = `Hi ${userName}! Browse our categories:\\n\\n`;\n  response += `\ud83d\udcf1 [Category 1]\\n`;\n  response += `\ud83d\udc55 [Category 2]\\n`;\n  response += `\ud83c\udfe0 [Category 3]\\n`;\n  response += `\ud83d\udc84 [Category 4]\\n\\n`;\n  response += `\ud83c\udf10 Visit: https://yourstore.com/`;\n}\n\n// Add universal call-to-action\nresponse += `\\n\\n\u2728 Special Offer: [Your Current Promotion]`;\nresponse += `\\n\ud83d\udcde Questions? Call: +91 XXXXXXXXXX`;\nresponse += `\\n\ud83d\udcac Or just reply here!`;\n\nreturn [{\n  chatId: $input.item.json.chatId,\n  response: response,\n  parseMode: 'Markdown'\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "8edafb90-588a-40ca-93b5-366fa5cbcf71",
      "name": "Generate Contact Info Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        1664
      ],
      "parameters": {
        "jsCode": "// Generate Contact Information Response\nconst userName = $input.item.json.userName;\n\n// CUSTOMIZE THIS WITH YOUR COMPANY DETAILS\nconst response = `\ud83d\udccd *Your Company Name - Contact Details*\\n\\n\ud83c\udfe2 *Address:*\\nYour Street Address\\nCity, State - PIN Code\\n\\n\ud83d\udcde *Phone:*\\n+91 XXXXXXXXXX (Main)\\n+91 XXXXXXXXXX (Sales)\\n+91 XXXXXXXXXX (Support)\\n\\n\ud83d\udce7 *Email:*\\user@example.com\\user@example.com\\n\\n\ud83c\udf10 *Website:*\\nhttps://yourcompany.com/\\n\\n\u23f0 *Store Hours:*\\nMon-Sat: 10 AM - 8 PM\\nSunday: 11 AM - 6 PM\\n\\nFeel free to visit us, ${userName}! \ud83d\ude0a`;\n\nreturn [{\n  chatId: $input.item.json.chatId,\n  response: response,\n  parseMode: 'Markdown'\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "6454f0d9-1b24-4dec-820d-073ce268d1a2",
      "name": "Build AI System Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        1424,
        1664
      ],
      "parameters": {
        "jsCode": "// Build comprehensive AI system prompt with company knowledge\nconst userMessage = $input.first().json.originalText;\nconst userName = $input.first().json.userName;\nconst intent = $input.first().json.intent;\n\n// YOUR_AWS_SECRET_KEY_HERE\n// CUSTOMIZE THIS SECTION FOR YOUR BUSINESS\n// YOUR_AWS_SECRET_KEY_HERE\n\nconst systemPrompt = `You are a helpful AI customer service assistant for [YOUR COMPANY NAME].\n\n\ud83d\udccb COMPANY INFORMATION:\n- Business Name: [Your Business Name]\n- Industry: [e.g., Fashion, Electronics, Home Decor, Food & Beverage, etc.]\n- Store Address: [Your Physical Address]\n- Phone: [Your Phone Number(s)]\n- Email: [Your Email Address]\n- Website: [Your Website URL]\n\n\ud83d\udecd\ufe0f WHAT WE SELL:\n[Describe your products/services in 2-3 sentences]\nExamples:\n- \"We sell premium handcrafted leather bags, wallets, and accessories\"\n- \"We offer organic skincare products made from natural ingredients\"\n- \"We provide home furniture including sofas, beds, dining sets, and decor\"\n\n\ud83d\udce6 PRODUCT CATEGORIES:\n[List your main categories, e.g.:\n- Category 1: [Name]\n- Category 2: [Name]\n- Category 3: [Name]]\n\n\ud83d\udcb0 PRICING & PAYMENT:\n- Price Range: [e.g., \u20b9500 - \u20b950,000]\n- Accepted Payments: [e.g., Cash on Delivery, Credit/Debit Cards, UPI, Net Banking]\n- Current Offers: [Any ongoing sales/discounts]\n\n\ud83d\ude9a DELIVERY & SHIPPING:\n- Delivery Areas: [e.g., Pan India, Local City Only, International]\n- Delivery Time: [e.g., 3-5 business days]\n- Shipping Cost: [e.g., Free above \u20b9999, \u20b950 flat rate]\n\n\ud83d\udd04 POLICIES:\n- Return Policy: [e.g., 7-day return, 30-day exchange]\n- Warranty: [If applicable]\n- Refund Policy: [Your refund terms]\n\n\ud83c\udfaf YOUR ROLE:\nYou help customers with:\n1. Product recommendations based on their needs\n2. Answering questions about prices, availability, and features\n3. Explaining policies (returns, shipping, payments)\n4. Providing order tracking information\n5. Resolving common issues and concerns\n6. Guiding them to make purchases\n\n\ud83d\udcac RESPONSE STYLE:\n1. Be warm, friendly, and professional\n2. Always use the customer's name: ${userName}\n3. Provide specific, helpful answers\n4. Mention prices in your local currency\n5. Highlight ongoing offers when relevant\n6. Use emojis appropriately for engagement (but don't overdo it)\n7. Keep responses concise and easy to read on mobile\n8. If you don't know something specific, direct them to call or email\n9. Always end complex responses with a clear call-to-action\n\n\ud83d\udccd IMPORTANT NOTES:\n- Current customer query type: ${intent}\n- If customer asks about specific products not in your knowledge, provide general category info and suggest they visit the website or call\n- For order-specific questions (tracking, returns), direct them to email or phone with order number\n- Be honest about delivery times and stock availability\n`;\n\nreturn [{\n  ...($input.first().json),\n  systemPrompt: systemPrompt,\n  userPrompt: userMessage\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "b13be1ed-6b8a-44a8-8dda-30ea5634eb00",
      "name": "AI Agent - Handle Complex Queries",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1632,
        1664
      ],
      "parameters": {
        "text": "={{ $json.userPrompt }}",
        "options": {
          "systemMessage": "={{ $json.systemPrompt }}"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "ea4fbfc4-99fd-4fa0-9c86-a4093d1c5dbd",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1632,
        1520
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "38a18571-b06e-450b-85fe-34b33e312569",
      "name": "Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1728,
        1808
      ],
      "parameters": {
        "sessionKey": "={{ $json.userId }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.2
    },
    {
      "id": "50a654e2-7c70-4b0c-99be-ca2ba890961e",
      "name": "Google Docs - Product Catalog (Optional)",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        1776,
        1504
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/YOUR_DOCUMENT_ID/edit"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "78c748ca-531b-4aaa-8d75-471bfe96d8d7",
      "name": "Format AI Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1952,
        1664
      ],
      "parameters": {
        "jsCode": "// Format AI response for WhatsApp\nconst aiResponse = $input.first().json.output;\nconst chatId = $input.first().json.chatId;\n\nreturn [{\n  chatId: chatId,\n  response: aiResponse,\n  parseMode: 'Markdown'\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "30eca11b-6aae-4db7-ad0a-1c58d6311d5a",
      "name": "Generate Default Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1136,
        1872
      ],
      "parameters": {
        "jsCode": "// Generate default/fallback response\nconst userName = $input.item.json.userName;\n\n// YOUR_AWS_SECRET_KEY_HERE\n// CUSTOMIZE THIS MENU FOR YOUR BUSINESS\n// YOUR_AWS_SECRET_KEY_HERE\n\nconst response = `Hi ${userName}! \ud83d\udc4b Welcome to [Your Store Name]!\\n\\nI can help you with:\\n\\n\ud83d\udecd\ufe0f *Browse Products:*\\n\u2022 [Your Category 1]\\n\u2022 [Your Category 2]\\n\u2022 [Your Category 3]\\n\u2022 [Your Category 4]\\n\u2022 And more...\\n\\n\ud83d\udce6 *Order Information:*\\n\u2022 Track your order\\n\u2022 Check delivery status\\n\u2022 Return or exchange items\\n\\n\ud83d\udcb0 *Pricing & Offers:*\\n\u2022 Current promotions\\n\u2022 Bulk discounts\\n\u2022 Payment options\\n\\n\ud83d\udccd *Store Information:*\\n\u2022 Location & hours\\n\u2022 Contact details\\n\u2022 Shipping areas\\n\\n\ud83d\udcac *Try asking me:*\\n\u2022 \"Show me [product type]\"\\n\u2022 \"What's available under \u20b9[amount]?\"\\n\u2022 \"Do you deliver to [location]?\"\\n\u2022 \"What's your return policy?\"\\n\u2022 \"Where is your store?\"\\n\\n\ud83d\udcde *Need Personal Assistance?*\\nCall: +91 XXXXXXXXXX\\nEmail: user@example.com\\n\\nWhat would you like to know? \ud83d\ude0a`;\n\nreturn [{\n  chatId: $input.item.json.chatId,\n  response: response,\n  parseMode: 'Markdown'\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "ec2b6512-76a0-4f25-a0eb-0f14615b070f",
      "name": "Send WhatsApp Response",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2192,
        1664
      ],
      "parameters": {},
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4cfcb3d6-cf04-4278-ba04-65106b76e543",
  "connections": {
    "Route by Intent": {
      "main": [
        [
          {
            "node": "Generate Product Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Contact Info Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Default Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Response": {
      "main": [
        [
          {
            "node": "Send WhatsApp Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent - Handle Complex Queries",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Classify User Intent": {
      "main": [
        [
          {
            "node": "Route by Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build AI System Prompt": {
      "main": [
        [
          {
            "node": "AI Agent - Handle Complex Queries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Handle Complex Queries",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate Default Response": {
      "main": [
        [
          {
            "node": "Build AI System Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Product Response": {
      "main": [
        [
          {
            "node": "Build AI System Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse WhatsApp Message Data": {
      "main": [
        [
          {
            "node": "Classify User Intent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Contact Info Response": {
      "main": [
        [
          {
            "node": "Build AI System Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Handle Complex Queries": {
      "main": [
        [
          {
            "node": "Format AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Trigger - Receive Messages": {
      "main": [
        [
          {
            "node": "Parse WhatsApp Message Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Docs - Product Catalog (Optional)": {
      "ai_tool": [
        [
          {
            "node": "AI Agent - Handle Complex Queries",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}