Relay.Calling.PromptResult
This object returned from one of synchronous prompt methods that represents the final result of a prompting attempt.
Methods
getConfidence
In a prompt action of type speech, it returns the confidence of the result.
Parameters
None
Returns
number - Confidence of the result on a speech prompt.
Examples
Start prompt and then check the result confidence.
<?php
$collect = [
'type' => 'speech',
'end_silence_timeout' => 1,
'speech_language' => 'en-US',
'text' => 'Please, tell me who you want to talk to'
];
$call->promptTTS($collect)->done(function($result) {
if ($result->isSuccessful()) {
$confidence = $result->getConfidence(); // => 83.2
}
});
getEvent
Returns the last Relay Event arrived for this operation.
Parameters
None
Returns
Relay.Event - Last Relay Event.
Examples
Start the prompt while playing TTS and then inspect last Relay event payload.
<?php
$collect = [
'type' => 'digits',
'digits_max' => 3,
'initial_timeout' => 10,
'text' => 'Please, enter your 3 digits PIN'
];
$call->promptTTS($collect)->done(function($result) {
$event = $result->getEvent();
// Inspect $event->payload ..
});
getResult
Returns the user's input in a prompt attempt. Could be both from speech or digits type.
Parameters
None
Returns
string - User's input in a prompt attempt.
Examples
Start recording and print the result in a
digitsprompt.
<?php
$collect = [
'type' => 'digits',
'digits_max' => 3,
'initial_timeout' => 10,
'text' => 'Please, enter your 3 digits PIN'
];
$call->promptTTS($collect)->done(function($result) {
if ($result->isSuccessful()) {
$result = $result->getResult();
echo "User enter the PIN: " . $result;
}
});
getTerminator
In a prompt action of type digits, it returns the digit that has terminated the attempt.
Parameters
None
Returns
string - Digit that has terminated the prompt attempt.
Examples
Start prompt and then check the terminator digit.
<?php
$collect = [ "initial_timeout" => 10, "digits" => [ "max" => 3, "digit_timeout" => 5, "terminators" => "#*" ] ];
$tts = [ "text" => "Please, enter your 3 digits PIN" ];
$call->promptTTS($collect)->done(function($result) {
if ($result->isSuccessful()) {
$terminator = $result->getTerminator(); // => "#"
}
});
getType
Returns the type of the attempt: digits or speech.
Parameters
None
Returns
string - digits or speech.
Examples
Start prompt and then check the type of the prompt.
<?php
$collect = [
'type' => 'digits',
'digits_max' => 3,
'initial_timeout' => 10,
'text' => 'Please, enter your 3 digits PIN'
];
$call->promptTTS($collect)->done(function($result) {
if ($result->isSuccessful()) {
$type = $result->getType(); // => "digits"
}
});
isSuccessful
Return true if the prompt attempt succeeded, false otherwise.
Parameters
None
Returns
boolean - True/False accordingly to the state.
Examples
Start the prompt while playing TTS and then check if it has ended successfully.
<?php
$collect = [
'type' => 'digits',
'digits_max' => 3,
'initial_timeout' => 10,
'text' => 'Please, enter your 3 digits PIN'
];
$call->promptTTS($collect)->done(function($result) {
if ($result->isSuccessful()) {
// Prompt completed with success..
}
});