Xtend IVR
Script consists mainly of commands and functions manipulated by conditional
and looping statements. This section aims at giving a rough idea about the commands,
conditional statements, looping statements and functions used in the script.
Arguments passed to commands and functions are of two types, mandatory and optional.
Mandatory arguments are compulsory, while optional arguments need be used only
when necessary. Mandatory arguments are given within <> while optional arguments
are given within [] brackets.
Commands
Answer
This is the command used to pickup the incoming telephone call. Most of the time this will be one of the first command to be issued by the script. The system will attend the call after specified number of telephone rings. If not specified, the default value is taken as 1 ring.
Syntax :
Answer [No.of Rings]
Eg:
Answer 3
Beep
The beep command produces a beep sound on the auxiliary multimedia device or on the phone line if connected for a specified duration in milliseconds.
Syntax :
Beep < Frequency > < Duration >
Eg:
Beep 3000 2000
BgPlay
BgPlay command plays the specified .wav file in the background.
Syntax :
BgPlay < Wave File >
Eg:
BgPlay "welcome.wav"
BgVolume
BgVolume command adjusts the background play back volume.
Syntax :
BgVolume < Percent >
Eg:
BgVolume 300
Bp
The Bp command is used to set a break point inside the script. This command is valid only in the Developer edition and the Standard edition will simply ignore it. The Execution will pause when Bp is encountered and the user will have to use the single step option (F7) for further execution. This command is well suited for debugging purpose.
Syntax :
Bp
Break
Break command is used to terminate the currently executing loop.
Syntax :
Break
Eg:
While $Count < 10 If $status = 1 Break endif endwhile
Clear
The Clear command immediately clears any pending PLAY, RECORD and SPEAK commands and removes any pending keys from the input queue.
Syntax :
Clear
Display
Display command prints messages in the Display area of the Main window.
Syntax :
Display < string >
Eg:
Display 300
Function
The Function command identifies the start of a user-defined function.
Syntax :
Function Function Name ( Parameters )
<statements>
Return [Expression]
or
Function Function Name
Parameters [$Parameter1][,$Parameter2]...
<statements>
Return [Expression]
Goto
Goto command causes the script to jump to the specified label. If the label is not present then the compiler will generate an error.
Syntax :
Goto <Label>
Eg:
Goto GET_PHONE
Goto ONSYSTEMERROR
Hangup
Hangup is used to terminate or hang-up an active call.
Syntax :
Hangup
Eg:
Hangup
Load
The Load command will load all variables from the given file. It is useful for loading up initial configuration values from a file.
Syntax :
Load <Filename>
Log
The Log command will log the given text into the log file maintained by Xtend IVR. A log file is maintained for each day and the filename is in the yyyymmdd format. One entry is automatically added for each device initialised and terminated. In order to enable the user to track down problems, the time of each log entry as well as the active device identifier is automatically logged along with the text. This is normally used as a logging and debugging aid.
Syntax :
Log <String>
Eg:
Log "The keys entered are" $Keys
Log $Keys
On
On command will cause a jump to the specified <label> if the given <key> has been pressed.
PlaySyntax :
On <key> Goto <label>
Play command will play back the specified wave file through the phone line. The script will not wait for the play to end. The play will happen in the background. All the wave files to be played will queue up. To force the PLAY to complete before proceeding, use the WAIT 0 command. If you have not specified the extension for the file then it will assume that the file is a .WAV file.
The sampling rate for the WAV file must be 8 KHz 16 bit mono.
Syntax :
Play <Wav File>
Eg:
Play welcome.wav
Play thanks
Record
The RECORD command is used to record incoming voice for a specific duration of time. The recorded voice is saved automatically in a file specified in the $RecordFile. When a session starts, Xtend IVR will automatically initialize this variable to a unique temporary filename. The saved file will be in WAV format.
Syntax :
Record <Seconds>
Eg:
Record 5
Wait 0
Record $RecordTime
Wait 0
Run
Run command will execute the specified external program. This command is used to connect Xtend IVR with your program. For transferring data between the called program and Xtend IVR, Xtend IVR uses a common shared file. The shared file is available in the Xtend IVR system variable $varfile.
Normally RUN command is called along with an external program and $varfile as the command line argument for that program. $Varfile is a temporary file shared by both Xtend IVR and called program, which contains the snapshot of the Xtend IVR variables at the time RUN command is interpreted. The called program should manipulate the file for accessing the Xtend IVR variables. Run command will wait until the called program is terminated.
Syntax :
Run <Exe File> <Arguments>
Eg:
Run "myprogram.exe" $varfile
RUN "updatedatabase.exe" $varfile
RUN "reg_user" $varfile
RunTimeout
RunTimeout command sets the timeout value for the RUN command. If the RUN command takes more time than specified by RUNTIMEOUT then it will automatically kill the execution of RUN command and jumps to ONRUNTIMEOUT label. If RunTimeout command is not specified, then the timeout is infinite.
Syntax :
RunTimeout <Seconds>
Eg:
RunTimeout 10
RUN "myexe.exe" $varfile
Save
The Save command will save all variables to the given file.
Syntax :
Save <Filename>
Sleep
The Sleep command suspends the execution of the current script for a specified time interval.
SpeakSyntax :
Sleep < Duration >
Eg:
Sleep 5000
Speak is the command used to speak out a text using the TTS (Text To Speech) engine. We can select the installed TTS using the Xtend IVR Configuration utility. Similar to PLAY command, SPEAK command also executes in the background.
Syntax :
Speak <String>
Eg:
Speak "Thank you"
Speak $Text
Timeout
The Timeout will set the maximum time allotted for the incoming call. If the call takes more than the allotted time then the Xtend IVR engine will hangup the line and jumps to the system label OnTimeout.
If Timeout command is not specified, then the timeout is infinite. Calling HANGUP will clear any previously set timeouts. To enable timeout for every script session, set Timeout in between ANSWER and HANGUP command.
Syntax :
Timeout <Seconds>
Eg:
WAIT_FOR_CALL:
while $Ring < 3
.......
endwhile
answer
TIMEOUT 10
.......
ONTIMEOUT:
HANGUP
goto WAIT_FOR_CALL
VoiceLog
The VoiceLog command will load all variables from the given file.
Syntax :
VoiceLog <FileName>
Eg:
VoiceLog "Sample.wav"
Volume
Volume command will adjust the playback volume of the specified .wav file in software. The default Volume is 100.
Syntax :
Volume <Percent>
Eg:
Volume 300
Wait
The Wait command will wait for the queued play or speak command to end and then wait for a specified number of milliseconds.
Syntax :
Wait <Milliseconds>
Eg:
WAIT 500
Conditional and Looping Statements
Xtend IVR script supports only one conditional statement that is "IF".
Syntax :
IF
<condition> <statements> ENDIF |
or |
IF
<condition 1> <statements> ELSEIF <condition 2> <statements> ENDIF |
or |
IF
<condition> <statements> ELSE <statements> ENDIF |
The first IF statement will check the <condition> condition and if true, will execute the commands inside the <statements> block. The second IF statement will check the <condition> condition and if it's true, it will execute the first block of statements. If the expression is false, it will execute the second block of statements. You can also use ELIF or ELSE IF.
Eg:
IF $Ring < 2
$A = $A + 2
ELSE
$A = $A - 2
ENDIFIF $Ring < $Num
$A = $A + 2
$B = $B / 10
ENDIF
IF <condition> THEN GOTO
This IF statement will check the <condition> and if it's true, it will jump to the specified <label>.
Eg:
IF $Ring < 2 THEN GOTO START_LOOP
Looping Statements
Xtend IVR script supports WHILE statement.
Syntax :
While <condition>
<statements>
endwhile
The 'WHILE' command will check the <condition> and if true, will execute the commands inside the <statements> block until the condition becomes false. But you can always break from the loop by giving a BREAK command.
Eg:
WHILE $Ring < 2
$A += 1
ENDWHILEWHILE $Ring < $Num
$A += 1
if $A>5
break
endif
ENDWHILE
Functions
ActiveCalls()
The activeCalls() function obtains the number of calls active in the dialed line.
Syntax :
ActiveCalls ( <dli> )
Eg:
$calls = ActiveCalls("3011001")
ActivePorts()
The activePorts() function obtains the number of ports being monitored by the Xtend IVR.
Syntax :
ActivePorts ()
Eg:
$ports = ActivePorts()
Alltrim()
Alltrim removes leading and trailing white spaces from a string.
Syntax :
alltrim (<String>)
Eg:
$name ="ram"
alltrim($name)
Alltrim removes
white spaces from both sides of the contained in the variable $name.
Ascii()
An ascii() function returns the ASCII code.
Syntax :
ascii ( <Character>)
AtomicAdd()
AtomicAdd() function increments the value of a variable in a particular device.
Syntax :
AtomicAdd( <deviceId>, <$variable>, <value> )
Eg:
AtomicSet(1, "$Count", 10)
AtomicAdd(1, "$Count", 5)
$Count now contains
15.
AtomicGet()
AtomicGet() function gains access to the variables across devices.
Syntax :
AtomicGet( <deviceId>, <$variable> )
Eg:
AtomicGet(1, "$Count")
AtomicSet()
AtomicSet() function sets the value of a variable in a particular device.
Syntax :
AtomicSet( <deviceId>, <$variable>, <value> )
Eg:
AtomicSet(1, "$Count", 5)
The value of $count will now be set to 5.
BlindTransfer()
BlindTransfer() function blindly transfers the call to the particular extension phone.
Syntax :
BlindTransfer( <extensionNumber> )
Eg:
$status = BlindTransfer("24")
$status now contains TRUE.
Calls()
Calls() function obtains the number of calls handled by the current port.
Syntax :
Calls( <deviceId> )
Eg:
$num = Calls(1)
chr()
Chr () function will return the character, if its ASCII code is given.
Syntax :
chr ( < Number > )
Eg:
$a = 65
$b = chr($a)
$b now contains
"A".
Compare()
A compare() function compares two string parameters and returns 0 if both the strings are equal; 1 if first string is longer than the second string and -1 if first string is smaller than the second string.
Syntax :
Compare (< String1 > , < String2 >)
Eg:
$a = "ABCD"
$b = compare($a,"ABCD")
$b now contains
0.
Concat()
A concat() function is used to concatenate or append two or more strings.
Syntax :
concat(<String1>,<String2>,....,<String n>)
Eg:
$a = "ABCD"
$b = concat ($a, "EFGH", "XYZ")
$b now contains
"ABCDEFGHXYZ".
DeleteFile()
DeleteFile() function deletes the specified file.
Syntax :
DeleteFile ( < Filename > )
Eg:
DeleteFile("abc.txt")
DeviceSpecific()
DeviceSpecific() executes a function unique to a specific driver.
Syntax :
DeviceSpecific ( < functionName >[, parameters ] )
Escape()
Escape() function converts the binary characters in the string to its percentage(%) hexa form.
Syntax :
Escape ( <string> )
Eg:
$Var = "Thank You.wav"
$file = Escape($Var)
$file now contains "Thank%20You.wav".
Find()
Find() function finds a character or substring inside a larger string.
Syntax :
Find ( "Master string","Sub string" )
Eg:
$Var = "Ivr Solutions"
Find($Var,"Sol")
Function will
return 4.
Format()
Format() function writes formatted data to a string according to the format specification types.
Syntax :
$Str = Format (fcString [ ,Arguments ].. )
Eg:
$Var = Format("Cost = %6d %s", 450, "Rs")
GetCallProgress()
GetCallProgress() function obtains the current status of a Dial() or Transfer() operation.
Syntax :
GetCallProgress ( <string> )
Eg:
$status = dial("123456789")
while true
$status = GetCallProgress()
...
endwhile
$status now contains "CONNECTED".
GetInfo()
GetInfo() function retrieves information from the driver DLL.
Syntax :
GetInfo ( <attribute> )
Eg:
$attribute = "CLI"
$id = GetInfo($attribute)
GetMessage()
GetMessage() function fetches a string from the message queue of the specified device.
Syntax :
GetMessage ( <deviceId> )
Eg:
$Msg = GetMessage(10)
GetStartTime()
GetStartTime() function generates the starting date and time of the IVR.
Syntax :
GetStartTime ()
Eg:
$time = GetStartTime()
GetTime()
GetTime() function fetches the local date and time.
Syntax :
GetTime ()
Eg:
$time = GetTime()
Index()
Index() function returns zero based index of a substring or a character inside a larger string. Index function has the same Syntax : as that of Find() function.
Syntax :
$Var = Index("Master string","Sub string")
Input()
Input() function will accept a maximum of <max digits> numbers entered on the dial-pad by the user and will wait for a duration of [wait in seconds] seconds for any further inputs or until the [enter key] is pressed and will store it into the Variable specified by $Variable. Everything from [wait in seconds] onwards is optional.
Syntax :
input (<Max Digits>=2, [Wait in Seconds] , [Enter Key] , [Esc Key])
IsVariable()
IsVariable()
function searches for the given variable anywhere inside the script and returns
true if it exists, otherwise returns false.
Syntax :
IsVariable ($Variable)
Len()
Len()
function will return the length of the string <string> given.
Syntax :
Len (< String >)
Eg:
$a = "ABCD"
$b = len($a)
$b now contains 4.
$a = 365
$b = len($a)
$b now contains 3. LoadFile()
LoadFile() function loads
the specified number of lines of text from the file to a variable.
Syntax :
LoadFile (< filename >, < $variable > , < No:of Lines >)
Eg:
LoadFile("abc.txt", "$Variable", 10)
Loads first
10 lines of text from the file "abc.txt" to the variable "$Variable". Lock()
Lock() function permits one and only one script to execute inside a block of statements.
Syntax :
Lock ( < LockName >)
Eg:
Lock("db_Insertion")
....
....
Unlock()
Lower()
Lower()
function will return a copy of the <string> specified string converted to lowercase.
Syntax :
Lower (< String >)
Eg:
$a = "ABCD"
$b = lower($a)
$b now contains "abcd".
Ltrim()
Ltrim() function will return a copy of the <string> given string after removing all the leading spaces.
Syntax :
Ltrim ( < String > )
Eg:
$a = "ABCD"
$b = ltrim($a)
$b now contains "ABCD".
Mid()
Mid() extracts a substring of length [len] characters from the string <string>, starting
from the position given in the <start index> (zero-based). The function returns
a copy of the extracted substring.
Syntax :
mid (< String > , < Start Index > , [ len ])
Eg:
$a = "ABCD"
$b = mid($a,1,2)
$b now contains "BC".
PlayTimeLeft()
PlayTimeLeft() function returns the pending play back time in milliseconds.
Syntax :
PlayTimeLeft ( )
Eg:
$b = PlayTimeLeft()
PutMessage()
PutMessage() function places a string into the message queue of the specified device.
Syntax :
PutMessage (< deviceId > , < String >)
Eg:
PutMessage(1,"Hello World")
RecordTimeLeft()
RecordTimeLeft() function returns the remaining time for recording.
Syntax :
RecordTimeLeft ()
Eg:
$b = RecordTimeLeft()
ReverseFind()
ReverseFind() function finds a character or substring inside a larger string starting from the end.
Syntax :
ReverseFind ( < Master string >, < Sub string > )
Rindex()
Rindex() function returns the zero-based index of a substring or a character inside a larger string starting from the end. Rindex() has the same syntax as that of ReverseFind() function.
Syntax :
Rindex ( < Master string >, < Sub string >)
Rtrim()
Rtrim() function will return a copy of the <string> after removing all trailing white spaces.
Syntax :
Rtrim(<String>)
Eg:
$a = "ABCD "
$b = rtrim($a)
$b now contains "ABCD".
SaveFile()
SaveFile() function replaces the content from the variable with that of the file by the specified number of lines.
Syntax :
SaveFile (<Filename > , < $Variable > , < No:of Lines >)
Seconds()
Seconds() function gives the time elapsed in seconds after the process has started. This function tells the number of seconds the process has used up.
Syntax :
seconds()
SetInfo()
SetInfo() function sets the attribute of the driver.
Syntax :
SetInfo (< Attribute >, < Value >)
Eg:
SetInfo("DIALCLI","9846036247")
In a dial-out, the driver sets the caller-ID and displays it at the receiving end as "9846036247".
SetInfo("AllowIncoming",false)
The setting will disable / reject the incoming calls on the channel. SoftDisconnect()
SoftDisconnect()
function destroys a softInterconnect with a specified device.
Syntax :
SoftDisconnect ( < DeviceId > )
Eg:
SoftInterConnect(1)
....
....
SoftDisconnect(1)
SoftInterconnect()
SoftInterConnect() function interconnects the current device and the specified device.
Syntax :
SoftInterConnect( < DeviceId > )
Eg:
SoftInterConnect(1)
....
....
SoftDisconnect(1)
SoftListen()
SoftListen() function listens to a particular channel.
Syntax :
SoftListen ( < DeviceId >, < Type > )
Eg:
SoftListen(1,0)
....
....
SoftUnListen(1)
SoftStream()
SoftStream() function streams the Incoming, Outgoing or both audio of the current device to the incoming audio of the specified device.
Syntax :
SoftStream ( < DeviceId >, < Type > )
Eg:
SoftStream(1,0)
....
....
SoftUnstream(1)
SoftUnlisten()
SoftUnlisten() function unlistens from the specified device.
Syntax :
SoftUnlisten ( < deviceId > )
Eg:
SoftListen(1,0)
....
....
SoftUnListen(1)
SoftUnstream()
SoftUnstream() function releases SoftStream() to the specified device.
Syntax :
SoftUnstream ( < deviceId > )>
Eg:
SoftStream(1,0)
....
....
SoftUnstream(1)
srAcceptWords()
srAcceptWords() function defines the grammar for the subsequent Input() operation.
Syntax :
srAcceptWords ( < word 1>, <word 2>, ..., <word N> )
Eg:
srAcceptWords("zero", "one", "two", "three", "four", "five")
srAudio()
srAudio() function specifies when the audio play back has to be stopped.
Syntax :
srAudio ( < type > )
srConfidence()
srConfidence() function determines the level of recognition for the words/grammar defined.
Syntax :
srConfidence ()
srGrammar()
srGrammar() function loads grammar for speech recognition in the script.
Syntax :
srGrammar ( < actualXmlText > )
Eg:
srGrammar("<P>Words</P>")
This loads the grammar provided in the string. srKeepGrammar()
srKeepGrammar()
function sets the grammar for the subsequent Input() operation in the script.
Syntax :
srKeepGrammar (< boolean > )
Eg:
srKeepGrammar(true)
Substr()
Extracts a substring from a larger string and has syntax same as that of mid() functon.
Syntax :
Substr ( < String > , < Start Index > , [ Len ] )
TotalCalls()
TotalCalls() function obtains the total number of calls handled by the IVR so far.
Syntax :
TotalCalls ( )
Eg:
$total = TotalCalls()
Transfer()
Transfer() function transfers the call to an extension phone.
Syntax :
Transfer ( < Extension number >, < Timeout > )
Eg:
$status = Transfer("30",20)
$status now contains "CONNECTED".
Upper()
Upper() function will return a copy of the <string> converted to uppercase.
Syntax :
Upper ( < String >)
UnEscape()
UnEscape() function reverses the Escape() process.
Syntax :
UnEscape ( < string > )
Eg:
$a = "Thank%20You.wav"
$str = UnEscape($a)
$str now contains "Thank You.wav".
UnLock()
UnLock()
function releases the last Lock() operation.
Syntax :
UnLock ( )
Eg:
Lock("db_Insertion")
....
....
Unlock()
See Also