NAV
Version: 2.3.3
PHP

Add number to External Contact

$this->addNumberToExternalContact($vcard, $number, $telephonyProperty);

<?php

$clid = "external_number";
$vcard = $this->externalLookup($clid);
$number = "telephone_number";
$result = $this->addNumberToExternalContact($vcard, $number, TelephonyProperties::CELL_WORK); 

?>

Make sure to replace external_number with the number to lookup and telephone_number with the number to add. TelephonyProperties is the kind of number i'm adding. Add number result is true for success, false otherwise.

Parameter Description
$vcard is the contact returned from externalLookup function
$number is the number to add to the contact
$telephonyProperty TelephonyProperties is the kind of number to add

Insert Ticket

$this->createTicket($contactUid, $title, $service, $priority, $body, $customFields = array(), $customDateFields = array());

<?php

$clid = "external_number";
$vcard = $this->externalLookup($clid);
$contactUid = $vcard[0][VCardProperties::UID][0]["value"][0][0];
$title = "ticket_title";
$body = "ticket_body";
$result = $this->createTicket($contactUid, $title, $ticketService, 3, $body, array("custom_value_1"), array("custom_value_date_1")); 

?>

Make sure to replace external_number with the external number to lookup, check externalLookup for explanation. Replace ticket_title with the tiicket title. Ticket title is also article title. Replace ticket_body with the ticket text message

Parameter Description
$contactUid is the contact uid retrieved from the externalLookup function
$title is ticket title, also is set in the ticket's article title
$ticketService The service where queue ticket ( the service need support enabled)
$priority Ticket priority values are 1 = low, 2 = nromal, 3 = high
$customFields Custom fields to pass, array position is custom field number, for example arrya(null,"custom") set only custom field 2
$customDateFields Custom date fields to pass, array position is custom field number, for example arrya(null,"custom_date ") set only custom date field 2

Send SMS

$this->sendSms($number, $text);

<?php


$text = "sms_text";
$number = "telephone_number";
$this->sendSms($number, $text);

?>

Make sure to replace sms_text with the sms text max 160 characters and telephone_number with mobile telephone number to send sms

Parameter Description
$text Sms text message (max 160 characters)
$number mobile number to send sms

Automatic Po

Load automatic po

Ivr_abot($val = array())

<?php
$voice = "male"
$welcome_msg = "text message"
$userOrServiceRequest = "text message",
$backup_service ="service_code"
$lookup_caller = "1"
$barge_in="0"
$mrcp_profile="profile name"
$this->Ivr_abot(array($welcome_msg,$backup_service));
?>

Make sure to replace backup_service with the service code.

Parameter Default Description
$val array() Pass array with some array values

$val = array($voice,$welcome_msg,$userOrServiceRequest,$backup_service,$lookup_caller,$barge_in,$mrcp_profile)

Parameter Default Description Usage
$voice "male" Voice gender used by Attendant Bot for prompt messages Optional
$welcome_message Welcome message used by Attendant Bot as the first prompt usually used as a company presentation. (optional.Ex: 'Welcome to Telenia Software' Optional
$backup_service Service to which calls are forwarded when the Attendant BOT was unable to handle. Required
$userOrServiceRequest Message used by Attendant Bot to ask the caller with who wants to talk to (default: 'Say surname and first name of the person you want to talk to list of services separated by or, Example: 'Say surname and first name of the person you want to talk to or assistance for talking to an operator. Optional
$lookup_caller 1 If enabled, the caller is identified in order to personalize the welcome message. Optional
$barge_in 0 If enabled, it allows the caller to interrupt any request message that the Attendant proposes. Optional
$mrcp_profile google_cloud_service MRCP profile used by the Attendant Bot, requires knowledge of system configurations (default: 'google_cloud_service') Optional

Lookup

Internal Lookup

Get contact from number, use it if the number is internal number

<?php

$clid = "internal_number";
$result = $this->internalLookup($clid);
$name = $result[VCardProperties::FN][0]["value"][0][0];

?>

Make sure to replace internal_number with the internal number to lookup, get properties with VCardPoperties. If result is null number not exist in internal addressbook

Parameter Description
$clid Caller id number (or number to use to get contact from addressbook)

External Lookup

Get contact from number, use it if the number is external number

<?php

$clid = "external_number";
$result = $this->externalLookup($clid);
$name = $result[0][VCardProperties::FN][0]["value"][0][0];

?>

Make sure to replace external_number with the external number to lookup, get properties with VCardPoperties. If result is null number not exist in external addressbook

Parameter Description
$clid Caller id number (or number to use to get contact from addressbook)

Send Alarm

Send alarm with specific priority level

sendAlarm($priority = 1, $message = "")

<?php

$priority = 1;
$message = "message";
$this->sendAlarm($priority,$message);

?>

Make sure to replace message with the custom message form alarm.

Parameter Default Description
$priority 1 Alarm priority level, values are (1,2,3,4,5,6)
$message "" Custom message to put in alarm body

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 audio_message with the message to played.

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 value with the value to save.

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 service_code with the service code to check. Value $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 service_code with the service code to check. $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 service_code with the service code to check. $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 internal_number with the internal number to call.
$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 external_number with the external number to call.
Get call result with getDialResult() $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","profile" => "profile_name" );

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 audio_file with the system audio file and grammar.grxml with the correct grammar If exit with this dial state TVOX_IVR_CALLER_EXIT, close call statistics with correct values $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 recording_note with the note to attach file. $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 log_message with the message to log.

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 log_message with the message to log. Dump variable Array or Object to 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 log_message with the message to log.

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 log_message with the message to log. Dump variable Array or Object to 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 log_message with the message to log.

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 log_message with the message to log. Dump variable Array or Object to 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:

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()

VCard Properties

Property Description
UID Unique identifier
FN Contact Fullname ( name and surname )
N Contact Name
TEL Contact telephone (list of phones)
ORG Contact organization
CATEGORIES Contact categories
EMAIL Contacts email (list of emails)
ADR Contact address
NOTE Contact Notes
CUSTOM_1 Contact custom field 1
CUSTOM_2 Contact custom field 2
CUSTOM_3 Contact custom field 3
CUSTOM_4 Contact custom field 4
CUSTOM_5 Contact custom field 5
CUSTOM_6 Contact custom field 6
CUSTOM_7 Contact custom field 7
CUSTOM_8 Contact custom field 8
CUSTOM_9 Contact custom field 9
CUSTOM_10 Contact custom field 10
TELENIA_VIP If contact is vip or not
TELENIA_NPS Nps value

Telephony Properties

Property Description
WORK Work phone
CELL Mobile phone
FAX Fax number
HOME Home phone
CELL_WORK Work mobile number
FAX_WORK Work fax number
FAX_HOME Home fax number
CELL_HOME Mobile home number
OTHER Other number


















Changelog

2.3.7 - 2.4.7

2.4.6

2.3.6

2.3.5

2.3.4

2.3.3

2.3.2

2.3.1

PHP