How do I allow hangup of a call from cloud ui agen...
# ask-ai
j
How do I allow hangup of a call from cloud ui agent builder
t
Thanks for reaching out, David. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about allowing a call hangup from Cloud UI Agent Builder. Short answer: the Agent Builder UI does not include a built-in hangup button. You can implement hangup two ways: • Use an Action (HTTP tool) in Agent Builder that calls your backend endpoint. Your backend then calls LiveKit’s DeleteRoom API to end the call for everyone. a. Create an Action in Agent Builder (POST) pointing to your backend (e.g., /end-call). b. Pass the room name via
{{metadata.room_name}}
and use secrets for `LIVEKIT_API_KEY`/`LIVEKIT_API_SECRET`. c. Have your backend call
api_client.room.delete_room(api.DeleteRoomRequest(room=room_name))
. • Export the agent as code and add a function tool that calls
delete_room
directly (then deploy the agent from the code). This gives full control but requires custom code — you can’t add that function from the UI alone. Which approach do you prefer — Actions to call an existing backend, or exporting the agent to add direct SDK hangup logic? If you want, tell me how your backend is set up (language/framework) and I’ll give the exact request and server code snippet. Sources: Agents telephony integration | LiveKit docs | Job lifecycle | LiveKit docs | Agent Builder | LiveKit docs
j
#2
t
Great — you chose option #2 (export agent code and add SDK hangup). To give the exact code and steps, which language/runtime will you use after export: Python or Node.js? Also tell me whether you’ll deploy back to LiveKit Cloud or to your own server/CLI so I can tailor the deploy instructions.
j
python
livekit cloud
t
Thanks — I’ll walk you through exporting the agent, adding a Python hangup function that calls
delete_room
, and redeploying it to LiveKit Cloud. 1) Export the agent from Agent Builder • In Agent Builder, choose Export → Python. Download the generated project. 2) Add a hangup function • Open the project and add a function tool that calls LiveKit’s room delete API. Example (use inside the agent’s tools file):
Copy code
from livekit import api

@function_tool
async def hangup_call(self, ctx: RunContext):
    """End the current call by deleting the room."""
    room_name = ctx.job.room.name
    await ctx.job.api.room.delete_room(api.DeleteRoomRequest(room=room_name))
    return {"status": "ended", "room": room_name}
• Ensure imports match the codebase;
ctx.job.api
is the API client available in the exported runtime. 3) Wire the function into the agent • Add the new function tool name to the agent’s tool list or instructions so the agent can call it when appropriate (e.g., on user intent to hang up). 4) Ensure credentials and permissions • Confirm the agent’s runtime on LiveKit Cloud has access to LiveKit credentials (API key/secret) with rights to delete rooms. Keep secrets secure per the project’s secret management. 5) Deploy the modified agent back to LiveKit Cloud • Follow the project’s README for packaging/deploy steps included in the export. Typically: a. Install dependencies:
pip install -r requirements.txt
b. Run any build/deploy commands provided (or use the LiveKit Cloud CLI/process described in the exported README). c. Upload/redeploy the modified agent bundle to LiveKit Cloud per the export instructions. 6) Test • Start a test call in a room, invoke the agent and trigger hangup. Verify all participants are disconnected and the room is deleted. If you want, I can: • Provide a full file-level patch for where to insert the function in your exported project (share the main agent file names), or • Show a minimal runnable example of the exported agent’s structure with the
hangup_call
integrated. Which would you like next?