how to gracefull delete room when user hangs up an...
# ask-ai
l
how to gracefull delete room when user hangs up and RoomInputOptions.close_on_disconnect=False
t
Thanks for reaching out, Deepak. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When a user hangs up and
RoomInputOptions.close_on_disconnect
is set to
False
, you’ll want to manually delete the room to keep everything running smoothly. Here’s a simple way to handle it: 1. First, detect when the user hangs up using callbacks or events. 2. Next, make sure any ongoing agent speech finishes by calling
wait_for_playout()
. 3. Finally, use the
delete_room
API through the LiveKit server to close the room for everyone involved. This method helps keep your rooms neat and tidy, avoiding problems like participants sticking around or extra audio in recordings. If you’d like, I’m here to help you implement this step-by-step—just let me know! Sources: Agents telephony integration | LiveKit Docs | Inside a session | LiveKit Docs | Inside a session | LiveKit Docs | telephony/sip_lifecycle.py | agent.py