hangup

View as MarkdownOpen in Claude

End the call immediately.

This is a terminal action. Any actions chained after hangup() may not execute. Always place hangup() last in the chain.

Parameters

None.

Returns

FunctionResult — self, for chaining.

Example

from signalwire import AgentBase
from signalwire import FunctionResult
agent = AgentBase(name="my-agent", route="/agent")
agent.set_prompt_text("You are a helpful assistant.")
@agent.tool(name="end_call", description="End the call")
def end_call(args, raw_data):
return (
FunctionResult("Thank you for calling. Goodbye!")
.update_global_data({"call_ended": True})
.hangup()
)
agent.serve()