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.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_managementpermission 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.Configure environment variables
Store your tokens in a
.env file in your project root.- Cascade
- Realtime
.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 Declare your dependencies in a Keep the process running. It registers with Zero Runtime using the ID
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.- Cascade
- Realtime
pyproject.toml, then let uv build the environment and run the agent:- Cascade
- Realtime
pyproject.toml
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.2. Outbound gateway: lets the agent dial out to WhatsApp numbers. First fetch the SIP credentials from Meta:Use the returned
- Dashboard
- API
1. Inbound gateway: the entry point for incoming WhatsApp calls.
- In the Zero Runtime Dashboard, go to Telephony > Phone Numbers and click Add Number > Configure SIP.
- Enter a Name (e.g.
WhatsApp Gateway) and your WhatsApp Business Phone Number. - Open the Inbound tab and copy the Inbound Gateway URL. You need it to enable SIP forwarding in Meta.
hostname (address) and sip_user_password (password) to create the gateway.- Dashboard
- API
- In the same SIP Configuration panel, open the Outbound tab.
- Set Outbound Gateway Address to the Meta
hostname, SIP Username to your WhatsApp number, and SIP Password tosip_user_password. - 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()).- Dashboard
- API
- In Telephony > Phone Numbers, click Configure Rule on your WhatsApp number, then Create New Routing Rule.
- Enter a Routing Rule Name, select an API Key, and set Call Direction to Inbound.
- Select your WhatsApp number under Phone Numbers.
- Enter
agent1as the Agent Name or ID (must matchmain.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.
- Inbound
- Outbound
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
agent1and 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.
What’s Next
Telephony docs
Explore call transfer, DTMF, voicemail, and more.
Deploy an agent
Move from local to production.