8
n8n 中文网amn8n.com

使用AI和意图路由处理WhatsApp客户咨询

高级

这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 20 个节点。主要使用 Code, Switch, WhatsApp, GoogleDocsTool, Agent 等节点。 使用AI和意图路由处理WhatsApp客户咨询

前置要求
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "2awBbs4kwz2DghoQ",
  "meta": {
    "instanceId": "e46a00fdf674c6a717d1781ab876c72daac39cdddf1349ff176b416ee5840ee5",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 AI 和意图路由处理 WhatsApp 客户咨询",
  "tags": [],
  "nodes": [
    {
      "id": "18ede450-1342-4afc-ae8a-e77cd6e0f5b3",
      "name": "便签 - 主要说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        1104
      ],
      "parameters": {
        "color": 4,
        "width": 566,
        "height": 960,
        "content": "## 💬 WhatsApp 客户支持机器人"
      },
      "typeVersion": 1
    },
    {
      "id": "bcd03e0f-491a-4403-9415-1cbebb03990c",
      "name": "便签 - 步骤 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        1072
      ],
      "parameters": {
        "color": 7,
        "width": 324,
        "height": 401,
        "content": "## 📱 步骤 1:接收 WhatsApp 消息"
      },
      "typeVersion": 1
    },
    {
      "id": "1dd7b535-b77a-43e3-a0c8-8ea2c5ef6f10",
      "name": "便签 - 步骤 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        1072
      ],
      "parameters": {
        "color": 7,
        "width": 324,
        "height": 443,
        "content": "## 🧠 步骤 2:意图分类"
      },
      "typeVersion": 1
    },
    {
      "id": "9d8b4954-a7ed-44d1-b0f5-722f129450b3",
      "name": "便签 - 步骤 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        1072
      ],
      "parameters": {
        "color": 7,
        "width": 314,
        "height": 378,
        "content": "## 🔀 步骤 3:智能路由"
      },
      "typeVersion": 1
    },
    {
      "id": "185a07f9-2406-4ff8-9e26-c7897dc483e7",
      "name": "便签 - 步骤 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        1056
      ],
      "parameters": {
        "color": 7,
        "width": 334,
        "height": 393,
        "content": "## 🤖 步骤 4:AI 代理(用于复杂查询)"
      },
      "typeVersion": 1
    },
    {
      "id": "9c249b38-41a9-4446-befb-a07aaa1076c4",
      "name": "便签 - 步骤 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        1056
      ],
      "parameters": {
        "color": 7,
        "width": 324,
        "height": 354,
        "content": "## 📤 步骤 5:发送 WhatsApp 响应"
      },
      "typeVersion": 1
    },
    {
      "id": "7fb04cfb-53c6-4424-96a4-0a28d0e2c551",
      "name": "WhatsApp 触发器 - 接收消息",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        176,
        1664
      ],
      "webhookId": "whatsapp-webhook-id",
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "id": "UHBhPoQG2bNZKkzc",
          "name": "WhatsApp OAuth account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "06578f8a-5296-4b4e-a8d8-5757a5a346ca",
      "name": "解析 WhatsApp 消息数据",
      "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": "分类用户意图",
      "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": "按意图路由",
      "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": "生成产品响应",
      "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// ========================================\n// CUSTOMIZE WITH YOUR ACTUAL PRODUCTS\n// ========================================\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   💰 ₹8,999\\n   ✅ In Stock\\n   🔗 https://yourstore.com/monitors\\n\\n`;\n  response += `2. *27\" 4K Professional Display*\\n   💰 ₹22,999\\n   🎉 20% OFF!\\n   🔗 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 += `👕 *Men's Cotton T-Shirts*\\n   💰 Starting at ₹399\\n   🔗 https://yourstore.com/mens-tshirts\\n\\n`;\n  response += `👗 *Women's Summer Dresses*\\n   💰 ₹1,299 - ₹2,999\\n   🎉 Buy 2 Get 10% OFF\\n   🔗 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 += `🛋️ *3-Seater Sofa Set*\\n   💰 ₹24,999\\n   🚚 Free Delivery\\n   🔗 https://yourstore.com/sofas\\n\\n`;\n  response += `🪑 *Dining Table (6-Seater)*\\n   💰 ₹15,999\\n   ✅ Solid Wood\\n   🔗 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 += `✨ *Vitamin C Face Serum*\\n   💰 ₹599\\n   🌿 100% Natural\\n   🔗 https://yourstore.com/skincare\\n\\n`;\n  response += `💆 *Anti-Aging Night Cream*\\n   💰 ₹899\\n   ⭐ Bestseller!\\n   🔗 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 += `🌾 *Organic Rice (5kg)*\\n   💰 ₹450\\n   🌱 Chemical-free\\n   🔗 https://yourstore.com/groceries\\n\\n`;\n  response += `🫘 *Mixed Nuts Pack (500g)*\\n   💰 ₹299\\n   💪 High Protein\\n   🔗 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 += `📱 [Category 1]\\n`;\n  response += `👕 [Category 2]\\n`;\n  response += `🏠 [Category 3]\\n`;\n  response += `💄 [Category 4]\\n\\n`;\n  response += `🌐 Visit: https://yourstore.com/`;\n}\n\n// Add universal call-to-action\nresponse += `\\n\\n✨ Special Offer: [Your Current Promotion]`;\nresponse += `\\n📞 Questions? Call: +91 XXXXXXXXXX`;\nresponse += `\\n💬 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": "生成联系信息响应",
      "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 = `📍 *Your Company Name - Contact Details*\\n\\n🏢 *Address:*\\nYour Street Address\\nCity, State - PIN Code\\n\\n📞 *Phone:*\\n+91 XXXXXXXXXX (Main)\\n+91 XXXXXXXXXX (Sales)\\n+91 XXXXXXXXXX (Support)\\n\\n📧 *Email:*\\ninfo@yourcompany.com\\nsupport@yourcompany.com\\n\\n🌐 *Website:*\\nhttps://yourcompany.com/\\n\\n⏰ *Store Hours:*\\nMon-Sat: 10 AM - 8 PM\\nSunday: 11 AM - 6 PM\\n\\nFeel free to visit us, ${userName}! 😊`;\n\nreturn [{\n  chatId: $input.item.json.chatId,\n  response: response,\n  parseMode: 'Markdown'\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "6454f0d9-1b24-4dec-820d-073ce268d1a2",
      "name": "构建 AI 系统提示",
      "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// ========================================\n// CUSTOMIZE THIS SECTION FOR YOUR BUSINESS\n// ========================================\n\nconst systemPrompt = `You are a helpful AI customer service assistant for [YOUR COMPANY NAME].\n\n📋 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🛍️ 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📦 PRODUCT CATEGORIES:\n[List your main categories, e.g.:\n- Category 1: [Name]\n- Category 2: [Name]\n- Category 3: [Name]]\n\n💰 PRICING & PAYMENT:\n- Price Range: [e.g., ₹500 - ₹50,000]\n- Accepted Payments: [e.g., Cash on Delivery, Credit/Debit Cards, UPI, Net Banking]\n- Current Offers: [Any ongoing sales/discounts]\n\n🚚 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 ₹999, ₹50 flat rate]\n\n🔄 POLICIES:\n- Return Policy: [e.g., 7-day return, 30-day exchange]\n- Warranty: [If applicable]\n- Refund Policy: [Your refund terms]\n\n🎯 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💬 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📍 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 代理 - 处理复杂查询",
      "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 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1632,
        1520
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "KtAMOYdbcKc3zjad",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "38a18571-b06e-450b-85fe-34b33e312569",
      "name": "对话记忆",
      "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 文档 - 产品目录(可选)",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        1776,
        1504
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/YOUR_DOCUMENT_ID/edit"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "HHtSmyiZeuvQ7w3f",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "78c748ca-531b-4aaa-8d75-471bfe96d8d7",
      "name": "格式化 AI 响应",
      "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": "生成默认响应",
      "type": "n8n-nodes-base.code",
      "position": [
        1136,
        1872
      ],
      "parameters": {
        "jsCode": "// Generate default/fallback response\nconst userName = $input.item.json.userName;\n\n// ========================================\n// CUSTOMIZE THIS MENU FOR YOUR BUSINESS\n// ========================================\n\nconst response = `Hi ${userName}! 👋 Welcome to [Your Store Name]!\\n\\nI can help you with:\\n\\n🛍️ *Browse Products:*\\n• [Your Category 1]\\n• [Your Category 2]\\n• [Your Category 3]\\n• [Your Category 4]\\n• And more...\\n\\n📦 *Order Information:*\\n• Track your order\\n• Check delivery status\\n• Return or exchange items\\n\\n💰 *Pricing & Offers:*\\n• Current promotions\\n• Bulk discounts\\n• Payment options\\n\\n📍 *Store Information:*\\n• Location & hours\\n• Contact details\\n• Shipping areas\\n\\n💬 *Try asking me:*\\n• \"Show me [product type]\"\\n• \"What's available under ₹[amount]?\"\\n• \"Do you deliver to [location]?\"\\n• \"What's your return policy?\"\\n• \"Where is your store?\"\\n\\n📞 *Need Personal Assistance?*\\nCall: +91 XXXXXXXXXX\\nEmail: info@yourstore.com\\n\\nWhat would you like to know? 😊`;\n\nreturn [{\n  chatId: $input.item.json.chatId,\n  response: response,\n  parseMode: 'Markdown'\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "ec2b6512-76a0-4f25-a0eb-0f14615b070f",
      "name": "发送 WhatsApp 响应",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2192,
        1664
      ],
      "webhookId": "9fab27ba-160c-49be-8e15-a2dbe798a318",
      "parameters": {},
      "credentials": {
        "whatsAppApi": {
          "id": "k1o5E0dQ9sRIo9pB",
          "name": "WhatsApp account"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "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
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 客服机器人, AI 聊天机器人

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量20
分类2
节点类型9
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流