Variables and Functions in Yeastar Expression

This topic introduces the supported variables and functions in Yeastar Call Flow Designer.

Variable

Variables are used to dynamically retrieve and pass data throughout a call flow. There are two types of variables in Yeastar Call Flow Designer:
  • 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.
Variable Type Description Example Value
Prompt component
$Prompt{index}.ttsResult String The Text-to-Speech (TTS) result of the Prompt component.
  • PromptTTSResult.Success: The text is successfully converted into speech, and the system plays it to caller.
  • PromptTTSResult.Timeout: The text is NOT converted into speech within the timeout period, and the system routes caller directly to the next component without playing a prompt when the timeout is reached.
$Prompt1.ttsResult(STRING)=PromptTTSResult.Success
Menu component
$Menu{index}.result String

The result of the Menu component.

  • MenuResult.Timeout: The caller didn't press any DTMF digit before the timeout, and was routed to the timeout destination.
  • MenuResult.ValidOption: The caller pressed a valid key, and was routed to the corresponding destination.
  • MenuResult.InvalidOption: The caller pressed an invalid key, and was routed to the invalid input destination.

$Menu1.result(STRING)=MenuResult.InvalidOption

$Menu{index}.ttsResult String The Text-to-Speech (TTS) result of the Menu component.
  • MenuTTSResult.Success: The text is successfully converted into speech, and the system plays it to caller.
  • MenuTTSResult.Timeout: The text is NOT converted into speech within the timeout period, and the system routes caller directly to the next component without playing a prompt when the timeout is reached.
$Menu1.ttsResult(STRING)=MenuTTSResult.Success
$Menu{index}.userInput String The DTMF digit that the caller pressed, excluding the end key (# or *). "2"
User Input component
$UserInput{index}.result String

The result of User Input component.

  • UserInputResult.Timeout: The caller didn't press any DTMF digit before the timeout, and was routed to the timeout destination.
  • UserInputResult.ValidOption: The caller pressed a valid key, and was routed to the corresponding destination.
$UserInput1.result(STRING)=UserInputResult.Timeout
$UserInput{index}.ttsResult String The Text-to-Speech (TTS) result of the User Input component.
  • UserInputTTSResult.Success: The text is successfully converted into speech, and the system plays it to caller.
  • UserInputTTSResult.Timeout: The text is NOT converted into speech within the timeout period, and the system routes caller directly to the next component without playing a prompt when the timeout is reached.
$UserInput1.ttsResult(STRING)=UserInputTTSResult.Success
$UserInput{index}.userInput String The DTMF digit that the caller pressed, excluding the end key (# or *). "2"
Record component
$Record{index}.ttsResult String The Text-to-Speech (TTS) result of the Record component.
  • RecordTTSResult.Success: The text is successfully converted into speech, and the system plays it to caller.
  • RecordTTSResult.Timeout: The text is NOT converted into speech within the timeout period, and the system routes caller directly to the next component without playing a prompt when the timeout is reached.
$Record1.ttsResult(STRING)=RecordTTSResult.Timeout
Dial by Number component
$DialByNumber{index}.ttsResult String The Text-to-Speech (TTS) result of the Dial by Number component.
  • DialByNumberTTSResult.Success: The text is successfully converted into speech, and the system plays it to caller.
  • DialByNumberTTSResult.Timeout: The text is NOT converted into speech within the timeout period, and the system routes caller directly to the next component without playing a prompt when the timeout is reached.
$DialByNumber1.ttsResult(STRING)=DialByNumberTTSResult.Success
Transfer component
$Transfer{index}.ttsResult String The Text-to-Speech (TTS) result of the Transfer component.
  • TransferTTSResult.Success: The text is successfully converted into speech, and the system plays it to caller.
  • TransferTTSResult.Timeout: The text is NOT converted into speech within the timeout period, and the system routes caller directly to the next component without playing a prompt when the timeout is reached.
$Transfer1.ttsResult(STRING)=TransferTTSResult.Success
Get Extension Presence Status component
$GetExtensionStatus{index}.currentProfileName String

Name of the extension's current presence status.

Note: When using functions to evaluate an extension's presence status, ensure that the status constant matches one of the values defined in PBX Settings > Preferences > Presence.

"Available"
$GetExtensionStatus{index}.currentProfile String Name and additional information of the extension's current presence status. "Available,work"
$GetExtensionStatus{index}.isInCall Boolean Whether the extension is currently on a call.
  • True: At lease one endpoint registered to the extension is on a call.
  • False: None of the endpoints registered to the extension are on a call.
True
$GetExtensionStatus{index}.isInRing Boolean Whether the extension is currently ringing.
  • True: At lease one endpoint registered to the extension is ringing.
  • False: None of the endpoints registered to the extension are ringing.
False
Get Queue Agent component
$GetQueueAgent{index}.agentList Object

The list of agents with a specific status in a specific queue, returning each agent's extension number as well as their current status.

"1001,Log Out;1003,Log Out;1004,Log Out"

$GetQueueAgent{index}.agentNumberList Object The list of agents with a specific status in a specific queue, returning each agent's extension number. "1001,1003,1004"
Get Queue Info component
$GetQueueInfo{index}.availableAgents Integer

The number of agents currently available to take calls.

5
$GetQueueInfo{index}.unavailableAgents Integer

The number of agents currently unavailable to take calls.

1
$GetQueueInfo{index}.callsActive Integer

The number of calls currently being answered by queue agents.

2
$GetQueueInfo{index}.callsWaiting Integer The number of calls currently waiting in the queue. 10
Get Agent Status component
$GetAgentStatus{index}.currentProfile String Name and additional information of the agent's current status.
Note: When using functions to evaluate an agent's status, ensure that the status constant matches one of the supported values listed below.
  • Status for Static Agents:
    • "Pause{pause_reason}"
    • "Unpause"
  • Status for Dynamic Agents:
    • "Log In"
    • "Log Out"
    • "Pause{pause_reason}"
"Log Out"
$GetAgentStatus{index}.isInCall Boolean Whether the agent is currently on a call.
  • True: The agent is on a call.
  • False: The agent is NOT on a call.
True
$GetAgentStatus{index}.isInRing Boolean Whether the agent's extension is currently ringing.
  • True: The agent's extension is ringing.
  • False: The agent's extension is NOT ringing.
True
Database Access component
$DatabaseAccess{index}.queryResult Object

The table returned by a SQL query.

Tip: You can use the variable with the following functions to retrieve data from the result.
  • GET_TABLE_ROW_COUNT(table): Get the total number of rows.
  • GET_TABLE_CELL_VALUE(table,row,column): Get the value at the specified row and column.
"demo%40yeastar.com"
$DatabaseAccess{index}.nonQueryResult Integer The number of rows affected by a non-query SQL statement. 99
$DatabaseAccess{index}.scalarResult String The single value returned by a scalar SQL query. "10"
HTTP Request component
$HttpRequest{index}.responseContent String The body content returned from HTTP response.

{"authenticated": true, "user": "10000"}

$HttpRequest{index}.responseStatusCode String The HTTP status code returned from the request.
Note: When using functions to evaluate HTTP status code, ensure that the constant is a numeric code, without any accompanying text.
"200"

Function

Functions are used for condition evaluation and data processing, enabling flexible control of the call flow. The supported functions are as follows.

Boolean

AND
Perform a logical operation across two or more conditions, returning True only 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"))

In this example, the function returns True only when the user input is 1 and the caller's number is 1001.

OR
Perform a logical operation across two or more conditions, returning True if any of the conditions is met.
Syntax
FX_OR(condition1,condition2, ...)
  • Request Type: Boolean
  • Response Type: Boolean
Example
FX_OR(FX_EQUAL($Session.ani,"1001"),FX_EQUAL($GetAgentStatus1.isInCall,False))
In this example, the function returns True if either the caller's number is 1001 or the agent is not in a call.
NOT
Perform a logical operation on a single condition to get the opposite of its Boolean result.
Syntax
FX_NOT(condition)
  • Request Type: Boolean
  • Response Type: Boolean
Example
FX_NOT($GetExtensionStatus1.isInCall)

In this example, the function returns True when the extension is NOT in a call.

EQUAL
Perform a logical check to determine whether two values are equal (both in value and data type).
Syntax
FX_EQUAL(value1,value2)
  • Request Type: Any
  • Response Type: Boolean
Example
FX_EQUAL($Session.ani,"1001")
In this example, the function returns True if the caller's number is a string and its value is exactly "1001".
NOT_EQUAL
Perform a logical check to determine whether two values are not equal.
Syntax
FX_NOT_EQUAL(value1,value2)
  • Request Type: Any
  • Response Type: Boolean
Example
FX_NOT_EQUAL($GetAgentStatus1.isInRing,True)
In this example, the function returns True if the agent is NOT in the ringing state.
CONTAINS
Perform a logical operation to check if the first string contains the second string.
Syntax
FX_CONTAINS(value1,value2)
  • Request Type: String
  • Response Type: Boolean
Example
FX_CONTAINS($GetExtensionStatus1.currentProfile,"Available")
In this example, the function returns True if the extension's current presence status contains 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)
In this example, the function returns True if the number of calls waiting in the queue exceeds 5.
GREATER_THAN_OR_EQUAL
Perform a logical check to determine if the first value is greater than or equal to the second value.
Syntax
FX_GREATER_THAN_OR_EQUAL(value1,value2)
  • Request Type: Integer
  • Response Type: Boolean
Example
FX_GREATER_THAN_OR_EQUAL($GetQueueInfo1.callsWaiting,5)
In this example, the function returns True if the number of calls waiting in the queue is 5 or more.
LESS_THAN
Perform a logical check to determine if the first value is less than the second value.
Syntax
FX_LESS_THAN(value1,value2)
  • Request Type: Integer
  • Response Type: Boolean
Example
FX_LESS_THAN($GetQueueInfo1.callsWaiting,5)
In this example, the function returns True if the number of calls waiting in the queue is less than 5.
LESS_THAN_OR_EQUAL
Perform a logical check to determine if the first value is less than or equal to the second value.
Syntax
FX_LESS_THAN_OR_EQUAL(value1,value2)
  • Request Type: Integer
  • Response Type: Boolean
Example
FX_LESS_THAN_OR_EQUAL($GetQueueInfo1.callsWaiting,5)
In this example, the function returns True if the number of calls waiting in the queue is 5 or fewer.
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)

In this example, the function converts the value returned by the Get Extension Presence Status component to a Boolean value. For example, if the value is "Available", the function returns True.

String

CONCATENATE
Perform a string operation to concatenate every string parameter and return the resulting string.
Syntax
FX_CONCATENATE(string1,string2,...)
  • Request Type: String
  • Response Type: String
Example
FX_CONCATENATE("Caller",$Session.ani,"called",$Session.flowNum)
In this example, the function combines the caller's number and flow number into one string. E.g. "Caller1001called6900".
TRIM
Perform a string operation to remove leading and trailing invisible characters (e.g. spaces, new lines, etc.) from the given value.
Syntax
FX_TRIM(value)
  • Request Type: String
  • Response Type: String
Example
FX_TRIM(" Hello ")

In this example, the function removes spaces from the word and returns "Hello".

LEFT
Perform a string operation to extract a specified number of characters from the beginning of the given text.
Syntax
FX_LEFT(text,count)
  • Request Type:
    • text: String
    • count: Integer
  • Response Type: String
Example
FX_LEFT("13800138000",3)
In this example, the function extracts the first three characters from the given text and returns "138".
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: String
    • start_position: Integer
    • length: Integer
  • Response Type: String
Example
FX_MID("13800138000",4,4)
In this example, the function extracts 4 characters starting from the 4th character of the text, and returns "0013".
RIGHT
Perform a string operation to extract a specified number of characters from the end (right side) of a given text.
Syntax
FX_RIGHT(text,count)
  • Request Type:
    • text: String
    • count: Integer
  • Response Type: String
Example
FX_RIGHT("13800138000",4)
In this example, the function extracts the last 4 characters from the given text, and returns "8000".
UPPER
Perform a string operation to convert all characters in the given text to uppercase.
Syntax
FX_UPPER(text)
  • Request Type: String
  • Response Type: String
Example
FX_UPPER("Yeastar")
In this example, the function converts all letters in the text to uppercase, and returns "YEASTAR".
LOWER
Perform a string operation to convert all characters in the given text to lowercase.
Syntax
FX_LOWER(text)
  • Request Type: String
  • Response Type: String
Example
FX_LOWER("Yeastar")
In this example, the function converts all letters in the text to lowercase, and returns "yeastar".
REPLACE
Perform a string operation to replace a specified substring with another substring in the given text.
Syntax
FX_REPLACE(text,target,replacement)
  • Request Type:
    • text: String
    • target: String
    • replacement: String
  • Response Type: String
Example
FX_REPLACE("+8613800138000","+86","")
In this example, the function removes the country code +86 from the phone number, and returns "13800138000".
REPLACE_REG_EXP
Perform a string operation to replace substrings that match a regular expression pattern with a specified replacement string.
Syntax
FX_REPLACE_REG_EXP(text,expression,replacement)
  • Request Type:
    • text: String
    • expression: String
    • replacement: String
  • Response Type: String
Example
FX_REPLACE_REG_EXP("Call123", "[0-9]", "X")
In this example, the function matches all numeric characters using the regular expression [0-9] and replaces them with X, and returns "CallXXX".
JSON_GET_STRING

Perform an operation to retrieve a string value from a JSON object based on the specified key.

Syntax
FX_JSON_GET_STRING(JSONObject,key)
  • Request Type:

    • JSONObject: String

    • key: String

  • Response Type: String
Example
FX_JSON_GET_STRING($HttpRequest1.responseContent,"status")
In this example, the function returns the value of the status key from the JSON content returned by the HTTP Request 1 component.
TO_STRING
Perform an operation to convert a value to a string.
Syntax
FX_TO_STRING(value)
  • Request Type: Any
  • Response Type: String
Example
FX_TO_STRING(10086)
In this example, the function converts 10086 into a string parameter, and returns "10086".

Date Time

NOW
Return the current date and time as a DateTime object.
Syntax
FX_NOW()
  • Request Type: Null. This function takes no parameters.
  • Response Type: dateTime
Example
FX_NOW()

In this example, the function returns the current system date and time - "2025-07-01 17:29:08".

Number

LEN
Perform a string operation to return the number of characters in the given text.
Syntax
FX_LEN(text)
  • Request Type: String
  • Response Type: Integer
Example
FX_LEN("13800138000")
In this example, the function returns 11, which indicates the length of the text.
SUM
Perform an option to sum two or more 32-bit integer values.
Syntax
FX_SUM(value1,value2,...)
  • Request Type: Integer
  • Response Type: Integer
Example
FX_SUM(100,200,300)
In this example, the function sums the three values and returns 600.
SUM_LONG
Perform an operation to sum two or more 64-bit integer values.
Syntax
FX_SUM_LONG(value1,value2,...)
  • Request Type: Integer
  • Response Type: Integer
Example
FX_SUM_LONG(1000000000,2500000000)
In this example, the function sums the two values and returns 3500000000.
NEGATIVE
Perform an operation to return the negative value of a 32-bit integer.
Syntax
FX_NEGATIVE(value)
  • Request Type: Integer
  • Response Type: Integer
Example
FX_NEGATIVE(100)
In this example, the function returns -100.
NEGATIVE_LONG
Perform an operation to return the negative value of a 64-bit integer.
Syntax
FX_NEGATIVE_LONG(value)
  • Request Type: Integer
  • Response Type: Integer
Example
FX_NEGATIVE_LONG(1000000000)
In this example, the function returns -1000000000.
MULTIPLY
Perform an operation to multiply two or more 32-bit integer values.
Syntax
FX_MULTIPLY(value1,value2,...)
  • Request Type: Integer
  • Response Type: Integer
Example
FX_MULTIPLY(10,20,3)
In this example, this function returns 600.
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)
In this example, the function returns 2000000000.
DIVIDE
Perform an operation to divide the first 32-bit integer value by the second 32-bit integer value.
Syntax
FX_DIVIDE(value1,value2)
  • Request Type: Integer
  • Response Type: Integer
Example
FX_DIVIDE(100,20)
In this example, the function divides 100 by 20 and returns 5.
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)
In this example, the function divides 10000000000 by 2000000000 and returns 5.
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)
In this example, the functions returns 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)
In this example, the function returns 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)
In this example, the function returns the number of rows from the result returned by the Database Access 1 component.
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)
In this example, the function returns the number of items from the result returned by the Database Access 1 component.
JSON_GET_INTEGER

Perform an operation to retrieve an integer value from a JSON object based on the specified key.

Syntax
FX_JSON_GET_INTEGER(JSONObject,key)
  • Request Type:

    • JSONObject: String

    • key: String

  • Response Type: Integer
Example
FX_JSON_GET_INTEGER($HttpRequest1.responseContent,"httpStatus"
In this example, the function returns the value of the httpStatus key from the JSON content returned by the HTTP Request 1 component.
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
FX_TO_INTEGER("12345")
In this example, the function converts the string "12345" into the 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")
In this example, the function converts the string "1234567890123" into the integer 1234567890123.

Object

GET_TABLE_CELL_VALUE
Perform an operation to retrieve the value from a table cell at the specified row and column.
Syntax
FX_GET_TABLE_CELL_VALUE(table,row,column)
  • Request Type:
    • table: Any
    • row: Integer
    • column: Integer
  • Response Type: Object
Example
FX_GET_TABLE_CELL_VALUE($DatabaseAccess1.queryResult,0,1)
In this example, the function returns the value from the first row and second column in the result returned by the Database Access 1 component.
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)
In this example, the function returns the third item in the result returned by the Database Access 1 component.
JSON_GET_OBJECT

Perform an operation to retrieve a nested JSON object from a parent JSON object based on the specified key.

Syntax
FX_JSON_GET_OBJECT(JSONObject,key)
  • Request Type:

    • JSONObject: String

    • key: String

  • Response Type: Object
Example
FX_JSON_GET_OBJECT($HttpRequest1.responseContent,"data")
In this example, the function returns the JSON object associated with the data key from the JSON content returned by the HTTP Request 1 component.