dial

View as Markdown

dial

  • dial(dialer): Promise<Call> - See Call for more details.

Makes an outbound Call and waits until it has been answered or hung up. This is an advanced method that lets you call multiple devices in parallel or series: for simpler use cases, see dialPhone and dialSip.

With this method you can specify a configuration of devices to call in series and/or in parallel: as soon as one device answers the call, the returned promise is resolved. You specify a configuration through a VoiceDeviceBuilder object.

Parameters

NameTypeDescription
dialerVoiceDeviceBuilderThe Dialer specifying the devices to call.

Returns

Promise<Call> - See Call for more details.

A call object.

Example

Calls a phone number. If the number doesn’t answer within 30 seconds, calls two different SIP endpoints in parallel.

1const devices = new Voice.DeviceBuilder()
2 .add(Voice.DeviceBuilder.Phone({ from: "+XXXXXX", to: "+YYYYYY", timeout: 30 }))
3 .add([
4 Voice.DeviceBuilder.Sip({ from: "sip:aaa@bbb.cc", to: "sip:xxx@yyy.zz" }),
5 Voice.DeviceBuilder.Sip({ from: "sip:aaa@bbb.cc", to: "sip:ppp@qqq.rr" }),
6 ]);
7
8try {
9 const call = await client.dial(devices);
10 console.log("Call answered");
11} catch (e) {
12 console.log("Call not answered");
13}