melodic-garage-3113
07/10/2025, 6:29 PMtall-airline-16756
07/10/2025, 6:29 PMtall-airline-16756
07/10/2025, 6:30 PMmother-moon-*
) is not supported for agent dispatch rules.
For dynamically generated room names, the recommended methods are:
• Explicit Dispatch via API: Programmatically create dispatches for each room as they're created. This is done using the LiveKit API. For example:
dispatch = await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name=agent_name,
room=room_name,
metadata='{"user_id": "12345"}'
)
)
• Token-based Dispatch: Configure participant tokens to dispatch agents upon connection:
token = (
AccessToken()
.with_room_config(
RoomConfiguration(
agents=[
RoomAgentDispatch(agent_name="test-agent", metadata='{"user_id": "12345"}')
],
),
)
)
• SIP Dispatch Rules: Pattern-based (prefix) matching is only available for SIP/telephony use cases, not for general agent dispatch rules.
For testing, using a fixed room name is the simplest option. For production and dynamic room names, you should implement an external dispatcher or programmatically create agent dispatches via API as new rooms are created.
If you'd like step-by-step guidance to implement one of these solutions, let me know which method you're interested in.
Sources: packages/livekit-server-sdk/src/AgentDispatchClient.ts | Agent dispatch | LiveKit Docs | SIP dispatch rule | LiveKit Docsstocky-accountant-55381
07/10/2025, 11:28 PMtall-airline-16756
07/10/2025, 11:29 PM{
"iss": "your-api-key",
"sub": "participant-identity",
"exp": 1234567890,
"nbf": 1234567890,
"video": {
"room": "room-name",
"roomJoin": true
},
"roomConfig": {
"agents": [
{
"agentName": "your-agent-name",
"metadata": "{\"user_id\": \"12345\"}"
}
]
}
}
Let me explain the key fields that make this work:
• iss: Your LiveKit API key (think of it like your special pass)
• sub: The participant's identity (who's joining the room)
• video.room: The room name as a string
• video.roomJoin: Set to true
to give the green light to join
• roomConfig.agents: Your list of agents to dispatch, each with an agentName (matching your agent worker's name) and optional metadata
When you use this token to connect, the specified agent will automatically join the room. Want to bring in multiple agents? Just add more RoomAgentDispatch
objects to the agents
array.
Need help with encoding or have specific requirements? I'm all ears! Just drop me a message, and I'll be happy to help you out.
Sources: Agent dispatch | LiveKit Docs | packages/livekit-server-sdk/src/AccessToken.test.ts | Authentication | LiveKit Docs | livekit-api/livekit/api/access_token.pystocky-accountant-55381
07/10/2025, 11:33 PMtall-airline-16756
07/10/2025, 11:34 PMagentName
in your token's roomConfig.agents
is an exact match (yes, even down to capitalization!) with the agent_name
in your agent worker's WorkerOptions
.
• Agent Worker Running: Make sure your agent worker is up and running, connected to the LiveKit server, and successfully registered. Think of it like making sure all your team members are clocked in and ready to go.
• Token Configuration: Take a moment to verify that the token's roomConfig
looks perfect and that the agent name is spelled exactly the same way in both places. Tiny typos can be sneaky!
• Authentication: Confirm that your agent worker has the correct LIVEKIT_URL
, LIVEKIT_API_KEY
, and LIVEKIT_API_SECRET
. It's like making sure everyone has the right security badge to enter the building.
• Logs: Peek into your agent worker logs and look for registration, connection, and job assignment messages. The LiveKit server logs can also reveal any agent dispatch hiccups.
• Direct Dispatch Test: As a pro troubleshooting tip, try using the API to manually dispatch the agent to the room. This can help you figure out if the issue is with the token or something on the agent/service side.
Getting an agent dispatched via token is all about making sure everything is configured just right. If you're stuck, I'd be happy to help you dig into those logs or walk you through some test commands. You've got this!
Sources: Dispatching agents | LiveKit Docs | LiveKit Agents | README.md | Web and mobile frontends | LiveKit Docsstocky-accountant-55381
07/10/2025, 11:40 PMtall-airline-16756
07/10/2025, 11:41 PMcamelCase
exactly:
- Use agentName
(not agent_name
) in both your token and your agent worker configuration.
- Use roomConfig
(not room_config
).
• The roomConfig.agents
array must match exactly as expected (including naming and structure).
• The agent must be started with agent_name="agent-name"
in WorkerOptions.
• Optional: Add a metadata
field to your agent entry if you want to pass custom data but it is not required for dispatch.
I know these little details can drive you crazy! Here are some common gotchas that might be causing your silent dispatch failure:
• Case sensitivity or field naming differences (e.g. agentName
vs. agent_name
).
• Agent worker is NOT running with explicit agent_name
supplied (it must be).
Trust me, even the tiniest naming difference can totally block dispatch. Double-check that your JWT field names and values match up perfectly, and keep everything in that crisp camelCase
format.
If you've confirmed everything looks good and you're still stuck, no worries! The next step would be checking those agent worker/server logs for registration and job assignment events. I'd be happy to walk you through what to look for if you need an extra hand. We'll solve this together!
Sources: Authentication | LiveKit Docs | packages/livekit-server-sdk/src/AccessToken.test.ts | CHANGELOG.md | Dispatching agents | LiveKit Docsmelodic-garage-3113
07/11/2025, 3:42 AMtall-airline-16756
07/11/2025, 3:43 AMHS256
(HMAC SHA-256) for signing. Other algorithms won't work here.
• Token Structure and Claims: Your JWT needs to have all the key players: iss
, sub
, exp
, nbf
, and video
with roomJoin
and room
fields. Think of it like a guest list for your token party! 🎉
• Issuer Claim: The iss
in your token should match your LiveKit API key exactly.
• Encoding: When signing, make sure your API secret is encoded as bytes. No hex strings or other sneaky formats!
• Expiration: Just a quick check - your token isn't expired, right? Make sure the exp
claim is valid and in the future.
Here's how we can fix this:
1. Whip up a fresh test token using the LiveKit SDK or a reliable signing function.
2. Use the exact same API key and secret from your LiveKit dashboard - both for signing and server settings.
3. Do a quick verification that your signature is HS256
and your payload has all those required claims.
Pro tip: This error is almost always about a little mix-up with your token's secret, algorithm, or structure. We've got this! 💪
Sources: packages/livekit-server-sdk/src/AccessToken.ts | Authentication | LiveKit Docs