what is the difference between events participant_...
# ask-ai
w
what is the difference between events participant_connected and participant_attributes_changed?
t
Thanks for reaching out, Arthur. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just wanted to clarify the difference between the participant_connected and participant_attributes_changed events in LiveKit—they each have their own role: • participant_connected: This pops up when a new remote participant joins the room after you’ve connected. It gives you some basic info about the newcomer, like their identity and initial details. • participant_attributes_changed: This one happens whenever a participant’s attributes (those app-specific key-value pairs) get updated. It lets you know exactly what changed, showing both the old and new values, plus which participant it’s about. So, to sum it up: participant_connected is all about someone new joining the party, while participant_attributes_changed is your heads-up when someone’s details get updated.
w
which one will be used to determine if a caller has entered the room and is currently actively listening to the convo?
t
Hey there! To figure out if someone has joined the room and is actually listening in, here’s a simple way to check: 1. Detect Room Entry: Keep an eye on the
participant_connected
event—that’s how you know when someone new has popped into the room. This lets you confirm they’re there. 2. Check Audio Track Subscription: Take a look to see if the participant has any active audio tracks subscribed. If they do, it’s a good sign they’re tuned in and listening:
Copy code
// Check if a specific participant has audio tracks
const participant = room.remoteParticipants.get(participantIdentity);
if (participant?.audioTrackPublications.size > 0) {
    console.log(`${participant.identity} is currently listening`);
}
Just a heads up—LiveKit doesn’t have a direct “listening” status, but if someone’s in the room and has active audio tracks, it’s a pretty solid clue they’re paying attention. Sources: src/room/events.ts