how would you manage room metadata updates in an o...
# ask-ai
s
how would you manage room metadata updates in an ongoing session? Can you give me an example of an agent that receives room metadata updates?
✅ 1
t
Thanks for reaching out, Roman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're asking how to manage room metadata updates during an ongoing session and for an example agent that receives those updates. I’ll cover what you can do and give a concise example pattern an agent can use. Quick summary • Room metadata is a string property of a Room that can be updated during a live session. • Update it from a backend/agent using the server SDK (e.g.,
update_room_metadata()
/
updateRoomMetadata()
). • Agents/clients typically observe changes either by: ◦ Receiving a data message or custom signal broadcast when metadata changes, or ◦ Getting webhook notifications on the server side and then informing connected agents/clients. • There is no confirmed dedicated real-time room-metadata event for agents; use data messages or webhooks to propagate changes to agents in real time. Example pattern: agent that receives room-metadata updates 1. Backend: update room metadata via server SDK
Copy code
# (server-side) update room metadata
await api_client.room.update_room_metadata(
    room="my-room",
    metadata='{"session_phase":"recording"}'
)
# After updating, broadcast a small data message (optional) to notify participants
1. Agent: connect to the room and listen for data messages (or react to webhook-triggered messages)
Copy code
async def my_agent(ctx: JobContext):
    await ctx.connect(auto_subscribe=True)

    # read initial metadata
    current_metadata = ctx.room.metadata
    print("initial metadata:", current_metadata)

    # listen for data messages (used to notify about metadata changes)
    @ctx.room.on("data_received")
    def on_data(sender, payload, kind):
        # parse payload that indicates metadata update
        if payload.get("type") == "room_metadata_updated":
            new_meta = payload.get("metadata")
            print("room metadata updated:", new_meta)
            # react to the new metadata here
Alternative approach (server -> agent via webhook) • Server receives webhook like
room_updated
(or similar). • Server forwards the change to agents via an internal API or emits a data message into the room so agents/clients receive it. If you want, I can: • Provide a full runnable example in your preferred language (Node, Python, or Ruby). • Show how to format the data message payload and secure the notification flow. Which language and delivery method do you prefer: direct data messages inside the room, or webhook -> server-forwarded notifications to agents? Sources: client-sdk-js | livekit/livekit_composite | DeepWiki | server-sdk-ruby | livekit/livekit_composite | DeepWiki | Job lifecycle | LiveKit Documentation, with interactive elements