victorious-monitor-50234
10/16/2025, 7:26 AMtall-airline-16756
10/16/2025, 7:26 AMtall-airline-16756
10/16/2025, 7:27 AMon_participant_attributes_changed function is a helpful event handler in LiveKit that kicks in whenever a participant's attributes get updated in a room. It’s a great way to stay in the loop and respond to changes in a participant’s key-value state, which everyone in the room can see.
Here’s a friendly breakdown of how it works:
• The handler takes in two parameters: changed_attributes (a dictionary showing which keys and values were updated) and participant (the Participant object whose attributes changed).
• You update attributes using the set_attributes method, and these changes automatically sync across all participants.
• If you want to delete an attribute, just set its value to an empty string—it’s that simple!
• Keep in mind, attributes aren’t meant for very frequent updates (like more than once every few seconds). For those, using data packets is a better choice.
• Also, participants need the canUpdateOwnMetadata permission in their access token to update their own attributes.
Here’s a gentle example in Python to illustrate:
@room.on("participant_attributes_changed")
def on_participant_attributes_changed(changed_attributes: dict[str, str], participant: rtc.Participant):
logging.info("participant attributes changed: %s %s", participant.attributes, changed_attributes)
This will log both the participant’s full current attributes and the specific changes made. If you have any questions or want me to walk you through anything else, just let me know—I’m here to help!
Sources: livekit-rtc/livekit/rtc/room.py | Participant attributes and metadata | LiveKit Docs