when the agent leaves the call, I detect that and ...
# ask-ai
e
when the agent leaves the call, I detect that and delete the room. However, this doesnt make the call hang up. When reading the docs it seemed to say this is the correct way to end the call. Am I doing something wrong?
t
Thanks for reaching out, Josh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You are following the correct approach: deleting the room via the
delete_room
API is the recommended way to end a call in LiveKit. When you delete a room, all participants are automatically disconnected and receive a
Disconnected
event. This should result in the call hanging up for everyone involved. If you are finding that the call does not hang up after the room is deleted, please ensure that: • You are using the
delete_room
API and not just disconnecting the agent participant • The correct room name/ID is passed to the API • Clients are listening for and handling the
Disconnected
event properly If these conditions are met and the issue persists, please provide more detail about your client handling or any specific errors you are seeing. I can then assist further based on your implementation details. Sources: Agents telephony integration | LiveKit Docs | Managing rooms | LiveKit Docs | Inside a session | LiveKit Docs | Anatomy of an Agent | LiveKit Docs
e
The room has a sip participant (sip made with twilio) and an agent. When the agent leaves the room, I want to hang up the call. The way I do this is by deleting the room. Is this correct?
t
Hey there! I totally get your concern about ending a call with both a SIP participant and an agent. The good news is that using the
delete_room
API is actually super straightforward and exactly what you want to do. It's like hitting the "end call" button that works perfectly for everyone involved. Let me break down why this is such a smooth solution: • If you just disconnect the agent, the SIP participant might end up hearing awkward silence—not cool, right? So
delete_room
is definitely the way to go. • Pro tip: If you want to play a final message from the agent, just wait for that to finish up before you delete the room. It keeps things polished. • Bonus: If you're recording with LiveKit Egress, deleting the room stops the recording cleanly too! The best part? No extra complicated steps for SIP calls. The
delete_room
API has got your back and handles all the technical cleanup automatically. Easy peasy! Sources: Agents telephony integration | LiveKit Docs | Managing rooms | LiveKit Docs | Inside a session | LiveKit Docs | telephony/sip_lifecycle.py | pkg/sip/outbound.go | agent.py
e
But when I delete the room, it does not hang up the call for the sip participant. Is this a known issue? Or am I doing something wrong based on how I told you I have implemented things
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
e
it seems that the hang up works when I set the transport as tcp instead of tls. However I want to keep tls for security reasons. I am using twilio as my provider. I think the issue is that when using tls, the handshake between livekit and twilio expires in the middle of the call causing the sip bye signal to get lost. How can I resolve this issue?