Skip to main content

Relay.Calling

This represents the API interface for the Calling Relay Service. This object is used to make requests related to managing end to end calls.

Methods

dial

Make an outbound Call and waits until it has been answered or hung up.

Available In:

Parameters

$paramsarrayrequiredArray with the following properties:
typestringrequiredThe type of call. Only phone is currently supported.
fromstringrequiredThe party the call is coming from.
Must be a SignalWire number or SIP endpoint that you own.
tostringrequiredThe party you are attempting to call.
timeoutnumberoptionalThe time, in seconds, the call will ring before going to voicemail.

Returns

React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.DialResult object.

Examples

Make an outbound Call and grab the call object if it was answered.
<?php

$params = [ 'type' => 'phone', 'from' => '+1XXXXXXXXXX', 'to' => '+1YYYYYYYYYY' ];
$client->calling->dial($params)->done(function($dialResult) {
if ($dialResult->isSuccessful()) {
// Your active $call..
$call = $dialResult->getCall();
}
});

newCall

Create a new Call object. The call has not started yet allowing you to attach event listeners on it.

Available In:

Parameters

See Relay.Calling.Dial for the parameter list.

Returns

Call - A new Relay.Calling.Call object.

Examples

Create a new Call object.
<?php

$params = [ 'type' => 'phone', 'from' => '+1XXXXXXXXXX', 'to' => '+1YYYYYYYYYY' ];
$call = $client->calling->newCall($params);
// Use the $call object...