> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Routing SIP Calls to Agents

> Learn how to configure routing rules to direct SIP calls to AI agents in Zero Runtime, including Agent Cloud and self-hosted deployment options.

You can route inbound or outbound SIP calls directly to an AI agent using Zero Runtime's routing rules. This is useful for building automated voice assistants, IVRs, or connecting callers to intelligent agents for support, sales, or other workflows.

## Routing Rule Configuration for Agents

When creating a routing rule, set the `dispatch` property to use the `agent` option. There are two deployment modes for agents:

* **Agent Cloud:** Use this if your agent is deployed on Zero Runtime Agent Cloud. You must provide the deployment ID of the agent.
* **Self-hosted Agent:** Use this if you are running the agent on your own infrastructure. You must provide the agentId of your self-hosted agent.

### Example: Routing Rule for Agent Cloud

```json theme={null}
{
  "gatewayId": "gateway_in_123456789",
  "name": "AI Sales Agent",
  "numbers": ["+14150001111"],
  "dispatch": {
    "room": {
      "type": "dynamic",
      "prefix": "participantNumber"
    },
    "agent": {
      "type": "cloud",
      "id": "deployment_abc123", // Deployment ID of the Agent Cloud agent
      "metadata": { "department": "sales" }
    }
  }
}
```

### Example: Routing Rule for Self-hosted Agent

```json theme={null}
{
  "gatewayId": "gateway_in_123456789",
  "name": "Self-hosted Support Agent",
  "numbers": ["+14150002222"],
  "dispatch": {
    "room": {
      "type": "dynamic",
      "prefix": "participantNumber"
    },
    "agent": {
      "type": "self",
      "id": "agent_789", // Agent ID of your self-hosted agent
      "metadata": { "department": "support" }
    }
  }
}
```

## Deployment Notes for Agent Cloud

When using an Agent Cloud deployment, the agent must read the following environment variables to join the correct Zero Runtime room:

* `ZRT_ROOM_ID`: The room ID the agent should join for the call session.
* `ZRT_AUTH_TOKEN`: The authentication token for joining the room.

Your agent should read these environment variables at runtime to connect to the correct room and handle the SIP call.

<Tip>
  You can configure agent routing rules via the Zero Runtime dashboard or using the API for automation and CI/CD workflows.
</Tip>

## API Reference

* [Building AI Agent for Telephony](/quickstarts/build-a-telephony-agent)
* [Create Routing Rule API](https://docs.videosdk.live/api-reference/realtime-communication/sip/routing-rules/create-routing-rule)
* [Fetch all Routing Rule API](https://docs.videosdk.live/api-reference/realtime-communication/sip/routing-rules/fetch-all-routing-rule)
* [Fetch a Routing Rule API](https://docs.videosdk.live/api-reference/realtime-communication/sip/routing-rules/fetch-routing-rule)
* [Update Routing Rule API](https://docs.videosdk.live/api-reference/realtime-communication/sip/routing-rules/update-routing-rule)
* [Delete Routing Rule API](https://docs.videosdk.live/api-reference/realtime-communication/sip/routing-rules/delete-routing-rule)
