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
str | NoneDefaults 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

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

Temporary Transfer

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

Custom Caller ID

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="transfer_with_caller_id", description="Transfer with custom caller ID")
def transfer_with_caller_id(args, raw_data):
return (
FunctionResult("Transferring now.")
.connect(
"support@company.com",
final=True,
from_addr="+15559876543"
)
)
agent.serve()