{
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "name": "WhatsApp AI Insurance Lead Qualifier: converse, score, sync to CRM & hand off to a human",
  "tags": [],
  "nodes": [
    {
      "id": "a1b2c3d4-0001-4a10-9a01-aa1111110001",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        40
      ],
      "parameters": {
        "width": 540,
        "height": 760,
        "content": "## \ud83d\udcac WhatsApp AI Insurance Lead Qualifier\n\n**Who it's for:** Insurance brokers, agencies and lead-gen teams that get leads on WhatsApp and lose them to slow, manual, inconsistent follow-up.\n\n**What it does:** An AI agent chats with each lead on WhatsApp in natural language, remembers the conversation across messages, qualifies them (insurance type, budget, timeline, contact preference), scores intent, writes an AI summary into your CRM, and pings your sales team only when a lead is hot or asks for a human.\n\n### How it works\n1. **WhatsApp Trigger** fires on every inbound message.\n2. **AI Insurance Assistant** replies naturally, keeps a brand persona and qualifies the lead (with memory per phone number).\n3. **Reply on WhatsApp** sends the answer back to the lead.\n4. **Qualify & Score Lead** turns the chat into `{ qualified, lead_score, intent, wants_human, email, summary }`.\n5. **Upsert Lead in CRM** saves qualified leads to HubSpot; **Alert Sales Team** Slacks a human when the lead is hot or asks for one.\n\n### Setup (~10 min)\n- Connect **WhatsApp Business Cloud**, **OpenAI**, **HubSpot** and **Slack** credentials.\n- Set your business phone number ID on the two WhatsApp nodes.\n- Edit the persona + qualifying questions in **AI Insurance Assistant**.\n- Pick your Slack channel, then activate."
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-0002-4a10-9a01-aa1111110002",
      "name": "Warning",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        820
      ],
      "parameters": {
        "color": 3,
        "width": 540,
        "height": 220,
        "content": "## \u26a0\ufe0f Compliance & setup notes\n- **Consent / privacy:** the assistant asks for consent and honours **STOP** opt-out (POPIA / GDPR). Add your own data-retention + purge policy before going live.\n- **PII:** don't log raw PII in plain text; this template only stores what your CRM needs.\n- **Cost:** each inbound message = ~1\u20132 OpenAI calls \u2014 use a cheap model (e.g. `gpt-4o-mini`).\n- This template ships **without credentials** \u2014 connect your own WhatsApp, OpenAI, HubSpot & Slack accounts."
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-0003-4a10-9a01-aa1111110003",
      "name": "Section: Converse",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -20
      ],
      "parameters": {
        "color": 4,
        "width": 880,
        "height": 600,
        "content": "## 1 \u00b7 Receive & converse on WhatsApp\nThe AI agent answers the lead naturally, holds a professional insurance persona, and remembers the conversation **per phone number** so it works across multiple messages and days."
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-0004-4a10-9a01-aa1111110004",
      "name": "Section: Qualify",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        220,
        -20
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 600,
        "content": "## 2 \u00b7 Qualify, score & summarize\nTurn the conversation into structured data: is the lead **qualified**, an intent **score 0\u2013100**, whether they **want a human**, their email, and a one-line **AI summary** for your CRM and sales team."
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-0005-4a10-9a01-aa1111110005",
      "name": "Section: Route",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -20
      ],
      "parameters": {
        "color": 6,
        "width": 540,
        "height": 600,
        "content": "## 3 \u00b7 Sync to CRM & route to a human\nSave qualified leads to HubSpot with their score and AI summary, and send a Slack alert to the sales team only when the lead is **hot** or explicitly **asks for a human** (live-agent handover)."
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-0010-4a10-9a01-aa1111110010",
      "name": "Lead Messages on WhatsApp",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        -620,
        240
      ],
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-0011-4a10-9a01-aa1111110011",
      "name": "AI Insurance Assistant",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -360,
        200
      ],
      "parameters": {
        "text": "={{ $json.messages[0].text.body }}",
        "options": {
          "systemMessage": "You are \"Aria\", a warm, professional virtual assistant for an insurance brokerage. You chat with leads on WhatsApp.\n\nGoals, in order:\n1. Briefly get consent to continue (\"Happy to help! Is it ok if I ask a few quick questions to find you the best cover? Reply STOP any time to opt out.\"). If the user says STOP, politely confirm opt-out and stop asking questions.\n2. Qualify naturally \u2014 do NOT interrogate. Across the conversation, gather: type of insurance (auto / home / life / health / business), what they want to cover, rough budget, timeline to buy, and the best way + time to reach them. Also ask for their name and email so an advisor can follow up.\n3. Detect the language the user writes in and reply in that same language.\n4. Keep replies short (WhatsApp style), one or two questions at a time.\n5. If the user is frustrated, confused, or asks for a person, reassure them that a human advisor will reach out shortly.\n\nNever give binding quotes or legal/financial advice \u2014 say an advisor will confirm details. Stay on topic (insurance)."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "a1b2c3d4-0012-4a10-9a01-aa1111110012",
      "name": "Chat Model (Conversation)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -440,
        440
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "a1b2c3d4-0013-4a10-9a01-aa1111110013",
      "name": "Remember Conversation",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -240,
        440
      ],
      "parameters": {
        "sessionKey": "={{ $json.messages[0].from }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "a1b2c3d4-0014-4a10-9a01-aa1111110014",
      "name": "Reply on WhatsApp",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        -60,
        200
      ],
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "YOUR_WHATSAPP_PHONE_NUMBER_ID",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('Lead Messages on WhatsApp').item.json.messages[0].from }}"
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-0015-4a10-9a01-aa1111110015",
      "name": "Qualify & Score Lead",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        300,
        200
      ],
      "parameters": {
        "text": "=Analyse this WhatsApp insurance conversation and extract structured data.\n\nLatest lead message:\n{{ $('Lead Messages on WhatsApp').item.json.messages[0].text.body }}\n\nAssistant's latest reply:\n{{ $json.output }}\n\nReturn:\n- qualified: true only if the lead has shared enough to be worth an advisor's time (an insurance type AND at least one of: budget, timeline, or contact details).\n- lead_score: 0-100 intent/fit score.\n- intent: one short phrase (e.g. \"ready to buy auto cover\").\n- wants_human: true if the lead asks for a person, is frustrated, or the message clearly needs a human.\n- email: the lead's email if mentioned, else \"\".\n- summary: one sentence an advisor can read at a glance.",
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.5
    },
    {
      "id": "a1b2c3d4-0016-4a10-9a01-aa1111110016",
      "name": "Chat Model (Analysis)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        260,
        440
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "a1b2c3d4-0017-4a10-9a01-aa1111110017",
      "name": "Parse Lead Data (JSON)",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        440,
        440
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"qualified\": true,\n  \"lead_score\": 82,\n  \"intent\": \"ready to buy auto cover\",\n  \"wants_human\": false,\n  \"email\": \"user@example.com\",\n  \"summary\": \"Wants auto cover for a new car within 2 weeks, budget ~$80/mo, prefers a morning call.\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "a1b2c3d4-0018-4a10-9a01-aa1111110018",
      "name": "Qualified Lead?",
      "type": "n8n-nodes-base.if",
      "position": [
        660,
        100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cond-qualified",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.qualified }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a1b2c3d4-0019-4a10-9a01-aa1111110019",
      "name": "Upsert Lead in CRM",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        940,
        100
      ],
      "parameters": {
        "email": "={{ $json.output.email }}",
        "resource": "contact",
        "operation": "upsert",
        "additionalFields": {
          "message": "={{ $json.output.summary }} (AI lead score: {{ $json.output.lead_score }}/100)",
          "firstName": "={{ $('Lead Messages on WhatsApp').item.json.contacts[0].profile.name }}",
          "phoneNumber": "={{ $('Lead Messages on WhatsApp').item.json.messages[0].from }}",
          "lifeCycleStage": "lead"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a1b2c3d4-0020-4a10-9a01-aa1111110020",
      "name": "Wants a Human?",
      "type": "n8n-nodes-base.if",
      "position": [
        660,
        360
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cond-human",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.wants_human }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a1b2c3d4-0021-4a10-9a01-aa1111110021",
      "name": "Alert Sales Team (Handover)",
      "type": "n8n-nodes-base.slack",
      "position": [
        940,
        360
      ],
      "parameters": {
        "text": "=:rotating_light: *Live-agent handover \u2014 lead needs a human*\n*{{ $('Lead Messages on WhatsApp').item.json.contacts[0].profile.name }}* ({{ $('Lead Messages on WhatsApp').item.json.messages[0].from }})\nIntent: {{ $json.output.intent }} \u00b7 Score: {{ $json.output.lead_score }}/100\n{{ $json.output.summary }}",
        "select": "channel",
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": ""
        },
        "operation": "post",
        "otherOptions": {}
      },
      "typeVersion": 2.3
    }
  ],
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "Wants a Human?": {
      "main": [
        [
          {
            "node": "Alert Sales Team (Handover)",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Qualified Lead?": {
      "main": [
        [
          {
            "node": "Upsert Lead in CRM",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Reply on WhatsApp": {
      "main": [
        [
          {
            "node": "Qualify & Score Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Qualify & Score Lead": {
      "main": [
        [
          {
            "node": "Qualified Lead?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wants a Human?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Model (Analysis)": {
      "ai_languageModel": [
        [
          {
            "node": "Qualify & Score Lead",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Remember Conversation": {
      "ai_memory": [
        [
          {
            "node": "AI Insurance Assistant",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Insurance Assistant": {
      "main": [
        [
          {
            "node": "Reply on WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Lead Data (JSON)": {
      "ai_outputParser": [
        [
          {
            "node": "Qualify & Score Lead",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Chat Model (Conversation)": {
      "ai_languageModel": [
        [
          {
            "node": "AI Insurance Assistant",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Lead Messages on WhatsApp": {
      "main": [
        [
          {
            "node": "AI Insurance Assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}