big-microphone-99982
11/24/2025, 2:55 AMfunction createParticipantToken(
userInfo: AccessTokenOptions,
roomName: string,
apiKey: string,
apiSecret: string,
agentName?: string
): Promise<string> {
const at = new AccessToken(apiKey, apiSecret, {
...userInfo,
ttl: "15m",
});
const grant: VideoGrant = {
room: roomName,
roomJoin: true,
canPublish: true,
canPublishData: true,
canSubscribe: true,
};
at.addGrant(grant);
if (agentName) {
at.roomConfig = new RoomConfiguration({
agents: [{ agentName }],
});
}
return at.toJwt();
}tall-airline-16756
11/24/2025, 2:55 AMtall-airline-16756
11/24/2025, 2:55 AMmetadata field on the AccessToken becomes the participant’s initial metadata when they join the room. RoomConfiguration is for room-level settings (like agent dispatch) and should not be used for participant-specific metadata.
Example: include metadata when creating the token:
const at = new AccessToken(apiKey, apiSecret, {
...userInfo,
metadata: 'your metadata here',
ttl: '15m',
}); Sources: Authentication | LiveKit docs | Participant attributes and metadata | LiveKit docs | Managing participants | LiveKit docs