Variables and Functions in Yeastar Expression
This topic introduces the supported variables and functions in Yeastar Call Flow Designer.
Variable
- Session Variable: Session variables store information about the
current call session. These variables are globally accessible throughout a
call flow and do not depend on any specific components.
For more information, see Session Variables.
- Component Variable: Component variables hold the values returned by
specific components. These variables become available after the
corresponding components are added to a call flow.
For more information, see Component variables.
- Session Variables
-
Variable Type Description Example Value $Session.ani String Caller's number. "15812340987" $Session.callid String Unique ID for a call. "1751336277.2" $Session.did String The DID number associated with the call flow that the caller reached. "5503301" $Session.flowNum String The extension number associated with the call flow that the caller reached.
"6900" $Session.transferingNum String The number from which the call was forwarded.
"1000" - Component variables
-
Note: Since the same component can be added multiple times in a call flow, an index is appended to each component (e.g. Menu 1, Menu 2) based on the order in which the components are added. To retrieve data from the right component, the component variable must contain the corresponding index.
Function
Functions are used for condition evaluation and data processing, enabling flexible control of the call flow. The supported functions are as follows.
- AND
- Perform a logical operation across two or
more
conditions, returning
Trueonly if all conditions are met at the same time.- Syntax
-
FX_AND(condition1,condition2, ...)- Request Type: Boolean
- Response Type: Boolean
- Example
-
FX_AND(FX_EQUAL($UserInput1.userInput,"1"), FX_EQUAL($Session.ani,"1001"))
- OR
- Perform a logical operation across two or more conditions, returning
Trueif any of the conditions is met.
- NOT
- Perform a logical operation on a single condition to get the opposite of its Boolean result.
- EQUAL
- Perform a logical check to determine whether two values are equal (both
in value and data type).
- Syntax
-
FX_EQUAL(value1,value2) - Example
-
FX_EQUAL($Session.ani,"1001")
- NOT_EQUAL
- Perform a logical check to determine whether two values are not equal.
- CONTAINS
- Perform a logical operation to check if the first string contains the
second string.
- Syntax
-
FX_CONTAINS(value1,value2) - Example
-
FX_CONTAINS($GetExtensionStatus1.currentProfile,"Available")
- GREATER_THAN
- Perform a logical check to determine if the first value is greater than
the second value.
- Syntax
-
FX_GREATER_THAN(value1,value2)- Request Type: Integer
- Response Type: Boolean
- Example
-
FX_GREATER_THAN($GetQueueInfo1.callsWaiting,5)
- GREATER_THAN_OR_EQUAL
- Perform a logical check to determine if the first value is greater than or equal to the second value.
- LESS_THAN
- Perform a logical check to determine if the first value is less than the second value.
- LESS_THAN_OR_EQUAL
- Perform a logical check to determine if the first value is less than or equal to the second value.
- TO_BOOLEAN
- Perform a logical operation to convert a value to a Boolean.
- Syntax
-
FX_TO_BOOLEAN(value)- Request Type: Any
- Response Type: Boolean
- Example
-
FX_TO_BOOLEAN($GetExtensionStatus1.currentProfile)
- CONCATENATE
- Perform a string operation to concatenate every string parameter and return the resulting string.
- TRIM
- Perform a string operation to remove leading and trailing invisible characters (e.g. spaces, new lines, etc.) from the given value.
- LEFT
- Perform a string operation to extract a specified number of characters from the beginning of the given text.
- MID
- Perform a string operation to extract a substring from a given text
starting at a specified position with a specified length.
- Syntax
-
FX_MID(text,start_position,length)- Request Type:
text: Stringstart_position: Integerlength: Integer
- Response Type: String
- Request Type:
- Example
-
FX_MID("13800138000",4,4)
- RIGHT
- Perform a string operation to extract a specified number of characters from the end (right side) of a given text.
- UPPER
- Perform a string operation to convert all characters in the given text
to uppercase.
- Syntax
-
FX_UPPER(text) - Example
-
FX_UPPER("Yeastar")
- LOWER
- Perform a string operation to convert all characters in the given text to lowercase.
- REPLACE
- Perform a string operation to replace a specified substring with another substring in the given text.
- REPLACE_REG_EXP
- Perform a string operation to replace substrings that match a regular expression pattern with a specified replacement string.
- JSON_GET_STRING
-
Perform an operation to retrieve a string value from a JSON object based on the specified key.
- TO_STRING
- Perform an operation to convert a value to a string.
- Syntax
-
FX_TO_STRING(value) - Example
-
FX_TO_STRING(10086)
- NOW
- Return the current date and time as a DateTime object.
- LEN
- Perform a string operation to return the number of characters in the given text.
- SUM
- Perform an option to sum two or more 32-bit integer values.
- Syntax
-
FX_SUM(value1,value2,...) - Example
-
FX_SUM(100,200,300)
- SUM_LONG
- Perform an operation to sum two or more 64-bit integer values.
- NEGATIVE
- Perform an operation to return the negative value of a 32-bit integer.
- NEGATIVE_LONG
- Perform an operation to return the negative value of a 64-bit
integer.
- Syntax
-
FX_NEGATIVE_LONG(value) - Example
-
FX_NEGATIVE_LONG(1000000000)
- MULTIPLY
- Perform an operation to multiply two or more 32-bit integer values.
- MULTIPLY_LONG
- Perform an operation to multiply two or more 64-bit integer values.
- Syntax
-
FX_MULTIPLY_LONG(value1,value2,...)- Request Type: Integer
- Response Type: Integer
- Example
-
FX_MULTIPLY_LONG(100000,20000)
- DIVIDE
- Perform an operation to divide the first 32-bit integer value by the second 32-bit integer value.
- DIVIDE_LONG
- Perform an operation to divide the first 64-bit integer value by the
second 64-bit integer value.
- Syntax
-
FX_DIVIDE_LONG(value1,value2)- Request Type: Integer
- Response Type: Integer
- Example
-
FX_DIVIDE_LONG(10000000000,2000000000)
- ABS
- Perform an operation to return the absolute (non-negative) value of a
32-bit integer.
- Syntax
-
FX_ABS(value)- Request Type: Integer
- Response Type: Integer
- Example
-
FX_ABS(-100)
- ABS_LONG
- Perform an operation to return the absolute (non-negative) value of a
64-bit integer.
- Syntax
-
FX_ABS_LONG(value)- Request Type: Integer
- Response Type: Integer
- Example
-
FX_ABS_LONG(-10000000000)
- GET_TABLE_ROW_COUNT
- Perform an operation to return the number of rows in a table.
- Syntax
-
FX_GET_TABLE_ROW_COUNT(table)- Request Type: Any
- Response Type: Integer
- Example
-
FX_GET_TABLE_ROW_COUNT($DatabaseAccess1.queryResult)
- GET_LIST_ITEM_COUNT
- Perform an operation to return the number of items in a given list.
- Syntax
-
FX_GET_LIST_ITEM_COUNT(list)- Request Type: Any
- Response Type: Integer
- Example
-
FX_GET_LIST_ITEM_COUNT($DatabaseAccess1.queryResult)
- JSON_GET_INTEGER
-
Perform an operation to retrieve an integer value from a JSON object based on the specified key.
- TO_INTEGER
- Perform an operation to convert a value to a 32-bit integer.
- Syntax
-
FX_TO_INTEGER(value)- Request Type: String
- Response Type: Integer
- Example
In this example, the function converts the string "12345" into the integer 12345.FX_TO_INTEGER("12345")
- TO_LONG
- Perform an operation to convert a value to a 64-bit integer.
- Syntax
-
FX_TO_LONG(value)- Request Type: String
- Response Type: Integer
- Example
-
FX_TO_LONG("1234567890123")
- GET_TABLE_CELL_VALUE
- Perform an operation to retrieve the value from a table cell at the specified row and column.
- GET_LIST_ITEM
- Perform an operation to retrieve the value from a list at the specified
index position.
- Syntax
-
FX_GET_LIST_ITEM(list,index)-
Request Type:
-
list: Any -
index: Integer
-
- Response Type: Object
-
- Example
-
FX_GET_LIST_ITEM($DatabaseAccess1.queryResult,2)
- JSON_GET_OBJECT
-
Perform an operation to retrieve a nested JSON object from a parent JSON object based on the specified key.
