Play audio message
Use this function to play an audio message previously loaded on the TVox system.
Ivr_play($val = array())
<?php
$audioFile = "audio_message";
$result = $this->Ivr_play(array($audioFile, 0));
if($result[0] == TVOX_IVR_CALLER_EXIT){
$this->RightExitIVR();
}
?>
Make sure to replace
with the message to played.
audio_message
In the example on the right side we can see
$result[0] == TVOX_IVR_CALLER_EXIT`
that check if caller hangup the call and $this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with some array values |
$val = array($audioFile, $canInterrupt)
Parameter | Description |
---|---|
$audioFile | Audio file's name |
$canInterrupt | Can interrupt file play (possibile values: 1 for interrupt, 0 to not stop play) |
Set call variable
Use this function to save value into call and popup variable
Ivr_setvar($val = array())
<?php
define("CUSTOMER_CODE", "CUSTOMER_CODE");
$this->Ivr_setvar(array(CUSTOMER_CODE, "value"));
?>
Make sure to replace
with the value to save.
value
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with two parameters |
$val = array($variableName, $variableValue)
Parameter | Description |
---|---|
$variableName | Variable's name to save |
$variableValue | Variable's value to save |
Get call variable
Get call variable value
Ivr_getvar($val = array())
<?php
define("CUSTOMER_CODE", "CUSTOMER_CODE");
$value = $this->Ivr_getvar(array(CUSTOMER_CODE));
?>
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with variable name as value |
Get digits
Get digits from user interaction and save as call variable
Ivr_get_digit($val = array())
<?php
define("CUSTOMER_CODE", "CUSTOMER_CODE");
$fileName = "audio_file";
$maxDigitNumber = 10;
$timeoutDigit = 5;
$result = $this->Ivr_get_digit(array($fileName, $maxDigitNumber, CUSTOMER_CODE, $timeoutDigit));
if ($result[0] == TVOX_IVR_CALLER_EXIT) {
$this->RightExitIVR();
}
?>
Get variable value after digits
$value = $this->Ivr_getvar(array(CUSTOMER_CODE));
$result[0] == TVOX_IVR_CALLER_EXIT`
check if caller hangup the call and$this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with four parameters |
$val = array($fileName, $maxDigits, $variableName, $timeoutDigits)
Parameter | Description |
---|---|
$fileName | Audio file name to play before collect digits |
$variableName | Variable name to save |
$maxDigits | max digits number |
$timeoutDigits | maximum timeout for insert numbers |
Choose option
Do a choice between array values digits
Ivr_choose_option($val = array())
<?php
$fileName = "audio_file";
$digits = array(1,2,3);
$timeoutDigit = 5;
$this->lastDigit = NULL;
$result = $this->Ivr_choose_option(array($fileName, $digits, null, $timeoutDigit));
if ($result[0] == TVOX_IVR_CALLER_EXIT) {
$this->RightExitIVR();
}
$value = $this->lastDigit;
?>
Get digit selected with
$value = $this->lastDigit;
$result[0] == TVOX_IVR_CALLER_EXIT`
check if caller hangup the call and$this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with four parameters |
$val = array($fileName, $digits, $variableName, $timeoutDigits)
Parameter | Description |
---|---|
$fileName | Audio file name to play before collect digits |
$digits | Array with list of the permitted digits |
$variableName | Variable name to save |
$timeoutDigits | Maximum timeout for digits insert |
Play stored digits
Read variable and play digit saved
Ivr_saysaved($val = array())
<?php
define("CUSTOMER_CODE", "CUSTOMER_CODE");
$this->Ivr_saysaved(array(CUSTOMER_CODE));
?>
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with varible name as parameter |
Check service is active
Check if service is Active
Ivr_check_service_active($servToCheck)
<?php
$serviceToCheck = "service_code";
$active = $this->Ivr_check_service_active($serviceToCheck);
?>
Make sure to replace
with the service code to check. Value
service_code
$active
is boolean
Parameter | Default | Description |
---|---|---|
$servToCheck | check if this service code is active |
Transfer call to service
Transfer call to service
Ivr_load_serv($val = array())
<?php
$service = "service_code";
$this->Ivr_load_serv(array($service));
$this->RightExitIVR();
?>
Make sure to replace
with the service code to check.
service_code
$this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with service code as value |
Transfer call to service advanced
Transfer call to service with advanced settings
Ivr_l_s_extend($val = array())
<?php
$servCode = "service_code";
$servLabel = "New label";
$servPriority = "1";
$servCallLimit = "5";
$servQueueLimit = "2";
$maxQueuedCallPercentage = "";
$servRecording = "1";
$servSkill1 = "skill1";
$servSkill2 = "skill2";
$servSkill3 = "skill3";
$servSkill4 = "";
$servSkill5 = "";
$this->Ivr_l_s_extend(array($servCode, $servLabel, $servPriority, $servCallLimit, $servQueueLimit, $maxQueuedCallPercentage, $servRecording, $servSkill1, $servSkill2, $servSkill3, $servSkill4, $servSkill5));
$this->RightExitIVR();
?>
Make sure to replace
with the service code to check.
service_code
$this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with service parameters |
$val = array($servCode, $servLabel, $servPriority, $servCallLimit, $servQueueLimit, $maxQueuedCallPercentage, $servRecording, $servSkill1, $servSkill2, $servSkill3, $servSkill4, $servSkill5)
Parameter | Description | Usage |
---|---|---|
$servCode | Service code to tranfer to | Required |
$servLabel | Label to show on client near service name | Optional |
$servPriority | Service priority | Optional |
$servCallLimit | Setting the maximum number of calls managed by the service for calls passing through the current node. | Optional |
$servQueueLimit | Setting the limit for calls in the queue to the service for calls passing through the current node. | Optional |
$maxQueuedCallPercentage | Settings limit in percentage on agents logged for calls passing through the current node. | Optional |
$servRecording | Call will be recorded when the operator answers. | Optional |
$servSkill1 | First Skillset, in priority order, in calls distibution for the selected service. | Optional |
$servSkill2 | Second skillset, in priority order, in calls distibution for the selected service. | Optional |
$servSkill3 | Third skillset, in priority order, in calls distibution for the selected service. | Optional |
$servSkill4 | Fourth skillset, in priority order, in calls distibution for the selected service. | Optional |
$servSkill5 | Fifth skillset, in priority order, in calls distibution for the selected service. | Optional |
Call internal number
Call internal number
Ivr_dial($val = array())
<?php
$number = "internal_number";
$this->Ivr_dial(array($number));
$this->RightExitIVR();
?>
Make sure to replace
with the internal number to call.
internal_number
$this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with internal number as value |
Call external number
Call external number
Ivr_dial_exter($val = array())
<?php
$extNumber = "external_number";
$timeToDial = "180";
$dialRetry = "3";
$callEnable = "1";
$this->Ivr_dial_exter(array($extNumber));
$this->RightExitIVR();
?>
Make sure to replace
with the external number to call.
external_number
Get call result withgetDialResult()
$this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with some parameters as value |
$val = array($extNumber, $timeToDial, $dialRetry, $callEnable);
Parameter | Description | Usage |
---|---|---|
$extNumber | Number to call | Required |
$timeToDial | Time for call duration in seconds | Optional |
$dialRetry | Number of attempts to call the entered number | Optional |
$callEnable | Call enabling number, configured in the TVox system | Optional |
Get dial result
Get dial result
getDialResult()
<?php
$result = $this->getDialResult();
?>
Result | Description |
---|---|
NOANSWER | Call not answered |
ANSWER | Call answered |
CANCEL | Call is cancelled |
BUSY | Called number was busy |
CONGESTION | No lines available to call |
CHANUNAVAIL | No routing to PSTN |
Play TTS text
Play text as audio
Ivr_speech_synthesize($val = array())
<?php
$textValue = "text_to_play";
$options = array("text" => $textValue, "language" => "it-IT","voice" => "Luca", "gender" => "male","profile" => "profile_name" );
$result = $this->Ivr_speech_synthesize($options);
if ($res[0] == TVOX_IVR_CALLER_EXIT || $res[0] == TVOX_IVR_FORCED_EXIT || $res[0] == TVOX_IVR_ERROR) {
$this->RightExitIVR();
}
?>
If exit with this dial state TVOX_IVR_CALLER_EXIT, TVOX_IVR_FORCED_EXIT, TVOX_IVR_ERROR, close call statistics with correct values
$this->RightExitIVR()
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with tts options |
array("text" => $textValue, "language" => "it-IT","voice" => "Luca", "gender" => "male" );
Parameter | Description |
---|---|
text | Text plaied from system |
language | Text language to read for play (depend on TTS server) |
voice | Voice's name to play text (depend on TTS server) |
gender | Voice's gender to play text (depend on TTS server) |
profile | The mrcp profile configured in the system |
timeout | Timeout for waiting digit if you want make selection |
Get value from caller speak
Recognize caller voice command based on grammar voice and get value.
Ivr_speech_recognition($val = array())
<?php
$fileName = "audio_file";
$grammar = "grammar.grxml";
$options = array("file" => $fileName, "grammar" => $grammar, "language" => "it-IT","voice" => "Luca", "gender" => "male","profile" => "profile_name" );
$result = $this->Ivr_speech_recognition($options);
if ($res[0] == TVOX_IVR_CALLER_EXIT) {
$this->RightExitIVR();
}
$result = $this->Agi->get_variable(TVOX_RECOG_RESULT);
$value = $result["data"];
?>
Make sure to replace
with the system audio file and
audio_file
with the correct grammar If exit with this dial state TVOX_IVR_CALLER_EXIT, close call statistics with correct values
grammar.grxml
$this->RightExitIVR()
Parameter | Default | Description |
---|---|---|
$val | array() | Array have some values |
Parameter | Description |
---|---|
file | Audio file to play before recognition |
grammar | Grammar to match voice command |
language | Text language to read for play (depend on TTS server) |
voice | Voice's name to play text (depend on TTS server) |
gender | Voice's gender to play text (depend on TTS server) |
profile | The mrcp profile configured in the system |
timeout | Timeout for waiting digit if you want make selection |
Start call recording
Record call and store to file
Ivr_start_rec($clid, $dnis, $type = "O", $ivrDoMix = false, $recOnlyCallerChannel = false)
<?php
$clid = "clid_number";
$dnis = "dnis_number"
$type = "I";
$ivrDoMix = true;
$recOnlyCallerChannel = true;
$filenameRecorded = $this->Ivr_start_rec($clid, $dnis, $type, $ivrDoMix, $recOnlyCallerChannel);
$this->lastDigit = NULL;
$result = $this->Ivr_choose_option(array("", $digits, NULL, 1800));
if ($result[0] == TVOX_IVR_CALLER_EXIT) {
$this->RightExitIVR();
}
if (isset($this->lastDigit) && $this->lastDigit != "") {
$note="recording_note";
$dest = $this->Ivr_stop_rec($note);
}
?>
If exit with this dial state TVOX_IVR_CALLER_EXIT, close call statistics with correct values
$this->RightExitIVR()
Parameter | Default | Description |
---|---|---|
$clid | Caller's number | |
$dnis | Called number | |
$type | "O" | Call direction, important for statistics ( values are "I" or "O") |
$ivrDoMix | false | If true, the file is available when Ivr_stop_rec is called otherwise it waits until the system has produced it |
$recOnlyCallerChannel | false | If true record only caller voice else record the caller voice and the music on hold and other system files |
Stop call recording
Stop call recording when started
Ivr_stop_rec($note = NULL, $buffer = false)
<?php
$note = "recording_note";
$destination = $this->Ivr_stop_rec($note);
?>
Make sure to replace
with the note to attach file.
recording_note
$destination
value is recorded file path
Parameter | Default | Description |
---|---|---|
$note | NULL | Set recording note to show in statistics |
$buffer | false | If true, the system automatically transfers to the standard tvox memory, otherwise the script have to manage the file by itself |
Update popup values
Updates the popup data referring to the particular call
set_collect_data($data)
<?php
$data = "value=12345";
$this->set_collect_data($data);
?>
Parameter | Description |
---|---|
$data | String values that are stored in database tu update popup |
Send DTMF
Send DTMF digit to call
Ivr_send_dtmf($val = array())
<?php
$dtmf = array("1");
$this->Ivr_send_dtmf($dtmf);
?>
Parameter | Default | Description |
---|---|---|
$val | array() | Pass array with dtmf number as value |
Load service voicemail
Load service's voicemail
Ivr_voicemail($val = array())
<?php
$this->Ivr_voicemail();
$this->RightExitIVR();
?>
$this->RightExitIVR()
close call statistics with correct values.
Parameter | Default | Description |
---|---|---|
$val | array() | If used by the script, no parameters are needed. Remember to configure the parameters from the web interface |
Load service if in calls limit
Loads the service if number calls not exceeded limit
Ivr_countcall($val = array())
<?php
$actionService = "service_code";
$serviceToMonitor = "monitor_service_code";
$whatCount = "GLOBAL_CALL_COUNT";
$limit = 10
$this->Ivr_countcall(array($limit, $whatCount, $serviceToMonitor, $actionService));
?>
Parameter | Default | Description |
---|---|---|
$val | array() | Array parameter with some parameters |
array($limit, $whatCount, $serviceToMonitor, $actionService)
Parameter | Description |
---|---|
$limit | Set call limit to load service |
$whatCount | Check what count from detect call service limit: cases are: GLOBAL_CALL_COUNT, QUEUE_COUNT, ANSWER_COUNT |
$serviceToMonitor | Service where monitor call limits |
$actionService | Service to load after calls limit check |
Check if call channel is up
Check if call channel is active
Ivr_isChannelUp()
<?php
$channelUp = $this->Ivr_isChannelUp();
?>
$ channelUp
returns a Boolean value: true if channel active, false otherwise
Hangup call
Hangup current call
Ivr_hangup($val = null)
<?php
$this->Ivr_hangup();
$this->RightExitIVR();
?>
$this->RightExitIVR()
close call statistics with correct values.
Exit with error
Exit from Ivr and set Error in statistics
Ivr_error()
<?php
$this->Ivr_error();
?>
Exit with good state
Exit from Ivr with correct state for statistics
RightExitIVR($start = null)
<?php
$this->RightExitIVR();
?>
Parameter | Default | Description |
---|---|---|
$start | null | Time when ivr was started, if not set, the value is the starting value of the ivr script |
Log
To access log, need enable windows sharing on TVox web interface
After enabling it, we can see the logs on the folder by logging in with the default username and password (ivrcustom: ivrcustom) via share samba
Default log is info, to enable full log open asterisk cli from tamadmin user.
when the asterisk cli is shown put command:
dialplan set global TVOX_DEBUG 3
if need show fatal errors need enable asterisk agi:
agi set debug on
Info
Log level INFO
info($msg, $debug_val = false, $val = array())
<?php
$this->info("log_message");
?>
Make sure to replace
with the message to log.
log_message
Parameters | Default | Description |
---|---|---|
$msg | Message to log | |
$debug_val | false | If set to true $val is logged to file |
$val | array() | Variable to log |
If need dump variable to info log use
info_var_dump($msg, $val = array())
<?php
$value = array("1","2","3");
$this->info_var_dump("log_message",$value);
?>
Make sure to replace
with the message to log. Dump variable Array or Object to log message
log_message
Parameters | Default | Description |
---|---|---|
$msg | Message to log | |
$val | array() | Variable to log |
Debug
Log level DEBUG
debug($msg, $debug_val = false, $val = array())
<?php
$this->debug("log_message");
?>
Make sure to replace
with the message to log.
log_message
Parameters | Default | Description |
---|---|---|
$msg | Message to log | |
$debug_val | false | If set to true $val is logged to file |
$val | array() | Variable to log |
If need dump variable to debug log use
debug_var_dump($msg, $val = array())
<?php
$value = array("1","2","3");
$this->debug_var_dump("log_message",$value);
?>
Make sure to replace
with the message to log. Dump variable Array or Object to log message
log_message
Parameters | Default | Description |
---|---|---|
$msg | Message to log | |
$val | array() | Variable to log |
Trace
Log level TRACE
trace($msg, $debug_val = false, $val = array())
<?php
$this->trace("log_message");
?>
Make sure to replace
with the message to log.
log_message
Parameters | Default | Description |
---|---|---|
$msg | Message to log | |
$debug_val | false | If set to true $val is logged to file |
$val | array() | Variable to log |
If need dump variable to trace log use
trace_var_dump($msg, $val = array())
<?php
$value = array("1","2","3");
$this->trace_var_dump("log_message",$value);
?>
Make sure to replace
with the message to log. Dump variable Array or Object to log message
log_message
Parameters | Default | Description |
---|---|---|
$msg | Message to log | |
$val | array() | Variable to log |
Variables
Library variables
Agi variables
Is possible get variables from agi, some variables are:
Variable Name | Description |
---|---|
Clid | Caller number |
Dnis | Dialed number |
CallId | Call identification number |
Service Code | Service code |
To get this values use this code:
<?php
$clid = $this->Agi->request["agi_callerid"];
$dnis = $this->Agi->request["agi_dnid"];
$callId = $this->Agi->request["agi_uniqueid"];
$serviceCode = $this->Agi->request["agi_extension"];
?>
Dial Result
Variable Name | Value | Description |
---|---|---|
TVOX_IVR_CONTINUE | 0 | Continue with IVR script (next step) |
TVOX_IVR_CALLER_EXIT | -1 | Caller hangup call |
TVOX_IVR_FORCED_EXIT | -2 | Force call close |
TVOX_IVR_INVALID | -3 | Invalid option insert |
TVOX_IVR_TIMEOUT | -4 | Digit timeout reached |
TVOX_IVR_TRANSFER_CALL | -5 | Call is trasfered |
TVOX_IVR_ERROR | -8 | Generic Error |
Asr variables
Variable Name | Description |
---|---|
TVOX_RECOG_INSTANCE | Result string from grammar recognition |
TVOX_RECOG_RESULT | Speech result |
TVOX_RECOG_DATA | String result value from match |
TVOX_RECOG_DTMF | Digit insert during speech |
TVOX_RECOG_RESULT can have some values:
- NO_INPUT
- NO_MATCH
- OK
- ERROR
TTS Variables
Variable Name | Value | Description |
---|---|---|
TVOX_SYNTH_DTMF | TVOX_SYNTH_DTMF | Digit insert during or after play |
Library Variables
Variable Name | Description |
---|---|
$Agi | Agi variable where get some call viariables or funcitons |
$UniqueID | Call unique id |
$lastDigit | Is updated when a Ivr_choose_option() is called, store last digit selection, need reset before other Ivr_choose_option() |
Changelog
2.3.7 - 2.4.7
- Add methods getQueueCalls and getReadyAgents
2.4.6
- Add method lookupByProperty
2.3.6
- Add custom statistics function
2.3.5
- Added Average Queue Time function
2.3.4
- Added get Ticket function
- Added increment custom node statitics function
2.3.3
- Add automatic po function, needed TTS and ASR to execute this.
- Add ticket creation function
- Add sendSms Function
- Add addNumberToExternalContact to add a telehpne number to existing contact
2.3.2
- Add internalLookup and externalLookup function to get contact from TVox Addressbook
2.3.1
- Add sendAlarm function to send Alarm with specific priority