rpc_dial

View as MarkdownOpen in Claude

Dial out to a phone number with a destination SWML URL that handles the outbound call leg. This is commonly used in call screening scenarios: place the caller on hold with hold(), then dial out to a human whose call is handled by a separate SWML agent.

Parameters

to_number
strRequired

Phone number to dial in E.164 format.

from_number
strRequired

Caller ID to display in E.164 format.

dest_swml
strRequired

URL of the SWML document that handles the outbound call leg. The SWML at this URL typically runs a screening agent that can accept, reject, or take a message.

device_type
strDefaults to phone

Device type for the outbound leg.

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="screen_call", description="Screen a call by dialing out")
def screen_call(args, raw_data):
human_number = args.get("phone_number")
caller_name = args.get("caller_name", "Unknown")
return (
FunctionResult("Please hold while I connect you.")
.hold(timeout=120)
.rpc_dial(
to_number=human_number,
from_number="+15559876543",
dest_swml=f"https://example.com/screening-agent?caller={caller_name}"
)
)
agent.serve()