swml_transfer

View as MarkdownOpen in Claude

Transfer the call to a SWML endpoint and configure an AI response for when control returns to the agent (relevant only when final=False).

For simple phone-number or SIP transfers, use connect() instead. Use swml_transfer() when you need to hand off to another SWML document and set up a return message.

Parameters

dest
strRequired

Destination URL for the transfer (a SWML endpoint, SIP address, etc.).

ai_response
strRequired

Message the AI speaks when the transfer completes and control returns to the agent. Only meaningful when final=False.

final
boolDefaults to True

Whether this is a permanent transfer (True) or temporary (False).

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="transfer_to_support", description="Transfer to support SWML endpoint")
8def transfer_to_support(args, raw_data):
9 department = args.get("department", "support")
10 return (
11 FunctionResult("Let me connect you.", post_process=True)
12 .swml_transfer(
13 dest="https://support.example.com/swml",
14 ai_response="The support call is complete. How else can I help?",
15 final=False
16 )
17 )
18
19agent.serve()