set_response

View as MarkdownOpen in Claude

Set or replace the response text after construction. The response is the text the AI speaks back to the caller after the function executes.

Parameters

response
strRequired

Text for the AI to speak to the caller.

Returns

FunctionResult — self, for chaining.

Example

1from signalwire import AgentBase
2from signalwire import FunctionResult
3
4agent = AgentBase(name="my-agent", route="/agent")
5agent.set_prompt_text("You are a helpful assistant.")
6
7@agent.tool(name="check_order", description="Look up an order by ID")
8def check_order(args, raw_data):
9 order_id = args.get("order_id")
10 result = FunctionResult()
11 if order_id:
12 result.set_response(f"Your order {order_id} shipped yesterday.")
13 else:
14 result.set_response("I couldn't find that order number.")
15 return result
16
17agent.serve()