Call Commands
Call commands control telephony on a live Call: answer, connect a human party,
whisper, barge, spy, close, and disconnect. Each command method returns a
CommandResult (truthy on success). Treat a falsy result as an operational
failure; connection loss and programmer errors still raise exceptions.
Full method list: API Reference - Call. This page is about when to use each command, with complete programs you can run.
Two inbound shapes
A. Agent is the voice (answer)
Use when your bot speaks for the subscriber (IVR, receptionist, booking agent).
Later escalate with connect() if a human should join, then whisper() a brief and close() so humans continue.
B. Ambient agent (connect first)
Use when two humans talk directly and your code listens or coaches. On inbound, call bare connect() without answer():
Tutorial: answer + respond (echo)
Agent is the voice. Answer inbound, echo caller audio until hangup.
Tutorial: ambient connect → spy → whisper
Humans talk directly. Your agent connects ambiently, listens in spy mode, then whispers a short tone burst to the subscriber only, then leaves with close().
To record both parties, also consume call.callee.audio_stream() in a parallel task - audio is always isolated per party.
Ambient modes (after connect())
Who is the subscriber? On inbound: your line (callee). On outbound: your line (caller). See Participant Model.
Outbound
Audio commands
Do not call private helpers such as call._interrupt(). Use clear_send_audio_buffer().
