Skip to main content

Architecture

A WhatsApp caller reaches the Meta Business Platform, which forwards the call over SIP to the Zero Runtime SIP Gateway. A routing rule invokes your self-hosted agent by matching its agent id.
WhatsApp voice agent architecture: a WhatsApp user calls through the Meta Business platform, which bridges the call over SIP to the Zero Runtime SIP Gateway (inbound and outbound). A routing rule sends it into Zero Runtime Cloud, where the routing layer hands it to the Zero Runtime Runtime hosting your AI agent, and the Zero Runtime API Server invokes the agent to start the call.

Prerequisites

  • Meta side:
    • A verified Meta Business Manager account.
    • A phone number verified in your WhatsApp Business Account (WABA).
    • A Meta Developer App with the whatsapp_business_management permission enabled.
    • A permanent user access token for the Meta Graph API.
  • Zero Runtime side: A Zero Runtime Auth token (ZERORUNTIME_AUTH_TOKEN). Generate one in the Zero Runtime Dashboard.

Quickstart

Setup the project

Use Python 3.11 or higher, then install the Zero Runtime Agents SDK. Create and activate a virtual environment, then install zrt and python-dotenv. Every provider plugin ships with zrt.
New to uv? See the uv install guide.

Configure environment variables

Store your tokens in a .env file in your project root.
.env

Build the agent

The agent must register itself with Zero Runtime so calls can be routed to it. It needs a unique agent id for the routing rule to match. Set ZERORUNTIME_AGENT_ID to that id (it defaults to zeroruntime_agent) and start it with zeroruntime.serve(), which registers it automatically. WhatsApp calls arrive through your routing rule, so there is no playground to open. Just keep the process running.
Declare your dependencies in a pyproject.toml, then let uv build the environment and run the agent:
pyproject.toml
Keep the process running. It registers with Zero Runtime using the ID agent1.

Configure SIP in Zero Runtime

Configure SIP for your WhatsApp number so Zero Runtime can route calls in and out. Use the Dashboard or the API.
1. Inbound gateway: the entry point for incoming WhatsApp calls.
  1. In the Zero Runtime Dashboard, go to Telephony > Phone Numbers and click Add Number > Configure SIP.
  2. Enter a Name (e.g. WhatsApp Gateway) and your WhatsApp Business Phone Number.
  3. Open the Inbound tab and copy the Inbound Gateway URL. You need it to enable SIP forwarding in Meta.
2. Outbound gateway: lets the agent dial out to WhatsApp numbers. First fetch the SIP credentials from Meta:
Use the returned hostname (address) and sip_user_password (password) to create the gateway.
  1. In the same SIP Configuration panel, open the Outbound tab.
  2. Set Outbound Gateway Address to the Meta hostname, SIP Username to your WhatsApp number, and SIP Password to sip_user_password.
  3. Click Save & Activate.

Create a routing rule

Connect your WhatsApp number to your agent by ID. The agent ID must match the id your agent registers under — ZERORUNTIME_AGENT_ID (registered by zeroruntime.serve()).
  1. In Telephony > Phone Numbers, click Configure Rule on your WhatsApp number, then Create New Routing Rule.
  2. Enter a Routing Rule Name, select an API Key, and set Call Direction to Inbound.
  3. Select your WhatsApp number under Phone Numbers.
  4. Enter agent1 as the Agent Name or ID (must match main.py), click Verify Agent ID, then click Create Rule.

Enable WhatsApp SIP forwarding

Tell Meta to forward incoming WhatsApp calls to your inbound gateway. Substitute the Inbound Gateway URL you copied from the Inbound tab.
A successful response is { "success": true }.

Place a test call

Make sure your main.py script is still running locally before making or receiving calls. The agent must be active to handle any communication.
From a different WhatsApp account, place a voice call to your WhatsApp Business number. The agent answers and greets you.

Verify

  • The agent registers under the ID agent1 and the worker process stays running.
  • An incoming WhatsApp call reaches the agent and you hear the greeting.
  • Outbound calls dial the target WhatsApp number through your outbound gateway.
Common errors:
  • Agent ID mismatch: the routing rule’s agentId must exactly match the id the agent registers under (ZERORUNTIME_AGENT_ID).
  • Missing Meta permission: the access token needs whatsapp_business_management.
  • SIP forwarding off: the Meta calling.sip.status must be ENABLED.
  • Agent not running: the worker process must be alive to accept the inbound call.

What’s Next

Telephony docs

Explore call transfer, DTMF, voicemail, and more.

Deploy an agent

Move from local to production.

References