I run agent with `agent_name="interviewer",` and t...
# ask-ai
n
I run agent with
agent_name="interviewer",
and then in the client token generation I set
Copy code
at.roomConfig = new RoomConfiguration({
        agents: [
            new RoomAgentDispatch({
                agentName: 'interviewer',
            }),
        ],
    });
but agent never joins the room. why?
t
Thanks for reaching out, Kaster. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
n
so?
t
Hey there! Would you like a hand with setting up explicit dispatch through the API, or maybe some help double-checking your token configuration to make sure the agent joins the room smoothly?
n
yes please. i set explicit dispatching by setting up the agent_name in python, then generated token on the fronend (react) with the same agent name, but agent never joins the room
t
Hey there! Let’s work together to figure out why the agent isn’t joining the room. Here are some steps you can follow: 1. Double-check Agent Configuration: Make sure the agent worker is running with the exact
agent_name
. Since explicit dispatch turns off automatic dispatch, the names need to match perfectly. 2. Look at Your Token Setup: In your React frontend, confirm that the token includes the agent dispatch details inside the
RoomConfiguration
. Here’s a quick example:
Copy code
const roomName = "my-room";
const agentName = "test-agent";

function createTokenWithAgentDispatch() {
    const token = api.AccessToken()
        .with_identity("my_participant")
        .with_grants(api.VideoGrants({ room_join: true, room: roomName }))
        .with_room_config(
            api.RoomConfiguration({
                agents: [
                    api.RoomAgentDispatch({ agent_name: agentName, metadata: "my_metadata" })
                ]
            })
        )
        .to_jwt();
    return token;
}
1. Keep an Eye on Connection Status: Use connection state indicators in your frontend to see how the agent’s connection is doing. Here’s an example snippet:
Copy code
useEffect(() => {
    const handleConnect = async () => {
        try {
            // Generate token and connect to room
        } catch (error) {
            console.error('Connection failed:', error);
        }
    };
}, []);
1. Watch Out for Common Issues: ◦ Make sure the room name exists and matches everywhere. ◦ Check that the
agent_name
is consistent in both your worker and token setup. ◦ Look out for any network connectivity hiccups. ◦ Confirm that token generation and validation are working as expected. 1. Handle Async Operations Properly: Be sure all async calls (like
room.connect()
) are awaited correctly. If you’re still stuck after trying these, feel free to share with me: • The exact error message or logs you’re seeing • Whether you’re using explicit dispatch via API or token-based dispatch • The specific versions of LiveKit and SDKs you’re working with Sources: Dispatching agents | LiveKit Docs | examples/agent-dispatch/index.ts | Web and mobile frontends | LiveKit Docs