When I receive the webhook for room finished, I wo...
# ask-ai
c
When I receive the webhook for room finished, I would like to have data in the event metadata that I’ve written from my agent using the python livekit agent SDK. Is that possible?
t
Thanks for reaching out, Guillaume. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m glad you asked about the "room finished" webhook event! It includes a
Room
object that holds details about the room. When you use the Python LiveKit Agent SDK, you can add metadata like room metadata, participant metadata, or agent dispatch metadata. That said, it’s not 100% clear if this metadata always shows up in the webhook payload. Here’s a simple way to check: 1. Set some room metadata using the server APIs or the Python SDK. 2. Trigger a "room finished" event and watch the webhook payload that comes through. 3. Look closely at the payload to see if the metadata appears inside the
Room
object. If you’d like, I’m here to help you walk through this testing or answer any questions about specific metadata types you’re working with. Just let me know! Sources: protobufs/livekit_webhook.proto | livekit-rtc/livekit/rtc/participant.py | Room metadata | LiveKit Docs
c
the python SDK doesn’t seem to be able to set the room metadata, it’s a read only property it seems
t
Hi there! Just to help you out, room metadata in LiveKit can only be set through server-side APIs, like the Python SDK, and unfortunately, clients can't write to it directly. But don’t worry—I’ll guide you through how to set or update room metadata: 1. During Room Creation: You can use the
CreateRoomRequest
to set metadata right when you create the room. Here’s a quick example:
Copy code
from livekit.api import LiveKitAPI, CreateRoomRequest

lkapi = LiveKitAPI(
    url="your-livekit-url",
    api_key="your-api-key",
    api_secret="your-api-secret"
)

create_room_request = CreateRoomRequest(
    name="my-room",
    metadata="initial room metadata"
)

room = await lkapi.room.create_room(create=create_room_request)
2. After Room Creation: If you want to update the metadata later on, you can use the
update_room_metadata
method. Here’s how:
Copy code
from livekit.api import LiveKitAPI, UpdateRoomMetadataRequest

update_request = UpdateRoomMetadataRequest(
    room="my-room",
    metadata="updated room metadata"
)

updated_room = await lkapi.room.update_room_metadata(update=update_request)
Just a quick note: room metadata is visible to all participants and has a size limit of 64 KiB. If you have any questions or need a hand with anything else, feel free to ask—I’m here to help! Sources: livekit-rtc/livekit/rtc/_proto/room_pb2.pyi | Room metadata | LiveKit Docs
c
how long does it take for a room to close after the last participant left?
t
Just so you know, a room in LiveKit automatically closes 20 seconds after the last participant leaves. This timing is managed by the
departure_timeout
parameter, which you can easily customize when creating a room through the server API. If you'd like a hand adjusting this timeout or if you have any other questions, please feel free to reach out—I’m here to help! Sources: protobufs/livekit_room.proto | Rooms, participants, and tracks | LiveKit docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | Core Platform Architecture & Authentication | livekit/livekit_composite | D... | pkg/service/roommanager.go
c
it’s weird I’m testing the webhook right now and I’m not receiving the room_finished event
t
I understand how important it is to receive the
room_finished
webhook event, so let’s work through some troubleshooting steps together: 1. Verify Webhook Configuration: Please double-check that the webhook URL is correctly set up in your LiveKit dashboard or server configuration file. 2. Confirm Room Closure: Keep in mind that this event only triggers when a room closes, which happens after all participants have left and the departure timeout (default 20 seconds) has passed. 3. Check Event Filtering: Make sure the
room_finished
event isn’t being filtered out by any event filters in your webhook setup. 4. Validate Webhook Endpoint: It’s important that your endpoint is accessible and responds with a 200 OK status, as repeated failures might stop events from being delivered. 5. Inspect Logs: Try enabling debug logging on your LiveKit server to see if the event is being queued for delivery. 6. Verify Security: Don’t forget to confirm that your webhook receiver is correctly validating the
Authorization
header and the SHA-256 checksum. If you’ve gone through these steps and are still having trouble, please reach out—I’m here to help you get this sorted! Sources: Webhook & Event System | livekit/livekit_composite | DeepWiki | test/webhook_test.go | examples/webhooks-nextjs/README.md | Webhooks | LiveKit Docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki
c
what about participantInfo, is there a way to update them in a way that’ll be reflected in the webhook event?
t
Great news! You can update ParticipantInfo in LiveKit, and these changes will show up in webhook events. Here’s how it works: • You can use the
UpdateParticipantRequest
through the server API to update participant metadata. This will refresh the
metadata
field in ParticipantInfo. • Webhook events such as
participant_joined
and
participant_left
will then include the updated ParticipantInfo. If you’d like, I’m here to help you navigate the API or assist with any specific updates you want to make! Sources: Managing participants | LiveKit docs | livekit/livekit_webhook.pb.go | pkg/telemetry/events.go | Participant attributes and metadata | LiveKit docs