How-to use variables in CallySquare

Remember all the variables must be previously defined in the Tools section (see V3 Variables for details) or inside the IVR project using the menu file -> Variable

Syntax

The variable format is slightly different from the Asterisk one.

It must be written as:

{VARIABLENAME}

DO NOT use the $ character before the {}.

Asterisk channel variables list

see https://docs.asterisk.org/Configuration/Dialplan/Variables/Channel-Variables/Asterisk-Standard-Channel-Variables/ for Asterisk Standard Channel Variables

Set a variable

The common operation is set a value to a variable. The value can be a constant (string, number, etc.) or another variable (Asterisk variables or custom variables).

Example: the usual Asterisk variable ${CALLERID(num)} MUST be defined just as {CALLERID(num)} in the Cally Square environment.

The variable {CALLER_NUMBER} now contains the caller number



DB Query Result

Using the IVR Blocks Database you need to specify the variable where the query result will be saved.

 

For example, we want to retrieve the customer name from the orders table where the order number is previously inserted by the caller.

The result set is stored into a matrix as:

{VARIABLENAME[row][column name]}

that is

{DBRESULT[0][customer_name]}

The first row has the index 0 (zero)

 

Built-in variables

We provide the following Asterisk channels variables named

variable name + _ROWS_COUNT:shows the number of affected rows (only for SELECT statements).

Example: {RESULT_ROWS_COUNT}

Asterisk Dialplan Functions

Using the Asterisk dialplan functions can be useful to get some information about the agents or queue status before to send the calls to a queue.

An example about using function is:

In the GOTOIF block we run a function to get the number of the current waiting calls in the queue.

If there are more than 5 waiting calls. the new callers will hear a message (playback block) that invite them to call later.

Here is the function we used into the GOTOIF block:

{QUEUE_WAITING_COUNT(queuename)} >= 5

** replace "queuename" with the name of the queue you want to check.

 

Asterisk dialplan functions list

seehttps://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Dialplan+Functions for Standard Asterisk Dialplan Functions



Javascript Methods

CallySquare is able to manage also the javascript methods.

For example, we need to check the caller prefix in order to send the call to the correct queue (local or UK  callers)

The GOTOIF condition is:

‘{PRODUCT_TYPE}’ == ‘option’

 

 

Array Handler

With the MATH block we are able to execute mathematical operations, javascript methods (as described in the previous section) and handle an array of values.

Example:

A variable called INPUT_DATA  contains a separated string:

John,Doe,998,john.doe@xcally.com

We want to set each value to a different variable ({FIRST_NAME}, {LAST_NAME},{EXTENSION},{EMAIL})

Math Operation

'{INPUT_DATA}'.split(",")



SET the single variable:

FIRST_NAME = {RESULT[0]} (John)

LAST_NAME = {RESULT[1]} (Doe)

EXTENSION = {RESULT[2]} (998)

EMAIL = {RESULT[3]} (john.doe@xcally.com)