{
  "name": "WhatsApp Lead Qualifier Agent",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "whatsapp-inbound",
        "options": {}
      },
      "id": "1a2b3c4d-0001-4000-8000-000000000001",
      "name": "WhatsApp Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": ""
          },
          "conditions": [
            {
              "leftValue": "={{$json.message.type}}",
              "rightValue": "text",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "1a2b3c4d-0002-4000-8000-000000000002",
      "name": "Is Text Message?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "prompt": "={{ \"You are a lead-qualification assistant for a local services business. Given this inbound WhatsApp message: \\\"\" + $json.message.text + \"\\\", classify intent as one of: PRICING_QUESTION, BOOKING_REQUEST, COMPLAINT, GENERAL, SPAM. Reply with only the label.\" }}",
        "options": {
          "temperature": 0.1
        }
      },
      "id": "1a2b3c4d-0003-4000-8000-000000000003",
      "name": "Classify Intent",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [680, 220]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            { "conditions": { "conditions": [ { "leftValue": "={{$json.intent}}", "rightValue": "BOOKING_REQUEST", "operator": { "type": "string", "operation": "equals" } } ] }, "outputKey": "booking" },
            { "conditions": { "conditions": [ { "leftValue": "={{$json.intent}}", "rightValue": "PRICING_QUESTION", "operator": { "type": "string", "operation": "equals" } } ] }, "outputKey": "pricing" }
          ]
        }
      },
      "id": "1a2b3c4d-0004-4000-8000-000000000004",
      "name": "Route by Intent",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [900, 220]
    },
    {
      "parameters": {
        "resource": "spreadsheet",
        "operation": "appendRow",
        "sheetId": "REPLACE_WITH_YOUR_SHEET_ID",
        "range": "Leads!A:E"
      },
      "id": "1a2b3c4d-0005-4000-8000-000000000005",
      "name": "Log Lead to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [1120, 300]
    }
  ],
  "connections": {
    "WhatsApp Webhook": {
      "main": [[{ "node": "Is Text Message?", "type": "main", "index": 0 }]]
    },
    "Is Text Message?": {
      "main": [[{ "node": "Classify Intent", "type": "main", "index": 0 }]]
    },
    "Classify Intent": {
      "main": [[{ "node": "Route by Intent", "type": "main", "index": 0 }]]
    },
    "Route by Intent": {
      "main": [[{ "node": "Log Lead to Sheet", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateSource": "insighttech.blog/library",
    "notes": "Replace the WhatsApp webhook credential, OpenAI credential, and Google Sheet ID before activating. Add a 'Send WhatsApp Reply' node per route (booking/pricing/complaint) to close the loop — left out here to keep the base template provider-agnostic."
  },
  "id": "whatsapp-lead-qualifier-agent",
  "tags": ["ai-agents", "automation-workflows"]
}
