ancient-judge-59849
05/13/2025, 1:10 PMtall-airline-16756
05/13/2025, 1:10 PMtall-airline-16756
05/13/2025, 1:11 PMasync def entrypoint(ctx: JobContext):
# connect to the room
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
# wait for the first participant to arrive
participant = await ctx.wait_for_participant()
# customize behavior based on the participant
print(f"connected to room {ctx.room.name} with participant {participant.identity}")
# inspect the current value of the attribute
language = participant.attributes.get("user.language")
# listen to when the attribute is changed
@ctx.room.on("participant_attributes_changed")
def on_participant_attributes_changed(changed_attrs: dict[str, str], p: rtc.Participant):
if p == participant:
language = p.attributes.get("user.language")
print(f"participant {p.identity} changed language to {language}")
This code demonstrates how to access and respond to a participant's attributes, such as language, to customize agent behavior dynamically. Let me know if you need further assistance!
Sources: Inside a session | LiveKit Docs | Inside a session | LiveKit Docs