Automate Sales Opportunity Alerts with n8n and Twilio WhatsApp
On a rainy Tuesday afternoon, Alex, a sales operations lead at a fast-growing B2B startup, stared at yet another angry email from a regional manager.
“We missed this 120k opportunity. Again. No one followed up in time. How is this still happening?”
Alex knew the pattern all too well. New opportunities entered the CRM, reps were buried in email, and by the time anyone noticed a big deal, the prospect had already gone cold. Notifications were scattered across inboxes, Slack channels, and CRM dashboards no one refreshed often enough.
What Alex needed was simple in theory: instant, reliable sales alerts on a channel reps actually checked. In practice, it felt like a messy, cross-tool nightmare.
That was the day Alex found an n8n workflow template that used Twilio and WhatsApp to automate sales opportunity alerts, complete with escalation for high-value deals.
The problem: slow reactions to hot opportunities
Alex’s sales team was fast on calls, but slow on awareness. New opportunities were created in Salesforce and HubSpot all day long, yet:
- Reps only saw new deals if they happened to be in the CRM
- Email alerts were delayed or buried under other notifications
- High-value opportunities did not reliably reach managers in time
Alex watched as opportunities worth six figures slipped through the cracks. Time-to-first-contact was inconsistent, managers only heard about big deals after the fact, and there was no clear audit trail of who was alerted when.
One morning, while searching for “n8n sales notifications WhatsApp,” Alex came across a workflow template that promised exactly what the team needed.
The discovery: a WhatsApp alert system built on n8n + Twilio
The template description caught Alex’s eye right away. It used:
- n8n as the visual automation engine
- Twilio WhatsApp API to send messages to reps and managers
- A CRM webhook as the trigger whenever a new opportunity was created
- MySQL to map CRM owners to their WhatsApp numbers
In short, the workflow would:
- Receive a CRM webhook when a new opportunity was created
- Look up the opportunity owner’s WhatsApp number in a MySQL table
- Build a formatted WhatsApp message with customer, deal value, stage, and CRM link
- Send the alert via Twilio WhatsApp
- Escalate to a manager automatically if the deal size exceeded a threshold
- Log the notification in the workflow for auditing
This was exactly the system Alex had imagined, already wired together. The only thing left was to adapt it to the company’s CRM and data.
Inside the workflow: how the pieces fit together
Before making any changes, Alex opened the n8n workflow to understand its architecture. The visual canvas told a clear story of how data would flow:
- Webhook (receive-crm-opportunity-webhook) – Entry point that waits for JSON payloads from the CRM whenever a new opportunity is created.
- MySQL (load-owner-phone-map) – Queries a table named
crm_owner_phone_mapto match the CRM owner’s email to their WhatsApp number and manager’s number. - Code (build-whatsapp-message) – Normalizes the webhook payload, finds the owner mapping, formats the WhatsApp message text, and computes a recommended action based on deal size.
- If (check-deal-threshold) – Compares the opportunity’s
dealValueagainst an escalation threshold, set by default to 100000. - HTTP Request (send-whatsapp-to-owner / send-escalation-to-manager) – Calls the Twilio API to send WhatsApp messages to the owner and, for large deals, to the manager.
- NoOp (log-notification-sent) – A placeholder node marking completion and providing a hook for logging or extensions later.
Instead of a tangled set of custom scripts, Alex now had a clear, maintainable automation path. The next step was to wire it up to the real tools the team used every day.
Rising action: wiring the CRM to WhatsApp in n8n
Step 1 – Teaching the CRM to talk to n8n
The first hurdle was getting the CRM to send opportunity data into the workflow. Alex configured the company’s CRM (in this case, Salesforce, though HubSpot or Pipedrive would have worked too) to POST a JSON payload to the n8n webhook URL exposed by the receive-crm-opportunity-webhook node.
The webhook was set up to receive key fields, including:
opportunityIdcustomerNameoraccountNamedealValueoramountcloseDateownerEmailorowner.emailopportunityUrlfor direct access back to the CRM
With the webhook URL in place, the first test payload successfully appeared in n8n’s execution log. The story had officially moved from theory to reality.
Step 2 – Creating the owner-to-WhatsApp map
Next, Alex needed a reliable way to map CRM owners to their WhatsApp numbers, along with manager escalation contacts. The template suggested a simple MySQL table, so Alex created it using the following 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)
);
Every phone number was stored in E.164 format, such as +14155551234, to match Twilio’s requirements. Once the table was populated with the sales team’s data, the load-owner-phone-map node could return the correct row based on the ownerEmail from the webhook.
Step 3 – Connecting Twilio WhatsApp
To bridge the gap between n8n and WhatsApp, Alex turned to Twilio:
- Signed up for Twilio and enabled the WhatsApp API, starting with the Twilio Sandbox for safe testing.
- Replaced
YOUR_ACCOUNT_SIDin the HTTP Request node URL with the actual Twilio Account SID. - Created HTTP Basic credentials in n8n, using the Twilio Account SID as the username and the Auth Token as the password.
- Set the
Fromparameter in the HTTP Request nodes to the Twilio WhatsApp-enabled number, for examplewhatsapp:+14155238886.
With these steps complete, the workflow was technically capable of sending WhatsApp messages. The only missing piece was the content of those messages.
The turning point: crafting the perfect WhatsApp alert
The heart of this automation lived in a single n8n Code node named build-whatsapp-message. Alex opened it and realized it did far more than just stitch strings together.
What the code node actually does
Inside the build-whatsapp-message node, the logic handled four critical tasks:
- Mapping incoming webhook fields to internal variables like
opportunityId,customerName,dealValue,closeDate, andownerEmail. - Looking up the owner’s mapping from the MySQL node output, including
WhatsAppPhoneandManagerPhone. - Formatting the deal value as currency and choosing a recommended action based on the size of the opportunity.
- Returning structured JSON for downstream nodes, including
messageText,recipientPhone,managerPhone, and other metadata.
The result was a clear, human-friendly WhatsApp alert that looked something like this:
🎯 *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
Alex tweaked the wording slightly to match the company’s tone, but kept the structure. The combination of key fields, clear next step, and direct CRM link meant reps could act within seconds of receiving the alert.
Escalation logic: making big deals impossible to ignore
Fast responses were great, but Alex also needed a way to guarantee that high-value deals attracted management attention. That is where the check-deal-threshold node came in.
This If node compared dealValue from the webhook to a configurable threshold, set by default to 100000. The logic was simple but powerful:
- If
dealValueis less than or equal to the threshold, only the owner receives a WhatsApp alert. - If
dealValueis greater than the threshold, the workflow sends the owner’s message and a second escalation message to the manager, often with an extra alert banner or stronger call to action.
Alex adjusted the threshold to match the company’s policy on what counts as a “major deal” and verified that the manager number from ManagerPhone in the MySQL table was correctly passed into the Twilio HTTP Request node.
From that point on, any opportunity above the threshold would trigger an automatic manager alert, no extra configuration needed.
Bringing it all together: importing and configuring the template
With the logic clear and the building blocks ready, Alex imported the workflow template into n8n and customized a few final details:
- Updated MySQL credentials in the load-owner-phone-map node to point to the production database.
- Configured the Twilio HTTP Basic credentials in n8n to use the live Twilio account.
- Adjusted the code in build-whatsapp-message to match the exact CRM opportunity URL pattern and field names used internally.
What started as a scattered notification problem was now a tightly wired automation, ready for real-world testing.
Testing the new WhatsApp sales alert workflow
Before rolling this out to the entire team, Alex needed proof that it worked end to end. The testing process followed a clear checklist:
- Used the Twilio Sandbox for WhatsApp to verify message delivery without impacting real customers or numbers.
- Triggered a sample webhook from the CRM, and also tried sending a test payload via curl or Postman to the n8n webhook URL.
- Checked that the MySQL query returned the correct row for the test
ownerEmail, including the owner’s and manager’s phone numbers. - Inspected the build-whatsapp-message node output in n8n to confirm
messageText,recipientPhone, andmanagerPhonewere all correct. - Monitored the Twilio console for message delivery status and any API errors.
Within minutes, Alex’s phone buzzed with a WhatsApp message that looked exactly like the template. A second message arrived on the manager’s phone for a high-value test deal, confirming that the escalation path worked perfectly.
Keeping it safe and clean: best practices Alex followed
As the workflow moved from test to production, Alex put a few safeguards in place to keep the automation secure and respectful of the team’s attention.
- Ensured the n8n instance was served over HTTPS and restricted webhook access with methods like IP allowlists or HMAC signatures where possible.
- Stored Twilio credentials inside n8n’s credential manager, not in code or publicly visible workflow fields, and used environment variables for production deployments.
- Validated and sanitized incoming webhook payloads, especially fields that appeared in the message text, to avoid injection or formatting issues.
- Planned rate limits and considered debouncing multiple updates for the same opportunity so reps would not be spammed with too many alerts.
These small steps ensured that the workflow was not just effective but also secure and sustainable.
When things go wrong: how Alex troubleshoots
Not every test went smoothly. A few early runs surfaced configuration issues that Alex resolved using a simple troubleshooting playbook:
- If WhatsApp messages failed with authorization errors, Alex double-checked the Twilio Account SID and Auth Token in n8n credentials.
- For
Tophone number errors, Alex confirmed that the numbers were in E.164 format and, when using the Twilio Sandbox, that they were registered or approved for testing. - Used n8n’s execution logs to inspect inputs and outputs for each node. The structured JSON from the code node made it easy to spot parsing or mapping issues.
- Relied on retries configured in the HTTP Request nodes to handle transient network failures without manual intervention.
With each fix, the workflow became more robust and reliable, giving Alex confidence to roll it out company-wide.
The resolution: a more responsive, data-driven sales team
Within a week of going live, the impact was obvious. Reps started responding to new opportunities faster, often within minutes of creation. Managers received automatic alerts for large deals, giving them time to support the reps with strategy and resources.
The sales floor felt different. Instead of chasing down information in the CRM, people were reacting to WhatsApp alerts that contained everything they needed to act:
- Customer name and deal value
- Stage and expected close date
- Opportunity ID and direct CRM link
- A clear recommended next action
Behind the scenes, n8n and Twilio handled the heavy lifting, while the MySQL mapping and code node kept everything personalized and on-brand. The workflow remained lightweight and extensible, easy to adapt to other CRMs or additional channels later.
For Alex, the missed 120k deal became a turning point instead of a recurring nightmare.
Try the same n8n + Twilio WhatsApp workflow in your team
If you recognize Alex’s story in your own sales process, you can follow the same path:
- Import the ready-to-use n8n workflow template.
- Connect your MySQL database and create the
crm_owner_phone_maptable. - Configure Twilio WhatsApp, set your Account SID, Auth Token, and WhatsApp-enabled number.
- Point your CRM webhook to the n8n receive-crm-opportunity-webhook URL.
- Run a test webhook and watch your first WhatsApp sales alert arrive.
This n8n + Twilio WhatsApp automation gives your sales team instant visibility into new opportunities and a reliable escalation path for high-value deals. It is flexible enough to work with Salesforce, HubSpot, Pipedrive, and other CRMs, and simple enough to customize for your own fields and message style.
Ready to see it in action? Import the template into n8n, send a test payload, and start measuring how much faster your team responds to new opportunities.
If you want help tailoring the message template, adjusting the escalation threshold, or mapping your CRM fields into the code node, share a sample of your CRM webhook payload and we can suggest the exact tweaks you need.
