how would I create a tool that allows the agent to...
# ask-ai
c
how would I create a tool that allows the agent to end the call?
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'd be happy to help you create a tool that lets an agent end a call in LiveKit! A great way to do this is by implementing a function that deletes the room using the
delete_room
API, which makes sure the call ends smoothly for everyone involved. Here’s a simple overview to get you started: • First, set up the LiveKit API client with your credentials (
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
). • Then, create an
end_call
function that waits until the agent is done speaking and calls
job_ctx.api.room.delete_room()
to delete the room. • If you like, you can add a button on the frontend to trigger this, but the main logic for ending the call should live in the backend. If you'd like, I can provide detailed code examples or walk you through any part of this—just let me know! Sources: Agent speech and audio | LiveKit Docs | basics/exit_message.py | components/livekit/agent-control-bar/agent-control-bar.tsx | examples/voice_agents/session_close_callback.py | agent.py