How it works
- During the call, the voice agent asks whether the caller wants to continue on WhatsApp. You tell it to in its instructions.
- When the call ends, the agent fills its custom fields and sends the Variables collected event.
- Your workflow receives the event and sends an approved WhatsApp template from your text agent to the caller’s number.
- When the caller replies, your text agent takes over. The call and the WhatsApp conversation belong to the same contact.
Before you start
- A text agent with WhatsApp connected and an approved template to open the conversation.
- n8n with the community node installed and connected with an API key of the subaccount. See n8n.
- A voice agent that takes calls. See Voice agents.
Set it up
1
Add a field to the voice agent
In the voice agent, open Custom fields and add one such as
whatsapp_ok, with What it is set to “Whether the caller agreed to continue on WhatsApp”. For web calls, which have no phone number, add whatsapp_phone too.2
Ask for it in the instructions
In Instructions and greeting, tell the agent to ask before hanging up whether the caller wants to continue on WhatsApp and, on a web call, to confirm the number.
3
Listen for the call
In n8n, add the Newlead Trigger node, set Agent Type to Voice, choose the voice agent and the Call Analyzed event.
4
Check the answer
Continue only when the event’s
variables show that the caller agreed.5
Get the number
Use Call › Get with the event’s
call_id. On an incoming call, from is the caller’s number; on an outgoing one, it’s to. On a web call, use the whatsapp_phone field.6
Send the template
Use Template › Send with your text agent, the template and the number, with its country code. Under Options, set Source Lead ID to the event’s
lead_id so both leads belong to the same contact, and set Idempotency Key to the call_id so each call sends one message at most.Good to know
- Variables collected, which n8n calls Call Analyzed, is only sent when the agent has custom fields, the call has a transcript and the analysis works. If it isn’t sent, no message goes out.
- Test calls from the agent’s page don’t send events, so test the workflow with a real call.
- For phone calls, prefer the number from the call over one the caller dictated: a number read out loud can be misheard.
- A contact marked Do not contact doesn’t get the template.
- What the events carry is in Webhook events, and the template options are in Send a template.