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.
Available In:
Parameters
None
Returns
number
- Confidence of the result on a speech
prompt.
Examples
<?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.
Available In:
Parameters
None
Returns
Relay.Event
- Last Relay Event.
Examples
<?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.
Available In:
Parameters
None
Returns
string
- User's input in a prompt attempt.
Examples
<?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.
Available In:
Parameters
None
Returns
string
- Digit that has terminated the prompt attempt.
Examples
<?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
.
Available In:
Parameters
None
Returns
string
- digits or speech.
Examples
<?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.
Available In:
Parameters
None
Returns
boolean
- True/False accordingly to the state.
Examples
<?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..
}
});