RELAYCall

connect

View as MarkdownOpen in Claude

Bridge the call to one or more destinations. The devices parameter supports both serial (try one at a time) and parallel (ring simultaneously) dialing strategies.

This method emits calling.call.connect events. See Call Events for payload details.

This method corresponds to the SWML connect verb. See the SWML connect reference for the full specification.

Parameters

devices
list[list[dict]]Required

A list of device groups for serial/parallel dialing. The outer list is tried serially (one group at a time). Each inner list is dialed in parallel (all devices in the group ring simultaneously).

Each device dict contains:

  • "type" — Device type ("phone", "sip")
  • "params" — Type-specific parameters (to_number, from_number, etc.)
ringback
Optional[list[dict]]

Media items to play to the caller while the destination is ringing. Same format as play() media items.

tag
Optional[str]

Correlation tag for the connected call.

max_duration
Optional[int]

Maximum duration of the connected call in seconds.

max_price_per_minute
Optional[float]

Maximum price per minute for the connected call.

status_url
Optional[str]

URL to receive connection status webhooks.

Returns

dict — Server response confirming the connect operation.

Example

1from signalwire.relay import RelayClient
2
3client = RelayClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7 contexts=["default"],
8)
9
10@client.on_call
11async def handle_call(call):
12 await call.answer()
13 await call.play([{"type": "tts", "text": "Connecting you now..."}])
14
15 # Serial dialing: try first number, then second if no answer
16 result = await call.connect([
17 [{"type": "phone", "params": {"to_number": "+15551234567", "from_number": "+15559876543"}}],
18 [{"type": "phone", "params": {"to_number": "+15559999999", "from_number": "+15559876543"}}],
19 ])
20 print(f"Connect result: {result}")
21
22client.run()