Relay.Calling.DetectAction

View as Markdown

This object returned from one of asynchronous detect methods that represents a running detector on the call.

Methods

getControlId

Return the UUID to identify the action.

Parameters

None

Returns

string - UUID to identify the action.

Examples

Start a detector and print the controlId.

1<?php
2
3$call->detectMachineAsync()->done(function ($action) {
4 echo $action->getControlId();
5});

getPayload

Return the payload sent to Relay to initiate the request. Useful to inspect what you sent to perform this action.

Parameters

None

Returns

Object - Payload sent to Relay.

Examples

Start a detector and print out the payload.

1<?php
2
3$call->detectDigitAsync()->done(function($detectResult) {
4 print_r($action->getPayload());
5});

getResult

Returns the final detector result.

Parameters

None

Returns

Relay.Calling.DetectResult - Final detector result.

Examples

Trying detecting DTMF and grab the result when it’s completed.

1<?php
2
3$call->detectDigitAsync()->done(function($action) {
4 // .. later in the code since it's an async method
5 if ($action->isCompleted()) {
6 $detectResult = $action->getResult();
7 }
8});

isCompleted

Return true if detector has finished, false otherwise.

Parameters

None

Returns

Boolean - True/False accordingly to the state.

Examples

Trying detecting DTMF and check if it has finished.

1<?php
2
3$call->detectDigitAsync()->done(function($action) {
4 // .. later in the code since it's an async method
5 if ($action->isCompleted()) {
6
7 }
8});

stop

Stop the action immediately.

Parameters

None

Returns

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

Examples

Trying detecting a machine and then stop the action.

1<?php
2
3$call->detectMachineAsync()->done(function ($action) {
4 // For demonstration purposes only..
5 $action->stop()->done(function($stopResult) {
6
7 });
8});