Skip to main content

Setting Up Routing Rules

Routing rules in VideoSDK allow you to control how inbound and outbound SIP calls are routed to specific rooms or agents based on the configurations you define. With routing rules, you can flexibly direct calls according to your business logic, such as sending support calls to a particular room or routing sales calls to a specific agent.

You can configure routing rules using the VideoSDK dashboard or programmatically via the API.

Configure routing rules using dashboard

The dashboard provides an intuitive interface to create and manage routing rules:

  1. Navigate to the SIP section and select "Routing Rules".
  2. Click "Add Routing Rule".
  3. Fill in the required details:
    • Gateway: Select the SIP gateway (inbound or outbound) for this rule.
    • Name: Enter a descriptive name for the rule.
    • Numbers: Specify the phone numbers this rule applies to.
    • Dispatch: Choose how calls should be routed (to a room or agent).
    • Room Options: For room dispatch, select static or dynamic, and configure prefix, room ID, and PIN as needed.
    • Agent Options: For agent dispatch, select agent type and provide agent ID and metadata.
    • Additional Options: Set tags, metadata, and whether to hide the caller's phone number.
  4. Save the rule. The new routing rule will be applied immediately.

Configure routing rules using API

You can also create routing rules using the API for automation or advanced use cases.

Endpoint Parameters:

  • gatewayId: The ID of the gateway this routing rule belongs to.
  • name: A descriptive name for the routing rule.
  • numbers: Array of phone numbers associated with this rule.
  • dispatch: Defines how calls should be dispatched (to a room or agent).
  • hidePhoneNumber: (Optional) Hide the caller's phone number.
  • metadata: (Optional) Custom metadata key-value pairs.
  • tags: (Optional) Custom tags for the rule.
POST
|
https://api.videosdk.live/v2/sip/routing-rules
import fetch from 'node-fetch';
const options = {
method: "POST",
headers: {
"Authorization": "$YOUR_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
"gatewayId" : "gateway_in_123456789",
"name" : "Support Line Rule",
"numbers" : ["+14150001111","+14150002222"],
"dispatch" : {"room":{"type":"dynamic","prefix":"prefix","id":"room_123","pin":"4321"},"agent":{"type":"cloud","id":"agent_789","metadata":{"department":"sales"}}}
}),
};
const url= `https://api.videosdk.live/v2/sip/routing-rules`;
const response = await fetch(url, options);
const data = await response.json();
console.log(data);

API Reference

Got a Question? Ask us on discord