use dispatch rule prefix for rooms (inbound) use a...
# ask-ai
m
use dispatch rule prefix for rooms (inbound) use agent names for outbound
g
To use a dispatch rule with a prefix for rooms in inbound calls, you can create a dispatch rule with the
dispatchRuleIndividual
type. This rule creates a new room for each caller, and you can specify a prefix for the room name using the
roomPrefix
option. Here's an example configuration:
Copy code
{
  "trunk_ids": [
    "<your-trunk-id>"
  ],
  "rule": {
    "dispatchRuleIndividual": {
      "roomPrefix": "call-"
    }
  }
}
For outbound calls using agent names, you can use the
AgentDispatchClient
to explicitly dispatch an agent to a room. Set the
agent_name
in the
WorkerOptions
to enable explicit dispatch. Here's a basic example:
Copy code
from livekit import api

room_name = "my-room"
agent_name = "test-agent"

async def create_explicit_dispatch():
    lkapi = api.LiveKitAPI()
    dispatch = await lkapi.agent_dispatch.create_dispatch(
        api.CreateAgentDispatchRequest(agent_name=agent_name, room=room_name)
    )
    print("created dispatch", dispatch)
Would you like more details on either setup? Sources: - SIP dispatch rule 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.