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

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