1. Tasks
  2. Answer Dial Call

Tasks

Answer Dial Call

Answers a ringing phone call and connects the caller to a live AI voice call. Useful for voice assistants that pick up calls to an extension on your phone system.

When a phone call comes in through a SIP connection, the stub gets an _update_from_dial with is_incoming_call set to true. To pick up, start a voice call with Start Voice Chat on the dial 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 a second, 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. The caller hears ringing until then. After that the call is turned away, and the stub gets a missed call event instead.

Basic usage

loading...

Parameters

dialcalluuid
required
string

The id of the call, from stubpost.data._incoming_dial_data.call_data.dialcalluuid 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": "dial" and the call's audio format:

        "audio": {
  "format": "~~stubpost.data._incoming_dial_data.call_data.audio_format"
}

      

Phone calls use the G.711 format the phone system prefers, audio/pcmu (μ-law) or audio/pcma (A-law), and the voice call has to match it. Use ~~ so the format is passed as an object. Without audio.format, the voice call uses the dial channel's default, μ-law, and an A-law call fails at the gateway_join step.

Result

loading...

Properties

payload.status
string

answered: the caller is connected to the assistant.


payload.dialcalluuid
string

The id of the call that was answered.


payload.voice_session_uuid
string

The voice call the caller is connected to.


payload.audio_format
object

The audio format of the call.

Errors

message Meaning
dialcalluuid and voice_session_uuid are required A param is missing
unknown_call No call with this dialcalluuid in your organization. The call belongs to the organization of its SIP connection
call_not_ringing The call isn't ringing anymore. error.details.status says why, eg missed when the caller hung up first, or the call was already answered or rejected

These are conceptual errors.

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. A voice call that never got the caller ends as abandoned by itself, with a session_ended _update_from_voice.

error.details.step Where it failed
rtp The call's audio connection couldn't be set up
sip_answer The phone system didn't confirm the answer within 4 seconds
gateway_join The voice call refused the caller, eg the voice_session_uuid is unknown or already ended, or its audio format doesn't match the call's (see audio.format above)

Examples

Answer every incoming call

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

loading...

Greet known callers by name

from is the caller's number. When the stub knows the caller, put their name in the greeting:

loading...

End the call

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

loading...