---
name: whatsapp-lead-routing
description: Design an n8n workflow that receives inbound WhatsApp Business messages, finds or creates the contact in the CRM, classifies intent, assigns an owner and pipeline, replies inside the 24-hour window and escalates if nobody answers. Use when the user wants to organize or automate leads arriving on WhatsApp.
---

# WhatsApp Lead Routing (n8n)

## Ask before building
1. How WhatsApp comes in: Meta's Cloud API, the CRM's WhatsApp (e.g. GoHighLevel) or another provider.
2. Assignment rules: by service, by city or location, by hours, by shift.
3. Owners and backups, with their alert channel.
4. Maximum time without a reply before escalating.
5. CRM and pipeline where opportunities should land.

## Flow
1. **Trigger**: inbound WhatsApp message webhook.
2. **Filter**: ignore status updates, group messages and the team's internal numbers.
3. **Find contact** in the CRM by phone (normalized to international format).
   - Exists with an open opportunity: alert its current owner and stop.
   - Does not exist: create the contact with source `WhatsApp`.
4. **Classify** (keyword rules first; an AI node only when rules are not enough): service, city, urgency. If unknown, `unclassified`.
5. **Assign** from a rules table (Google Sheets or Notion) so the owner can change it without touching the workflow. No matching rule: default owner.
6. **Create opportunity** in the right pipeline and stage, tagged `wa_lead`, `service_<x>`, `city_<y>`.
7. **Welcome**: a short, human message with the business name and one question. Only inside the 24-hour window since the customer's last message; outside it, only Meta-approved templates.
8. **Internal alert** to the owner with a summary and a link to the chat.
9. **Escalation**: wait the defined time; if the team has not replied, alert the backup and tag `no_reply`.

## Rules
- The AI never promises prices, timing or availability; a person answers those.
- Never send promotional messages to anyone who did not opt in.
- Log every step on the contact record so it can be audited.

## Deliverable
- The n8n workflow JSON.
- The assignment rules table.
- Tests: new contact, existing contact, unclassified message and an escalation case, with screenshots.
