Skip to main content

Routing SIP Calls to Agents

You can route inbound or outbound SIP calls directly to an AI agent using VideoSDK'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:

  • Cloud Agent: Use this if your agent is deployed on VideoSDK 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 Cloud Agent

{
"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 cloud agent
"metadata": { "department": "sales" }
}
}
}

Example: Routing Rule for Self-hosted Agent

{
"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 Cloud Agents

When using a cloud agent deployment, the agent must read the following environment variables to join the correct VideoSDK room:

  • VIDEOSDK_ROOM_ID: The room ID the agent should join for the call session.
  • VIDEOSDK_TOKEN: The authentication token for joining the room.

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

tip

You can configure agent routing rules via the VideoSDK dashboard or using the API for automation and CI/CD workflows.

API Reference

Got a Question? Ask us on discord