busy-breakfast-32623
09/05/2025, 10:37 AMtall-airline-16756
09/05/2025, 10:37 AMtall-airline-16756
09/05/2025, 10:37 AMagent_name in the server-side WorkerOptions so you can explicitly dispatch it.
2. Create a participant token using RoomConfiguration.agents to specify which agent to dispatch.
3. Connect to the room using the React SDK with that token, and the agent will join automatically.
If you'd like, I can walk you through the backend token setup or help you integrate this into your React app—just let me know!
Sources: TEMPLATE.md | templates.yaml | packages/livekit-server-sdk/src/AgentDispatchClient.ts | Agent dispatch | LiveKit Docs | React quickstart | LiveKit Docsbusy-breakfast-32623
09/05/2025, 10:39 AMtall-airline-16756
09/05/2025, 10:39 AMRoomConfiguration with RoomAgentDispatch to the payload. This way, the specified agent will be dispatched as soon as the participant connects to the room.
Here’s a friendly tweak you can make to your function:
def generate_access_token(room_name: str, participant_name: str, agent_name: str) -> str:
now = int(time.time())
exp = now + 3600 # 1 hour
payload = {
"iss": LIVEKIT_API_KEY,
"sub": participant_name,
"aud": "livekit",
"exp": exp,
"nbf": now,
"video": {
"room": room_name,
"roomJoin": True,
"roomList": True,
"roomRecord": True,
"roomAdmin": True,
"roomCreate": True,
"canPublish": True,
"canSubscribe": True,
"canPublishData": True,
"canUpdateOwnMetadata": True,
"ingressAdmin": True,
"hidden": False,
"recorder": False
},
"roomConfig": {
"agents": [
{
"agentName": agent_name,
"metadata": "{}" # Optional metadata
}
]
}
}
return jwt.encode(payload, LIVEKIT_API_SECRET, algorithm="HS256")
So, in this updated version, you pass in the agent_name as an argument and add it under roomConfig inside agents. This makes sure the right agent gets dispatched to the room whenever the token is used.
If anything’s unclear or you want a hand with anything else, just let me know—I’m here to help!