Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

Skip to main content
The Vocode API allows you to configure your outbound call agent’s behavior when the other end of a phone call is an answerphone as well as subscribe to events relating to machine detection.

Example 1: Hang up the call if it goes to voicemail

The on_no_human_answer parameter defines what should happen if a machine answers the phone.
from vocode import CreateCallAgentParams, PromptParams

vocode_client.calls.create_call(
    from_number="<YOUR VOCODE NUMBER>",
    to_number="15555555555",
    agent=CreateCallAgentParams(
        prompt=PromptParams(
            content="Ask Ajay if his refrigerator is running"
        ),
    ),
    on_no_human_answer="hangup",
)

Example 2: Hook into when a call goes to voicemail

If you’d like the bot to stay on the call and leave a voicemail, set on_no_human_answer to "continue". You can also configure a webhook to be fired when the answering machine detection status is populated.
from vocode import CreateCallAgentParams, PromptParams

vocode_client.calls.create_call(
    from_number="<YOUR VOCODE NUMBER>",
    to_number="15555555555",
    agent=CreateCallAgentParams(
        prompt=PromptParams(
            content="Ask Ajay if his refrigerator is running"
        ),
        webhook=WebhookParams(
            url="<YOUR WEBHOOK URL>",
            subscriptions=["event_human_detection"]
        )
    ),
    on_no_human_answer="continue"
)
Once the call is picked up, the webhook URL configured above will get the following POST request:
{
  "type": "event_human_detection",
  "call_id": "<some UUID>",
  "payload": {
    "result": "no_human" # or "human"
  }
}

On the horizon

Stay tuned for more features here, for example:
  • Instructing your agent to leave a particular voicemail
  • Routing the call to a human when a human picks up, otherwise leave a voicemail
Morty Proxy This is a proxified and sanitized view of the page, visit original site.