I am providing agent name in workeroptions and the...
# ask-ai
m
I am providing agent name in workeroptions and then created dispatch rule with room dispatch but still agent is not getting dispatched
t
Thanks for reaching out, Mridul. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
m
?
t
Hey there! Could you help me understand exactly what kind of help you’re looking for? For instance, are you interested in an example of how to explicitly dispatch an agent using the API or room configuration, or is there something else in the process you'd like a hand with?
m
I am providing agent name in workeroptions and then created dispatch rule with room dispatch but still agent is not getting dispatched
t
Hey there! Just a quick heads-up: when you set the
agent_name
in
WorkerOptions
, automatic dispatch gets turned off. To make sure your agent actually gets dispatched, you'll want to use one of these clear methods: • Calling the AgentDispatchService API to create a dispatch request with the agent name and room. • Adding the agent name in the room configuration when you generate the participant's access token. • Setting the agent name within your SIP dispatch rules. Also, it’s a good idea to double-check that: • Your agent is up and running, registered with the LiveKit server. • The room exists or has been created before you try dispatching the agent. If any of this feels tricky or you want a hand walking through the steps, just give me a shout—I’m here to help!
m
I have added agent_name like this - cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, agent_name=“odespa_agent”)) I have created Dispatch rule like this - dispatch_request_1 = api.CreateSIPDispatchRuleRequest( rule=api.SIPDispatchRule( dispatch_rule_individual=api.SIPDispatchRuleIndividual( room_prefix=“odespa_agent-call-” ) ), room_config=api.RoomConfiguration( agents=[ api.RoomAgentDispatch( agent_name=“odespa_agent”, metadata=‘{“orgId”: “”, “target_agent”: “odespa_agent”}’ ) ] ), name=“ODESPA Agent Dispatch Rule”, trunk_ids=[trunk_response.sip_trunk_id], inbound_numbers=[“”], hide_phone_number=False ) Created trunk like this - friendly_name = str(os.getenv(‘LIVEKIT_TRUNK_FRIENDLY_NAME’)) # trunk = SIPInboundTrunkInfo( # name = friendly_name, # numbers = [str(os.getenv(‘VVA_PHONE_NUMBER’))], # ) # request = CreateSIPInboundTrunkRequest( # trunk = trunk # ) # trunk_response = await livekit_api.sip.create_sip_inbound_trunk(request)
t
Thanks so much for sharing those details! Based on what you’ve got set up, here are a few important things to double-check: • Agent Name: Make sure the
agent_name
in
WorkerOptions
exactly matches the one used in your dispatch rule. • Explicit Dispatch: Since
agent_name
turns off automatic dispatch, be sure your dispatch rule is set up to explicitly assign the agent to the room. • Dispatch Rule Validation: Take a look for any conflicts in your dispatch rules, like duplicate trunk IDs, inbound numbers, or priority mix-ups. • Trunk Configuration: Double-check that the trunk ID and inbound numbers are correct and align with your dispatch rule. • Agent Registration: Confirm the agent is running and properly registered with the LiveKit server. If you want, I’m happy to walk you through validating your dispatch rules or help troubleshoot any specific parts of your setup. Just let me know how you’d like to move forward! Sources: sip/sip.go | livekit-protocol/livekit/protocol/sip.pyi | SIP Integration | livekit/livekit_composite | DeepWiki | Agents telephony integration | LiveKit Docs | Dispatching agents | LiveKit Docs
Hey there! To check if an agent is registered in LiveKit, here are a few things you can look at: • Registration Logs: From the log you shared, it looks like the worker has been registered successfully. For example, the entry "registered worker {id: 'AW_UbPhWfuf7TUF', url: 'wss://personal-vva-demo-beta-4x6xdzil.livekit.cloud', region: 'India', protocol: 16}" confirms this. • WebSocket Connection: If the agent keeps an active WebSocket connection with the server, it means they’re registered and connected. • Server Acknowledgment: When registration goes through, the server sends a
RegisterWorkerResponse
message. This happens behind the scenes in the agent’s setup. So, based on what you’ve shared, your agent seems to be registered just fine. If you want to double-check anything else or run into any issues, just give me a shout—I’m here to help! Sources: test/agent.go | livekit-agents/livekit/agents/worker.py | Anatomy of an Agent | LiveKit Docs | Anatomy of an Agent | LiveKit Docs | Anatomy of an Agent | LiveKit Docs