how do i set room attributes at the beginning of a...
# ask-ai
c
how do i set room attributes at the beginning of a room?
t
Thanks for reaching out, Bryce. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To set room attributes right when a room starts, you’ll want to use the server-side
CreateRoom
API to define the room’s metadata. Think of this metadata as a little string where you can store any app-specific info, and the cool part is everyone in the room can see it. Here’s a quick example using the Node.js Server SDK: Sources: Room metadata | LiveKit Docs | packages/livekit-server-sdk/src/RoomServiceClient.ts | README.md
c
I’m currently setting my attributes in my python backend. However, in the frontend attributes are always still show hasAttributes as false. What am I missing?
t
It looks like there might be a little mix-up: LiveKit doesn’t actually have a
hasAttributes
property. Instead, you can check if attributes are present by seeing whether the
attributes
map is empty or not. Here are some friendly tips to help you get everything synced up smoothly: • Make sure the backend sets attributes using
SetAttributes
in the token's video grant or through
UpdateParticipantRequest
. • On the frontend, keep an eye on
ParticipantEvent.AttributesChanged
so you can react to any updates right away. • Check the
attributes
object directly to see if attributes exist—for example, by using
Object.keys(participant.attributes).length > 0
. If you’re still running into trouble, just let me know! I’m here to help you figure it out. Sources: CHANGELOG.md | CHANGELOG.md | Sources/LiveKit/Participant/Participant.swift | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Parti...