Skip to main content
Integrations

Send WhatsApp Messages After AI Agents Call

Written By Product

Last updated 9 months ago

Workflow overview

[Webhook DeepAgent] → [IF: Condizione] → [WhatsApp: Invia Messaggio]

This workflow allows you to automatically send a WhatsApp message to the contact at the end of a call handled by DeepAgent.

Step 1: Prepare the Workflow

  1. Log in to n8n

  2. Open the DeepAgent Post-Call Webhook workflow

  3. The Webhook node is already configured

  4. You will add the following nodes starting from this one

Step 2: Add a Filter (Recommended)

  1. The filter is used to send WhatsApp messages only for certain calls.

  2. Click + after the Webhook node

  3. Add the IF node

  4. Configure a basic condition:

Field

Value

Value 1

{{ $json.status }}

Operator

equals

Value 2

completed

Useful alternative conditions: - {{ $json.sentimentLabel }} = positive - {{ $json.success }} = success

Step 3: Choose the WhatsApp Provider

n8n supports several providers:

Provider

Pro

Cons

WhatsApp Business Cloud API

Official Meta

Business verification required

Twilio

Quick setup

Paid

360dialog

Good support

Paid

Chat API

Simple

Unofficial

Step 4A: WhatsApp Business Cloud API (Recommended)

Requirements

  • Verified Meta Business account

  • Meta app with WhatsApp API enabled

  • Access Token

  • Phone Number ID

Node configuration

Field

Value

Operation

Send Message

Phone Number ID

Phone Number ID Meta

Recipient Phone Number

{{ $json.formattedPhone }}

Message Type

Text

Message

Message text

Message example

Hello {{ $json.payload.metadata.dynamicVariables.user_name }},

thank you for calling our assistant.

Summary: {{ $json.callSummary }}

For any information, you can reply to this message.

Step 4B: Twilio (Alternative)

Prerequisites

  • Twilio account

  • Active WhatsApp Sender

Node configuration

Field

Value

Resource

Message

From

WhatsApp: +14155238886

To

WhatsApp:{{ $json.formattedPhone }}

Message

Message text

Step 5: Format the Phone Number

To avoid errors, it is recommended to format the number before sending.

Add a Code node (JavaScript) between IF and WhatsApp:

let phone = $json.phoneNumber || '';
phone = phone.replace(/[\s\-\(\)\.]/g,
'');
if (!phone.startsWith('+')) {
if (phone.startsWith('00')) phone = '+' + phone.substring(2);
else if (phone.startsWith('3')) phone = '+39' + phone;
else phone = '+' + phone;
}
return { ...$json, formattedPhone: phone };

In the WhatsApp node, use:

{{ $json.formattedPhone }}

Step 6: Complete Workflow

[Webhook]
↓
[IF] status = completed
↓ (true)
[Code] format phone
↓
[WhatsApp] send message

Step 7: Test the Flow

  1. Activate the workflow (toggle ON)

  2. Make a test call with DeepAgent

  3. Check the Executions section in n8n

  4. Verify that the WhatsApp message is received

Available Variables

Variable

Description

{{ $json.phoneNumber }}

Contact number

{{ $json.callSummary }}

Call summary

{{ $json.callTranscription }}

Full transcription

{{ $json.callDuration }}

Call duration

{{ $json.status }}

Call status

{{ $json.sentimentLabel }}

sentiment

{{ $json.payload.metadata.dynamicVariables.user_name }}

contact name

{{ $json.payload.metadata.dynamicVariables.user_email }}

contact email

Example Complete Message

Dear {{ $json.payload.metadata.dynamicVariables.user_name }},

Thank you for speaking with our virtual assistant.

📞 Call duration: {{ Math.round($json.callDuration / 60) }} minutes 📝 Summary:

{{ $json.callSummary }}

If you would like more information, you can reply to this message.

Best regards

Troubleshooting

Problem

Solution

Message not sent

Check WhatsApp/Twilio credentials

Invalid number

Check international dialing code

Template not approved

Use approved templates Meta

Rate limit

Reduce message frequency