colossal-manchester-31772
08/12/2025, 10:47 PMtall-airline-16756
08/12/2025, 10:47 PMtall-airline-16756
08/12/2025, 10:48 PMagent_name
and adding some custom metadata. This metadata gets passed along to the agent as part of the job context.
• Dispatch on Participant Connection: You can set up a participant’s access token to automatically dispatch agents when they connect. This means specifying the agent name and metadata right in the RoomConfiguration
.
Both ways let you include custom attributes or identifiers in the metadata, which will be shared with other participants when they join. If you want, I’m happy to share more details or examples to help you get it set up!
Sources: Dispatching agents | LiveKit Docs | packages/livekit-server-sdk/src/AgentDispatchClient.ts | livekit-protocol/livekit/protocol/agent_dispatch.pycolossal-manchester-31772
08/12/2025, 10:53 PMagent_name
, but when this agent joins the room, I want other participants who are listening to the participant_connected
event to immediately know of some custom attributes for this agenttall-airline-16756
08/12/2025, 10:53 PMparticipant_connected
event instantly knows the custom attributes for an agent, you can add these attributes right into the agent's metadata during the dispatch process. This way, when the agent connects, everyone else can easily access that info.
Here’s a simple way to do it:
• Include Custom Metadata: When you dispatch the agent, just pop the custom attributes into the metadata
field. Like this:
const dispatch = await agentDispatchClient.createDispatch(
roomName,
agentName,
{ metadata: '{"custom_key": "custom_value"}' }
);
• Access Metadata in `participant_connected`: Once the agent joins the room, their metadata comes along with the participant object. Other participants can grab it through the metadata
property in the event handler.
room.on('participantConnected', (participant) => {
const customAttributes = JSON.parse(participant.metadata);
console.log(customAttributes.custom_key); // Outputs "custom_value"
});
Doing it this way means everyone immediately knows the custom attributes as soon as the agent connects. If you want me to walk you through anything else, just give me a shout!