stale-vase-84095
08/02/2025, 10:47 PMtall-airline-16756
08/02/2025, 10:48 PMtall-airline-16756
08/02/2025, 10:48 PMdelete_room API. This action terminates the call for all participants. Here’s how it works:
1. Finish Ongoing Speech: Ensure any current speech output is completed before proceeding.
2. Call the delete_room API: This API deletes the room, effectively ending the call.
Here’s an example of how this can be implemented in code:
async def hangup_call():
ctx = get_job_context()
if ctx is None:
return
await ctx.api.room.delete_room(
api.DeleteRoomRequest(
room=ctx.room.name,
)
)
class MyAgent(Agent):
@function_tool
async def end_call(self, ctx: RunContext):
"""Called when the user wants to end the call"""
current_speech = ctx.session.current_speech
if current_speech:
await current_speech.wait_for_playout()
await hangup_call()
This ensures the call is ended properly after the user leaves.
Sources: Agents telephony integration | LiveKit Docs | Agents telephony integration | LiveKit Docs | Making calls using SIP | LiveKit Docs