How can I add metadata to a session and later retr...
# ask-ai
b
How can I add metadata to a session and later retrieve it for analytics purposes?
t
Thanks for reaching out, Ezeugo. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! To help you add metadata to a session and easily retrieve it for analytics, here’s a friendly guide you can follow: Adding Metadata: • Participant-Level: You can include metadata right in the participant’s access token or update it after they join using the SDK. Usually, this metadata is a freeform string, often in JSON format. • Room-Level: If you want to set metadata for the entire room, you can do this through the server SDK. • Agent Jobs: When dispatching agents for tasks like transcription or analytics, don’t forget to pass along the relevant metadata. Retrieving Metadata: • Webhooks: A great way to capture metadata in real-time is by using webhooks like
PARTICIPANT_JOINED
. The payload you receive will include participant metadata. • Server SDK: You can also query participant metadata during or after the session using the server API, which is pretty handy. • Agents: Agents have the ability to read and export metadata while the session is ongoing. Just a quick note: Metadata isn’t directly available through the Analytics API, so for analytics purposes, it’s best to capture it via webhooks or the server SDK. If you need any more help or have questions, feel free to ask—I’m here to help! Sources: Participant attributes and metadata | LiveKit docs | Tests/PlayMode/LocalParticipantTests.cs | Agent dispatch | LiveKit Docs | SIP dispatch rule | LiveKit docs | Rooms, participants, and tracks | LiveKit docs
b
So where can I get room metadata after the room has ended?
t
I'm here to help you retrieve room metadata after the room has ended! You have a few options to consider: • ListRooms API: You can use this server-side API to fetch recently ended rooms. Each room object includes the
metadata
field. Just keep in mind, this works only for rooms still retained in the system. • Webhooks: Setting up a webhook for the
room_finished
event is a great way to capture and save room metadata right when the room ends. • External Storage: For keeping metadata accessible long-term, you might want to store it in your own database as the room ends—using webhooks or server-side logic. If you'd like, I’d be happy to walk you through setting up any of these methods. Just let me know which approach or tech stack you prefer, and we can take it from there together! Sources: livekit-api/src/services/room.rs | Room metadata | LiveKit Docs | Job lifecycle | LiveKit Docs | livekit-rtc/livekit/rtc/room.py