When I do a warm handoff using the move participan...
# ask-ai
s
When I do a warm handoff using the move participant api, then the livekit room continues to exist with two SIP participants and no agents. How can the room exit? We do not want to incur cost of livekit room since our job is done here
t
Thanks for reaching out, Saurabh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To make sure the LiveKit room closes smoothly after a warm handoff using the MoveParticipant API, you have two friendly options: automatic room deletion or manual deletion. Let me walk you through the steps: Automatic Room Deletion: 1. Once you’ve called the MoveParticipant API, set up an event handler for the
participant_disconnected
event in the destination room. 2. In that event handler, check if the only remaining participants are SIP participants or others, and then go ahead and trigger the room deletion. Manual Room Deletion: If you prefer, you can delete the room yourself using the Room Service API. Here’s a simple example in Python:
Copy code
await room_service.delete_room(DeleteRoomRequest(room="room-name"))
If you’d like, I’m here to help with more details or walk you through the implementation—just let me know! Sources: livekit-api/src/services/room.rs | Job lifecycle | LiveKit Docs | Connecting to LiveKit | LiveKit Docs | examples/warm-transfer/README.md | livekit-api/livekit/api/room_service.py
s
Will deleting the room with SIP participants close the connection between them?
t
Absolutely! When you delete a LiveKit room that has SIP participants, it will close the connection for everyone involved. This means all participants, including those on SIP, will be disconnected. You'll also see a
Disconnected
event sent to all participants, with the reason being
ROOM_DELETED
. If you have any more questions or need a bit more help, please don’t hesitate to ask—I’m here for you! Sources: Managing rooms | LiveKit Docs | Connecting to LiveKit | LiveKit Docs | Job lifecycle | LiveKit Docs | telephony/sip_lifecycle.py
s
But we want the SIP participants to continue having the conversation
t
I’m happy to help you keep your SIP participants connected even after deleting a LiveKit room! To make sure their conversation continues smoothly, you can transfer them to another destination before deleting the room. Here’s a simple way to do that: Steps to Transfer SIP Participants: 1. Use the
transfer_sip_participant
API to move the SIP participants to another phone number or SIP destination. For example:
Copy code
# Transfer SIP participant
ctx.transfer_sip_participant(participant, "tel:+18003310500")
1. Once the transfer is done, you can safely delete the room to avoid any extra charges. Requirements: • Make sure your SIP trunk provider supports call transfers (like enabling SIP REFER). • Set up the transfer destination properly (a valid phone number or SIP address). If you’d like, I’m here to guide you through the setup or answer any questions you have! Sources: Agents telephony integration | LiveKit Docs | Transferring calls | LiveKit Docs | Job lifecycle | LiveKit Docs | Managing rooms | LiveKit Docs | livekit-agents/livekit/agents/job.py