1. Tasks
  2. Answer WhatsApp Call

Tasks

Answer WhatsApp Call

Answers a ringing WhatsApp call and connects the caller to a live AI voice call. Useful for voice assistants that pick up calls to your WhatsApp number.

When a WhatsApp user calls your number, the stub gets an _update_from_whatsapp with is_incoming_call set to true. To pick up, start a voice call with Start Voice Chat on the whatsapp channel, then run this task with the call and the new voice call.

The task waits until the call is connected and the caller can hear the assistant, usually within 2 seconds, and then returns. From then on the call works like any live voice call: the stub steers it with voice notifications and gets _update_from_voice updates, including when the call ends.

NOTE

The call must be answered within 25 seconds of the incoming call event. After that it's rejected automatically, and the stub gets a missed call event instead.

Basic usage

loading...

Parameters

comwhatsappcalluuid
required
string

The id of the call, from stubpost.data._incoming_whatsapp_data.call_data.comwhatsappcalluuid on the incoming call event.


voice_session_uuid
required
string

The voice call to connect the caller to, from the Start Voice Chat result. Start it with "channel": "whatsapp".

WhatsApp calls need an audio/pcm format, which is the whatsapp channel's default. Don't set audio.format to audio/pcmu or audio/pcma for WhatsApp calls.

Result

loading...

Properties

payload.status
string

answered: the caller is connected to the assistant.


payload.comwhatsappcalluuid
string

The id of the call that was answered.


payload.audio.format
object

The audio format of the voice call.

Errors

message Meaning
comwhatsappcalluuid is required The comwhatsappcalluuid param is missing
voice_session_uuid is required The voice_session_uuid param is missing
unknown_call No call with this comwhatsappcalluuid
call_not_ringing The call isn't ringing anymore. error.details.status and error.details.reason say why, eg the caller hung up first, or the call was already answered or rejected

These are conceptual errors. If the caller hung up before or while the call was answered, the stub also gets a missed call event with the reason caller_hangup.

When answering fails along the way, the task returns a technical error, and error.details.step says where it failed. The caller's call ends, and the voice call ends as abandoned by itself, with a session_ended _update_from_voice.

error.details.step Where it failed
answer The call's audio connection couldn't be set up
pre_accept / accept WhatsApp refused to connect the call. error.details.meta has WhatsApp's error
connect The audio connection to WhatsApp didn't come up within 10 seconds
join The voice call refused the caller, eg the voice_session_uuid is unknown or already ended, or its audio format isn't supported
proxy The call couldn't be handed to the voice service

Examples

Answer every incoming call

On the action that receives _update_from_whatsapp, start the voice call and answer. Both tasks use is_incoming_call as their condition, so they don't run for messages or missed calls. The greeting makes the assistant speak first.

loading...

Answer calls from a call button

When a call comes from a call button in a message you sent, call_data.cta_payload has the button's payload. Answer only those calls, and reject the rest with Reject WhatsApp Call:

loading...

End the call

There is no task to hang up a WhatsApp call. End the voice call as usual, eg with a hangup voice notification or the Voice Hangup task. The assistant says goodbye, then the WhatsApp call ends.

loading...