proud-whale-10574
08/21/2025, 12:59 AMtall-airline-16756
08/21/2025, 12:59 AMtall-airline-16756
08/21/2025, 12:59 AMroom.localParticipant.setMetadata(JSON.stringify({ key: 'value' }));
• To set attributes:
room.localParticipant.setAttributes({ key1: 'value1', key2: 'value2' });
2. Using Server APIs:
• Use the UpdateParticipant API to update metadata:
data, err := json.Marshal(values)
_, err = c.UpdateParticipant(context.Background(), &livekit.UpdateParticipantRequest{
Room: roomName,
Identity: identity,
Metadata: string(data),
})
3. Initial Metadata via Access Token:
You can set initial metadata right when you generate the participant’s access token, so those values are ready as soon as they connect.
Just a heads up: make sure the participant’s access token includes the canUpdateOwnMetadata permission. Also, remember that metadata and attributes have a 64 KiB size limit.
If you have any questions or want a hand with this, just let me know—I’m here to help!
Sources: lib/src/participant/local.dart | livekit-rtc/livekit/rtc/participant.py | Runtime/Scripts/Participant.cs | Participant attributes and metadata | LiveKit Docs | Sources/LiveKit/Participant/LocalParticipant.swiftproud-whale-10574
08/21/2025, 1:05 AMtall-airline-16756
08/21/2025, 1:05 AM# Python Example
await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name="test-agent",
room="my-room",
metadata='{"userId": "123", "name": "John"}'
)
)
// Node.js Example
const dispatch = await agentDispatchClient.createDispatch(roomName, agentName, {
metadata: '{"userId": "123", "name": "John"}',
});
2. Dispatch on Participant Connection (Token-based Dispatch):
If you’re generating a participant access token, you can set up the room to automatically dispatch an agent with metadata like this:
# Python Example
AccessToken()
.with_room_config(
RoomConfiguration(
agents=[RoomAgentDispatch(agent_name="test-agent", metadata='{"context": "support_call"}')]
),
)
// Node.js Example
at.roomConfig = new RoomConfiguration({
agents: [
new RoomAgentDispatch({
agentName: agentName,
metadata: '{"context": "user_support"}',
}),
],
});
Accessing Metadata in the Agent:
Once your agent is dispatched, you can easily grab the metadata from the agent’s JobContext like this:
async def entrypoint(ctx: JobContext):
logger.info(f"job metadata: {ctx.job.metadata}")
If anything’s unclear or you want to dive deeper, just let me know—I’m here to help!
Sources: Dispatching agents | LiveKit Docs | livekit-protocol/livekit/protocol/agent_dispatch.pyi | examples/agent-dispatch/index.ts | Agent dispatch | LiveKit Docsproud-whale-10574
08/21/2025, 1:07 AMtall-airline-16756
08/21/2025, 1:07 AMUpdateParticipant API to tweak the participant's metadata like this:
# Example in Go
data, err := json.Marshal(values)
_, err = c.UpdateParticipant(context.Background(), &livekit.UpdateParticipantRequest{
Room: roomName,
Identity: identity,
Metadata: string(data),
})
This way, you can set or update the metadata for the dispatched agent’s participant representation in the room.
If you have any questions or want me to walk you through it, just let me know—I’m here to help!
Sources: Dispatching agents | LiveKit Docs | protobufs/livekit_agent_dispatch.proto | Managing participants | LiveKit Docs | livekit-rtc/livekit/rtc/participant.py | Dispatching agents | LiveKit Docs