Automate Sales Opportunity Alerts with n8n and Twilio WhatsApp
Deliver timely, actionable sales notifications to reps and managers via WhatsApp using n8n and the Twilio WhatsApp API. This guide walks through a ready-to-use workflow that receives a CRM webhook, looks up the owner’s phone, builds a message, and sends WhatsApp alerts — with escalation for high-value deals.
Why use WhatsApp + n8n for sales notifications?
WhatsApp is a fast, low-friction channel for sales teams. Combined with n8n’s visual automation and Twilio’s programmable messaging, you can instantly notify owners about new opportunities, reduce time-to-first-contact, and escalate high-value deals to managers automatically.
What this workflow does (at a glance)
- Receives a CRM webhook when a new opportunity is created
- Queries a MySQL mapping table to find the owner’s WhatsApp number
- Builds a formatted WhatsApp message including customer, value, stage, and CRM link
- Sends the message to the owner via Twilio WhatsApp
- Sends an escalation message to a manager if the deal exceeds a configurable threshold
- Logs the notification in the workflow for auditing
Architecture & workflow overview
The flow consists of the following n8n nodes:
- Webhook (receive-crm-opportunity-webhook) – Entry point for CRM webhook payloads.
- MySQL (load-owner-phone-map) – Selects mapping data from
crm_owner_phone_map. - Code (build-whatsapp-message) – Normalizes payload, finds the owner mapping, formats message text, and computes recommended action.
- If (check-deal-threshold) – Evaluates whether the deal exceeds the escalation threshold (default: $100,000).
- HTTP Request (send-whatsapp-to-owner / send-escalation-to-manager) – Calls Twilio API to send WhatsApp messages.
- NoOp (log-notification-sent) – Placeholder to indicate completion/logging.
Step-by-step setup
1. Configure the CRM webhook
Configure your CRM (Salesforce, HubSpot, Pipedrive, etc.) to POST a JSON payload to the n8n webhook URL produced by the receive-crm-opportunity-webhook node. Include fields such as opportunityId, customerName (or accountName), dealValue (amount), closeDate, ownerEmail (or owner.email), and opportunityUrl.
2. Create the MySQL mapping table
Create a lightweight table to map CRM owners to WhatsApp numbers and manager escalation numbers. Example SQL:
CREATE TABLE crm_owner_phone_map (
OwnerEmail VARCHAR(255) NOT NULL PRIMARY KEY,
OwnerName VARCHAR(255) NOT NULL,
WhatsAppPhone VARCHAR(20) NOT NULL,
ManagerPhone VARCHAR(20)
);
Ensure phone numbers are stored in E.164 format (e.g. +14155551234).
3. Configure Twilio WhatsApp
- Sign up for Twilio and enable the WhatsApp API (or use Twilio Sandbox for testing).
- Replace
YOUR_ACCOUNT_SIDin the HTTP Request node URL with your Twilio Account SID. - In n8n, add HTTP Basic credentials containing your Twilio Account SID as username and the Auth Token as password.
- Set the
Fromparameter to your Twilio WhatsApp-enabled number (example:whatsapp:+14155238886).
4. Import and configure the n8n workflow
Import the provided workflow into n8n. Update the MySQL credentials, the Twilio HTTP Basic credentials, and any CRM URL formatting in the build code node to match your CRM’s opportunity URL pattern.
Code walkthrough: build-whatsapp-message node
The code node normalizes the webhook payload and constructs a human-friendly WhatsApp message. Key responsibilities:
- Map incoming webhook fields to internal variables (opportunityId, customerName, dealValue, closeDate, ownerEmail).
- Look up the owner mapping produced by the MySQL node.
- Format currency and choose a recommended action depending on deal size.
- Return JSON with
messageText,recipientPhone,managerPhone, and other metadata consumed by downstream nodes.
Example message template produced by the code node:
🎯 *New Sales Opportunity Alert*
*Customer:* Acme Corp
*Deal Value:* $120,000.00
*Stage:* Proposal
*Expected Close:* 2025-11-01
*Opportunity ID:* OP-12345
📋 *Recommended Action:*
Schedule discovery call within 24 hours
🔗 View in CRM: https://crm.company.com/opportunity/OP-12345
Assigned to: Jane Sales
Escalation logic & threshold
The workflow uses an If node to check whether dealValue is larger than the configured threshold (default: 100000). If true, the workflow sends both the owner message and an escalation message to the manager with an extra alert banner. Update the threshold in the check-deal-threshold node to fit your company policy.
Testing and validation
- Use the Twilio Sandbox for WhatsApp to test message delivery without going live.
- Send a sample webhook from your CRM or use curl/Postman to POST a test payload to the webhook URL.
- Check the MySQL query returns the expected owner mapping row for the ownerEmail used in your test payload.
- Inspect the output of the code node in n8n to confirm the messageText, recipientPhone, and managerPhone values.
- Monitor Twilio console for message delivery status and any errors returned by the API.
Best practices & security
- Use HTTPS for your n8n instance and restrict webhook access if possible (IP allowlist, HMAC signatures).
- Store Twilio credentials in n8n credentials (not in code or public workflow). Use environment variables for production.
- Validate incoming webhook payloads and sanitize any fields you include in messages to avoid injection or formatting issues.
- Limit frequency to avoid spamming reps — consider debouncing or coalescing multiple updates into a single message for the same opportunity.
Troubleshooting tips
- If messages fail with authorization errors, double-check Account SID and Auth Token in n8n credentials.
- For
Tophone errors, confirm the number is in E.164 and registered/accepted by the Twilio Sandbox if testing. - Use n8n’s execution log for each node to inspect inputs/outputs. The code node returns structured JSON that helps isolate parsing issues.
- Enable retries on HTTP Request nodes (configured in the sample) to handle transient network failures.
Conclusion
This n8n + Twilio WhatsApp workflow gives sales teams instant visibility into new opportunities and a straightforward escalation path for high-value deals. It’s lightweight, extensible, and designed to be customized for any CRM. Whether you’re improving response times or ensuring manager attention on major deals, this automation can make your sales process more responsive.
Try the workflow now: Import the template into n8n, connect your MySQL and Twilio credentials, send a test webhook, and watch a WhatsApp alert arrive. Need help customizing the message template, threshold logic, or CRM mapping? Contact our team or subscribe for more automation templates and how-tos.
Call to action: Import the template, run a test, and if you’d like, reply here with your CRM payload sample — I can suggest the exact code tweaks to match your fields.
