How do I trigger something when the user has ended...
# ask-ai
c
How do I trigger something when the user has ended the call?
t
Thanks for reaching out, Bryce. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When you want to trigger something as soon as a user ends a call in LiveKit, here are a few friendly ways to do it: • Detect User Intent: You could use a function like
end_call
to catch when the user wants to hang up, and then respond accordingly. This often works well with natural language understanding. • Programmatically End the Call: Another option is to use the
delete_room
API, which ends the session for everyone involved—making sure the call is completely wrapped up. • Event Listeners: Keep an eye on the
participant_disconnected
event to notice when someone leaves, so you can tidy things up behind the scenes. • Frontend UI: Adding an "END CALL" button in your interface lets users disconnect whenever they want, and you can hook that up to trigger backend actions too. If you'd like, I’m happy to walk you through the details of any of these—just let me know! Sources: Agents telephony integration | LiveKit Docs | examples/voice_agents/realtime_joke_teller.py | components/livekit/agent-control-bar/agent-control-bar.tsx | Making calls using SIP | LiveKit Docs