quick-gpu-24854
10/17/2025, 10:57 AMtall-airline-16756
10/17/2025, 10:57 AMtall-airline-16756
10/17/2025, 10:58 AMdefineAgent()! You can easily access the attributes property of participant objects right within your agent's entry function. Here's a helpful example to guide you:
export default defineAgent({
entry: async (ctx: JobContext) => {
await ctx.connect();
// Wait for a participant to join
const participant = await ctx.waitForParticipant();
// Access participant attributes
console.log('Participant attributes:', participant.attributes);
// Access specific attribute values
const specificAttribute = participant.attributes['your-attribute-key'];
console.log('Specific attribute:', specificAttribute);
},
});
Also, if you'd like to access attributes from all participants in the room, here's how you can do that:
export default defineAgent({
entry: async (ctx: JobContext) => {
await ctx.connect();
// Access room and its participants
const room = ctx.room;
// Iterate through all participants and their attributes
room.remoteParticipants.forEach((participant) => {
console.log(`Participant ${participant.identity} attributes:`, participant.attributes);
});
// Access local participant attributes
console.log('Local participant attributes:', room.localParticipant.attributes);
},
});
Just a little note: participant attributes are a string key-value store that you can set in the participant's access token, and they’ll be synchronized automatically to everyone in the room. If you have any questions or want to dive deeper, please don’t hesitate to ask—I’m here to help!
Sources: Rooms, participants, and tracks | LiveKit Docs | src/agent.ts | Job lifecycle | LiveKit Docs | Participant attributes and metadata | LiveKit Docs