DeviceBuilder
A DeviceBuilder object allows you to specify a set of devices which should be dialed in sequence or parallel. You can then pass the device plan to the methods that support it, for example Call.connect.
Example
Creates a plan which specifies to dial a SIP endpoint. If there is no answer within 30 seconds, calls two phone numbers in parallel (as indicated by the array syntax). As soon as one of the two answers, the operation is considered successful.
Constructors
constructor
• new DeviceBuilder()
Instantiates an empty DeviceBuilder. Use the add method to add devices to this DeviceBuilder.
Example
Properties
The list of devices that have been added to this DeviceBuilder.
Methods
add
▸ add(device): DeviceBuilder
Adds the specified device (or set of devices) in series to this DeviceBuilder. When you add a device in series, a call to that device will be made only if none of the previously added devices answer the call.
You can pass either a device (Phone or Sip) or an array of devices.
- Passing a single device will add that device in series to the sequence.
- Passing an array of devices will add those devices in series to the previous ones, but among themselves they will be called in parallel.
Parameters
Returns
Example
Adding two devices in series. If "+1xxxxxxxxxx" doesn’t answer within 30 seconds, "+1yyyyyyyyyy" will be called.
Adding two devices in parallel. Both will ring simultaneously. As soon as
either "+1xxxxxxxxxx" or "+1yyyyyyyyyy" answers, the other stops ringing.
Mixing series and parallel. First calls the SIP device. If it doesn’t
answer, calls "+1yyyyyyyyyy" and "+1zzzzzzzzzz" simultaneously.
Phone
▸ Static Phone(params): VoiceCallPhoneParams
Represents the configuration to call a phone device.
Parameters
Object containing the parameters of the method.
Number to call, in E.164 format.
SignalWire number to use to initiate the call, in E.164 format.
Time to wait for the call to be answered, in seconds.
Optional webhook URL to which SignalWire will send call status change notifications. See the payload specifications under CallState.
An optional array of event names to be notified about. Allowed values are created, ringing, answered, and ended.
The optional maximum price in USD acceptable for the call to be created. If the rate for the call is greater than this value, the call will not be created. If not set, all calls will be created. Price can have a maximum of four decimal places, i.e. 0.0075.
Returns
VoiceCallPhoneParams - A device configuration object to pass to DeviceBuilder.add().
Example
Sip
▸ Static Sip(params): VoiceCallSipParams
Represents the configuration to call a SIP device.
Parameters
Object containing the parameters of the method.
SIP endpoint URI to call.
SIP endpoint URI to use to initiate the call.
Time to wait for the call to be answered, in seconds.
Optional array of desired codecs in order of preference. See SipCodec.
Optional array of headers. Must be X- headers only. See SipHeader.
Optional webhook URL to which SignalWire will send call status change notifications. See the payload specifications under CallState.
An optional array of event names to be notified about. Allowed values are created, ringing, answered, and ended.
The maximum price in USD acceptable for the call to be created. If the rate for the call is greater than this value, the call will not be created. If not set, all calls will be created. Price can have a maximum of four decimal places, i.e. 0.0075.
Returns
VoiceCallSipParams - A device configuration object to pass to DeviceBuilder.add().