Relay.Calling.PromptAction

View as Markdown

This object returned from one of asynchronous prompt methods that represents a prompt attempt that is currently active on a call.

Methods

getControlId

Return the UUID to identify the prompt attempt.

Parameters

None

Returns

string - UUID to identify the action.

Examples

Start the attempt and print the controlId.

1<?php
2
3$collect = [
4 'type' => 'digits',
5 'digits_max' => 3,
6 'initial_timeout' => 10,
7 'text' => 'Please, enter your 3 digits PIN'
8];
9$call->promptTTSAsync($collect)->done(function($action) {
10 echo $action->getControlId();
11});

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 the attempt and print out the payload.

1<?php
2
3$collect = [
4 'type' => 'digits',
5 'digits_max' => 3,
6 'initial_timeout' => 10,
7 'text' => 'Please, enter your 3 digits PIN'
8];
9$call->promptTTSAsync($collect)->done(function($action) {
10 print_r($action->getPayload());
11});

getResult

Returns the final result of the prompt attempt.

Parameters

None

Returns

Relay.Calling.PromptResult - Final result of the prompt attempt.

Examples

Start the attempt and grab the result when it’s completed.

1<?php
2
3$collect = [
4 'type' => 'digits',
5 'digits_max' => 3,
6 'initial_timeout' => 10,
7 'text' => 'Please, enter your 3 digits PIN'
8];
9$call->promptTTSAsync($collect)->done(function($action) {
10 // .. later in the code since it's an async method
11 if ($action->isCompleted()) {
12 $result = $action->getResult();
13 }
14});

getState

Return the current state of the prompt attempt.

Parameters

None

Returns

string - Current state of the prompt attempt.

Examples

Start the attempt and print the state.

1<?php
2
3$collect = [
4 'type' => 'digits',
5 'digits_max' => 3,
6 'initial_timeout' => 10,
7 'text' => 'Please, enter your 3 digits PIN'
8];
9$call->promptTTSAsync($collect)->done(function($action) {
10 echo $action->getState();
11});

isCompleted

Return true if the prompt attempt has finished, false otherwise.

Parameters

None

Returns

Boolean - True/False accordingly to the state.

Examples

Start the attempt and check if it has finished.

1<?php
2
3$collect = [
4 'type' => 'digits',
5 'digits_max' => 3,
6 'initial_timeout' => 10,
7 'text' => 'Please, enter your 3 digits PIN'
8];
9$call->promptTTSAsync($collect)->done(function($action) {
10 if ($action->isCompleted()) {
11
12 }
13});

stop

Stop the action immediately.

Parameters

None

Returns

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

Examples

Start the attempt and then stop it.

1<?php
2
3$collect = [
4 'type' => 'digits',
5 'digits_max' => 3,
6 'initial_timeout' => 10,
7 'text' => 'Please, enter your 3 digits PIN'
8];
9$call->promptTTSAsync($collect)->done(function($action) {
10 // For demonstration purposes only..
11 $action->stop()->done(function($stopResult) {
12
13 });
14});

volume

Control the volume of the playback.

Parameters

ParameterTypeRequiredDescription
volumenumberrequiredVolume value between -40dB and +40dB where 0 is unchanged.

Returns

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

Examples

Start the prompt and increase the playback volume.

1<?php
2
3$collect = [
4 'type' => 'digits',
5 'digits_max' => 3,
6 'initial_timeout' => 10,
7 'text' => 'Please, enter your 3 digits PIN'
8];
9$call->promptTTSAsync($collect)->done(function($action) {
10 // For demonstration purposes only..
11 $action->volume(5.0)->done(function($volumeResult) {
12
13 });
14});