connect

View as MarkdownOpen in Claude

Transfer or connect the call to another destination. Generates a SWML connect verb under the hood.

When final=True (the default), the call permanently leaves the agent. When final=False, the call returns to the agent if the far end hangs up first.

Parameters

destination
strRequired

Where to connect the call. Accepts a phone number in E.164 format (e.g., "+15551234567") or a SIP address (e.g., "support@company.com").

final
boolDefaults to True

Whether this is a permanent transfer.

  • True — call exits the agent completely (terminal action)
  • False — call returns to the agent when the far end hangs up
from_addr
Optional[str]Defaults to None

Caller ID override. Phone number or SIP address to show as the caller. When None, the current call’s originating address is used.

Returns

FunctionResult — self, for chaining.

Examples

Permanent Transfer

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_sales", description="Transfer caller to the sales team")
8def transfer_to_sales(args, raw_data):
9 return (
10 FunctionResult("Transferring you to sales.")
11 .connect("+15551234567", final=True)
12 )
13
14agent.serve()

Temporary Transfer

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="consult_specialist", description="Connect to a specialist temporarily")
8def consult_specialist(args, raw_data):
9 return (
10 FunctionResult("Connecting you to a specialist.")
11 .connect("+15551234567", final=False)
12 )
13
14agent.serve()

Custom Caller ID

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_with_caller_id", description="Transfer with custom caller ID")
8def transfer_with_caller_id(args, raw_data):
9 return (
10 FunctionResult("Transferring now.")
11 .connect(
12 "support@company.com",
13 final=True,
14 from_addr="+15559876543"
15 )
16 )
17
18agent.serve()