I am trying to assigna specific agent to a convers...
# ask-ai
a
I am trying to assigna specific agent to a conversation, I am using the agent id, this does not seem to work, what am I doing wrong ?
Copy code
livekit_api.AccessToken(config.livekit_api_key, config.livekit_api_secret)
        .with_identity(candidate_id)
        .with_ttl(timedelta(minutes=15))
        .with_grants(livekit_api.VideoGrants(room_join=True, room=room_name, can_publish=True, can_subscribe=True))
        .with_room_config(livekit_api.RoomConfiguration(agents=[livekit_api.RoomAgentDispatch(agent_name='CA_qG9BhWGxdBGw')]))
        .to_jwt()
t
Thanks for reaching out, Anne. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! It looks like you’re using an agent ID to assign a specific agent to a conversation. From what I’ve seen in the LiveKit docs, they usually talk about dispatching agents by agent names. Could you help me understand if you meant the agent name instead of the agent ID? Also, are you working with a particular version of the LiveKit framework that supports using agent IDs for dispatching? I’m here to help figure this out with you! Sources: Agent dispatch | LiveKit Docs | Dispatching agents | LiveKit Docs | livekit-api/livekit/api/agent_dispatch_service.py
a
where do I find the agent name?
t
Hey there! The agent name is set in the
agent_name
field when you're configuring
WorkerOptions
in your agent's code. This is super important for explicit agent dispatch, which basically helps you control how agents get assigned to rooms. Here’s how you can find or set the agent name: 1. In your agent implementation, just set the
agent_name
parameter inside
WorkerOptions
. For example:
Copy code
# Python example
opts = WorkerOptions(
    agent_name="test-agent",
)

// Node.js example
const opts = new WorkerOptions({
    agentName: "test-agent",
});
1. Make sure the agent name matches both in your agent code and in any dispatch rules you set up, like in
RoomAgentDispatch
or the access token. If you get stuck or want a hand with setting or finding the agent name, just give me a shout—I’m here to help! Sources: Agent dispatch | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | JobRequest | LiveKit Agents | templates.yaml | Dispatching agents | LiveKit Docs
a
Can you show me an agent code example where this name is set? in pyhon
t
Here’s a friendly example of Python agent code where the
agent_name
is set inside `WorkerOptions`:
Copy code
if __name__ == "__main__":
    cli.run_app(
        WorkerOptions(
            entrypoint_fnc=entrypoint,
            agent_name="my-telephony-agent"  # This enables explicit dispatch
        )
    )
A few things to keep in mind: • Setting
agent_name
turns off automatic dispatch and lets you control dispatch explicitly through the API or room settings. • Make sure the
agent_name
matches the name you use in your dispatch rules or access tokens. • This is super handy for telephony integrations, helping to prevent any unexpected agent behavior. If you’d like a hand with this or want to see more examples, just give me a shout! Sources: evaluating-agents/agent_evals.py | Making calls using SIP | LiveKit Docs | Dispatching agents | LiveKit Docs | examples/agent_dispatch.py | Agent dispatch | LiveKit Docs