stale-toddler-98427
08/27/2025, 7:28 PM+1-555-0101 -> Agent_A
• Call to +1-555-0102 -> Agent_B
• ...all on the same trunk.
My understanding is that I can't create a separate dispatch rule for each number on the same trunk, because the rules would conflict. It seems the inboundNumbers field is an allowlist for the caller's number (From), not the number being called (To).tall-airline-16756
08/27/2025, 7:28 PMtall-airline-16756
08/27/2025, 7:28 PMnumbers array when you create it.
2. Use Dispatch Rules:
Create dispatch rules that send calls to rooms with number-specific prefixes. For example, calls to +1-555-0101 can go to a room named call-5550101, and calls to +1-555-0102 can go to call-5550102.
3. Implement Agent Dispatch Logic:
In your agent worker, check the SIP headers (like the To header) or room names to figure out which number was called. Then, send the right agent to that room.
This way, you can easily manage call routes and connect callers to the right agents based on the number they dialed. Sources: Accepting incoming calls | LiveKit Docs | SIP inbound trunk | LiveKit Docs | Agent dispatch | LiveKit Docs | SIP inbound trunk | LiveKit Docs | livekit/livekit_sip.pb.gostale-toddler-98427
08/27/2025, 7:30 PMtall-airline-16756
08/27/2025, 7:30 PM{
"rule": {
"dispatchRuleCallee": {
"roomPrefix": "number-",
"randomize": false
}
},
"name": "My dispatch rule"
}
Explanation:
- This rule creates a room named number-<called-number> for each call.
- The randomize field is set to false, so the room names stay predictable and easy to follow.
If you'd like to send specific agents to these rooms, you can add a roomConfig with their details:
{
"rule": {
"dispatchRuleCallee": {
"roomPrefix": "number-",
"randomize": false
}
},
"name": "My dispatch rule",
"roomConfig": {
"agents": [
{
"agentName": "inbound-agent",
"metadata": "job dispatch metadata"
}
]
}
}
This way, calls get routed to rooms based on the number called, and you can easily assign the right agents if you want. Let me know if you need a hand setting this up! Sources: SIP dispatch rule | LiveKit Docsstale-toddler-98427
08/27/2025, 7:35 PMtall-airline-16756
08/27/2025, 7:35 PMstale-toddler-98427
08/27/2025, 7:36 PM+1-555-0101, it should use a rule that dispatches Agent_A.
Rule 2: If a call comes in for +1-555-0102 on the same trunk, it should use a different rule that dispatches Agent_B.tall-airline-16756
08/27/2025, 7:37 PM{
"dispatch_rule": {
"trunk_ids": [
"trunk-123"
],
"inbound_numbers": [
"+15550101"
],
"rule": {
"dispatchRuleDirect": {
"roomName": "agent-a-room"
}
},
"roomConfig": {
"agents": [
{
"agentName": "Agent_A",
"metadata": "Handles calls for +1-555-0101"
}
]
}
}
}
Dispatch Rule 2: For calls to +1-555-0102, route to Agent_B:
{
"dispatch_rule": {
"trunk_ids": [
"trunk-123"
],
"inbound_numbers": [
"+15550102"
],
"rule": {
"dispatchRuleDirect": {
"roomName": "agent-b-room"
}
},
"roomConfig": {
"agents": [
{
"agentName": "Agent_B",
"metadata": "Handles calls for +1-555-0102"
}
]
}
}
}
Explanation:
- Both rules use the same trunk (trunk-123).
- Each rule has its own inbound_numbers to match the specific called number.
- The roomConfig assigns the right agents to handle calls for each number.
This way, calls coming into different numbers on the same trunk get routed to the right agents, making sure everything runs smoothly. Sources: SIP dispatch rule | LiveKit Docs | SIP inbound trunk | LiveKit Docs | sip/sip.gostale-toddler-98427
08/27/2025, 7:39 PMtall-airline-16756
08/27/2025, 7:39 PMstale-toddler-98427
08/27/2025, 7:45 PMtall-airline-16756
08/27/2025, 7:45 PM