Built-in scenario functions
Overview
Functions are used as arguments by script components. They allow you to calculate specific values and even perform operations on the system.
Functions are categorized into:
-
clean
- the return value depends only on the parameters. -
with site-effects
- the return value may vary depending on the system state. -
modifiers
- makes changes to the system.
Components use arguments all the time, arguments can be represented as expressions, expressions can use functions.
Categories of functions
Category | Description |
---|---|
Pure mathematical functions. |
|
Pure functions to handle strings. |
|
Clean date and time functions and side-effect functions to access the current time. |
|
Pure value conversion, encoding, packaging, and representation functions. |
|
Pure hash functions. |
|
Clean functions to handle file paths and directory categories. |
|
Various functions for bidirectional access to context and state. |
|
Side-effect functions of special access to variables. |
|
Side-effect functions to retrieve data from the system configuration. |
|
Pure constant substitution functions. |
|
Pure symbol substitution functions. |
|
Side-effect call data access functions and queue state modifiers. |
Function catalog
Function | Parameters | Description |
---|---|---|
|
|
Sine of a number |
|
|
Cosine of a number |
|
|
Tangent of a number |
|
|
The arcsine of a number |
|
|
Arccosine of a number |
|
|
The arctangent of a number |
|
|
The arctangent of the quotient of two numbers |
|
|
Hyperbolic sine of a number |
|
|
Hyperbolic cosine of a number |
|
|
The hyperbolic tangent of a number |
|
|
Exponent of the number |
|
|
The natural logarithm of a number |
|
|
The binary logarithm of a number |
|
|
The decimal logarithm of a number |
|
|
The result of raising one number to the power of another |
|
|
The square root of a number |
|
|
Error Function: Not available on Windows |
|
|
Not available on Windows |
|
|
The maximum of two numbers |
|
|
The minimum of two numbers |
|
|
The result of discarding the fractional part of a number |
|
|
The result of rounding a number to an integer |
|
|
Absolute value of the number |
|
|
The integer nearest to the bottom |
|
|
Nearest integer from above |
|
|
The decimal logarithm of a number |
|
|
The natural logarithm of a number |
|
|
The logarithm of one number by the base of another number |
|
|
Square the number |
|
A random decimal number from |
|
|
|
A random integer from 0 to the specified integer |
|
|
Ca random integer in the range between two integers |
Function | Parameters | Description |
---|---|---|
|
Returns the generated UUID identifier. |
|
|
|
Returns the length of the string in characters. |
|
|
Returns the result of concatenating two strings. |
|
|
The result of comparing two strings: |
|
|
Returns the position index of the first occurrence of the substring (n2) in the string (n1). Returns |
|
|
Returns the position index of the last occurrence of the substring (n2) in the string (n1). Returns |
|
|
Returns the substring from the specified position (n2) to the end. |
|
|
Returns a substring from the specified position (p2) of no more than the specified length (p3). |
|
|
Returns the result of replacing occurrence (n1) in the string (n2) by the value (n3). |
|
|
Returns the string in lower case. |
|
|
Returns a string in uppercase. |
|
|
Returns the string after removing a substring from it from the specified position (n2) to the end. |
|
|
Returns a string after removing a substring from it from the specified position (n2) of the specified length (n3). |
|
|
Returns the position index of the first occurrence of the substring (n2) in the string (n1). Returns |
|
|
Returns the position index of the first occurrence of the substring (n2) in the string (n1), starting from the specified position (n3). Returns |
|
|
Returns a string spared of blank characters at the beginning and end (space, tab, etc). |
|
|
Returns a string spared from empty characters at the beginning (space, tab, etc.). |
|
|
Returns a string spared of empty characters at the end (space, tab, etc.). |
|
|
Returns a string spared from empty characters at the beginning (space, tab, etc.). |
|
|
Returns a string spared of empty characters at the end (space, tab, etc.). |
|
|
Returns the left side of a string of no more than the specified length. |
|
|
Returns the right side of a string of no more than the specified length. |
|
|
Returns the inverted string. |
|
|
Returns the result of replacement using a regular expression. n1 - value, n2 - pattern, n3 - replacement. |
|
|
Returns the result of replacement using a regular expression with the |
|
|
Returns the modified json structure. Applies the search query (n1) to the value (n2), modifies the detected element according to the options (n3) and returns the total result. Example:
modify_json( "chat/0/msgs", '{"chat":[{"msgs":[{"txt":"abc"}]}]}', '{"action":"append","value":{"txt":"zcv"}}' ) Options are represented as a json object with the mandatory
|
Function | Parameters | Description |
---|---|---|
|
Returns a number representing the absolute value in milliseconds since 1970. |
|
|
Returns the current date and time in the server’s local time zone in RFC3339 format. For example, |
|
|
Returns the current date and time in UTC in the format RFC3339. |
|
|
Returns the number of seconds in the Gregorian calendar, from A.D. 0. |
|
|
|
Returns the date in the server’s local time zone by absolute value tick. |
|
|
Returns the date in UTC by absolute value tick. |
|
|
Converts the date to unix timestamp |
|
|
Returns a string from a date representation (n2) using the specified format (n1). For example: Possible placeholders for the formatting string: |
|
Returns the current date in the server’s local time zone without specifying a time zone. Format |
|
|
|
Returns the date from the specified date/time. |
|
Returns the current time in the local time zone of the server without specifying a time zone. The format is |
|
|
|
Returns the time from the specified date/time. |
|
|
Returns the date/time generated by the string. A string can contain various date/time representations, including RFC3339. |
|
|
Returns the date/time based on the passed p1 - year, p2 - month, p3 - day. |
|
|
Returns the date/time based on the passed p1 - year, p2 - month, p3 - day, p4 - hour, p5 - minute. |
|
|
Returns the date/time based on the passed p1 - year, p2 - month, p3 - day, p4 - hour, p5 - minute, p6 - second. |
|
|
Returns the date/time based on the passed p1 - year, p2 - month, p3 - day, p4 - hour, p5 - minute, p6 - second, and p7 - millisecond. |
|
|
Returns the number of specified time units between two dates. The parameter is specified as an atom (not a string), e.g. Possible types of units in descending order: |
|
|
Returns the date after adding the specified number (n2) of specified time units (n1) to the specified date/time (n3). The parameter is specified as an atom (not a string), e.g. Possible types of units in descending order: |
|
|
Returns the current year of the specified date/time. |
|
|
Returns the current month ( |
|
|
Returns the current day ( |
|
|
Returns the current hour ( |
|
|
Returns the current minute ( |
|
|
Returns the current second ( |
|
|
Returns the current millisecond ( |
|
|
Returns the day number in the year for the specified date/time. |
|
|
Returns the day of the week number ( |
|
|
Returns the week number in the year for the specified date/time. |
|
|
Returns |
|
|
Returns the date/time converted to the local time zone of the server. Numerical values of date/time are not changed, but the absolute time point can be shifted after changing the time zone to local time zone. |
|
|
Returns the date/time converted to UTC. Numerical date/time values are not changed, but the absolute time point may be shifted after changing the timezone to zero. |
|
|
Returns the UTC date/time for the specified date/time considered in the server’s local time zone. |
|
|
Returns the local date/time for the specified date/time, treated as a UTC. |
|
|
Returns |
Function | Parameters | Description |
---|---|---|
|
|
Returns a string with a single character by its numeric code. |
|
|
Converts a numeric value to a string. |
|
|
Converts a string to a number. If it fails, it terminates with an error. |
|
|
Converts a string to a number by cutting off the end of unsuitable characters. In the limit, returns |
|
|
Returns a string with a HEX representation of the number. |
|
|
Returns a number based on its HEX representation. |
|
|
Returns the string resulting from packing into Base64 representation. |
|
|
Returns the string resulting from decompression from the Base-64 representation. |
|
|
Returns the string encoded with the UrlEncode. |
|
|
Returns the string decoded using the UrlEncode. |
|
|
Returns the string encoded by c Unicode Hex Character Code. |
|
|
Returns the string decoded by c Unicode Hex Character Code |
|
|
Returns the string resulting from the conversion to escape-sequence. Used for inserting into JSON. |
|
|
Returns the string resulting from unpacking from an escape sequence. Used for cleanup after JSON. |
|
|
Returns the result of transliteration of the string. |
|
|
If the value of the first parameter is |
Function | Parameters | Description |
---|---|---|
|
|
Returns the hash of a string using the algorithm MD5. |
|
|
Returns the hash of any value using the algorithm CRC32 (IEEE 802.3). |
|
|
Returns the new hash value from the previous value combined with the new portion. n1 is the previous hash value, n2 is the new data portion. According to the algorithm CRC32 (IEEE 802.3). |
|
|
Returns the hash of any value using the algorithm Adler-32. |
|
|
Returns the new hash value from the previous value combined with the new portion. n1 is the previous hash value, n2 is the new data portion. According to the algorithm Adler-32. |
|
|
Returns the hash sum from any value using an internal algorithm. |
Function | Parameters | Description |
---|---|---|
|
|
Returns the path type (category prefix from the specified path). |
|
|
Returns the relative path (the specified path without the category prefix). |
|
|
Returns the filename selected from the specified path. |
|
|
Returns the file extension selected from the specified path. |
|
|
Returns the name of the directory. For a file path it is the name of the directory, for a directory path it is the name of the parent directory. |
|
|
Returns the path formed as a result of meshing two parts. |
|
|
Returns the path generated by concatenating three parts: path, filename, and file extension. |
|
Returns |
|
|
Returns |
|
|
||
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
Function | Parameters | Description |
---|---|---|
|
|
Returns the value of the input parameter with the specified index. Scenarios can accept up to 20 input parameters. |
|
Returns a string containing the identifier of the current script handler. This identifier can be used to send messages to the handler by other script handlers, e.g. using Script Interaction. |
|
|
Returns a string containing the project ID of the currently running script. |
|
|
|
|
|
|
|
|
|
Executes a component of the specified type from the group of service script components. The first parameter is the component type (numeric number or key from the module name, for example 103 or pause), the second parameter is the component properties from the documentation except for transition branches and variables for output values (can be erlang:map() or erlang:proplist() or binary() with JSON). Returns an object with the keys of output variable fields and additionally "transferKey", the format of the returned value is the same as the format of the second parameter. |
|
|
Executes a component of the specified type from the service script component group. The first parameter is the component type (numeric number or key from the module name, e.g. 103 or pause). The second parameter is the component properties from the documentation except for the transition branches and variables for the output values (could be erlang:map() or erlang:proplist() or binary() with the JSON). The third parameter sets the format of the returned value (map, proplist, json). Another third parameter can order the output of a value by a specific key from the result (for example, to return a value usually stored in the output variable of a component). Also the third parameter can set the mode of returning a string glued from transferKey and varValue values (format "TransferKeyValue;OtherKeyValue"), for this purpose it is necessary to specify without quotes as the third parameter: "{transfer,Key}". Returns an object with the keys of the output variable fields and optionally "transferKey", or a value on a specific key from this object. Examples: ---- component(notify, #{mode ⇒ 0, text ⇒ [a1], user ⇒ <<"admin">>}, map) component(111, #{<<"mode">> ⇒ 0, <<"text">> ⇒ <<"Something">>, <<"user">> ⇒ <<"admin">>}, json) component(111, <<"\"mode\": 0, \"text\": \"Something\", \"user\": \"admin\"">>, <<"transferKey">>) component(parser, #{algoritm ⇒ 0, functionJSON ⇒ 0, data ⇒ <<"{\\\"a\\\":\\\"value\\\"}">>, query ⇒ <<"a">>}, {transfer,<<"resultVariable">>}) ---- Component codes and fields are available in the documentation on the respective component pages. One possible way is to set up a new script with a component that has the settings of interest, and copy its contents from the JSON script. |
|
|
Expects and blocks a critical section (analog of the Mutex component). The first parameter is the unique name of the critical section. The second parameter is the waiting time in milliseconds before timeout. Returns "ok", "timeout", "error". |
|
|
Expects and blocks a critical section (analog of the Mutex component). The first parameter is the unique name of the critical section. The second parameter - waiting time in milliseconds before timeout. The third parameter - type of operation under lock (1 or read - read, 2 or write - write). The fourth parameter is the time in milliseconds after which the critical section will be automatically released. Returns "ok", "timeout", "error". |
|
|
Releases a critical section (analog of the Mutex component). Returns "ok" or "error". |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Function | Parameters | Description |
---|---|---|
|
|
Returns |
|
|
Returns the value of a variable by its name. |
|
|
Returns the value of the variable by its name, or if no value is set, the default value from the second parameter. |
|
|
Returns a string containing the variable identifier of the variable by its name. |
|
|
Returns the value of a variable by its name, and if the value is string, it is returned in its original encoding without conversion. |
|
|
Sets the value of a variable by its name if its value is not specified. Returns the value of the variable as a result of the operation. |
|
|
Returns the value of a variable by its name. |
|
|
Extends or places a value (2 parameter) on a key (1 parameter) for 2 days in the data store on the site. Returns "ok". If the storage is unavailable, returns "error". |
|
|
Extends or places a value (2 parameter) on a key (1 parameter) for the specified number of seconds (3 parameter) in the data store on the site. Returns "ok". If the storage is unavailable, returns "error". |
|
|
Returns a key value from the data store on the site, or a default value if none is available. If the storage is unavailable, returns "error". |
|
|
Deletes the value by the specified key from the data storage on the site. If the storage is unavailable, returns "error". |
Reading and modifying an existing value in the repository when working in parallel mode should be done in a critical section, such as that built by the "Mutex" component or expression functions lock/unlock. |
Function | Parameters | Description |
---|---|---|
|
Returns the URL of the nearest available server with the logical role ws. |
|
|
Returns the site where the script is executed. |
|
|
Returns the domain in which the script is executing. |
|
|
Returns the parent domain relative to the one in which the script is executed. |
|
|
Returns |
|
|
|
Returns In the format of |
Function | Parameters | Description |
---|---|---|
|
Returns a number |
|
|
Returns a number |
|
|
Returns a number |
Function | Parameters | Description |
---|---|---|
|
Returns a string containing a tab character. |
|
|
Returns a string with an end-of-line character. |
|
|
Returns a string containing a quote character. |
|
|
Returns a string containing a double-quote character. |
Function | Parameters | Description |
---|---|---|
|
|
Returns the value of the specified parameter from the Available only for calls received in the IVR. |
|
Returns a string with the number dialed by the subscriber from the INVITE that got routed. ATTENTION: For calls coming from outside (from connections to providers), this number is generally not the same as the one that received the external call. For the latter, use the function calledid(). Available only for calls received in the IVR. To get the subscriber’s number when making outgoing calls with ivr (component 'Outgoing Call', API 'invite_byivr'), it is necessary to use IVR script parameters (startparam(N)) and pass the necessary information through them. |
|
|
Returns a string with the extension CAF, which the call was received at IVR. Contains the entire postfix after the ficacode number has been removed. Available only for calls received in the IVR. To get the subscriber’s number when making outgoing calls with ivr (component 'Outgoing Call', API 'invite_byivr'), it is necessary to use IVR script parameters (startparam(N)) and pass the necessary information through them. |
|
|
Returns a string containing the subscriber number generated by applying presentation rules, either the internal subscriber number of the current domain or username from the From header of the request received for routing INVITE. NOTE: For calls coming in from outside (from ISP connections), this number is generally not the same as the one from which the outside call came, as it may be converted normalization rules. For the latter, use the function callerid(). Available only for calls received in the IVR. To get the subscriber’s number when making outgoing calls with ivr (component 'Outgoing Call', API 'invite_byivr'), it is necessary to use IVR script parameters (startparam(N)) and pass the necessary information through them. |
|
|
Returns a string with the number dialed by the subscriber. For calls received externally from the provider, contains the username header To of the original received INVITE request before normalization and routing rules are applied. Available only for calls received in the IVR. |
|
|
Returns a string with the number dialed by the subscriber. For calls received externally from the provider, contains username header From the original received INVITE request before normalization, routing, and presentation rules are applied. Available only for calls received in the IVR. |
|
|
Returns a string with the value of the |
|
|
Returns a string containing the current session native identifier (NID), retrieving it from the current call’s labels. If executed at the very beginning of the first call, can delay execution for up to 500 ms while waiting for a session to be assigned. |
|
|
Returns a string containing the current session identifier (SI), identifying it in the session store by native session label. If executed at the beginning of the first call, this function can delay execution for up to 500 ms while waiting for a session to be assigned. |
|
|
Returns a string with the value of the specified Available only for calls received in the IVR. |
|
|
Returns a string containing the identifier of the hunt-group entity the call is directed to. Available only for calls received in the IVR via a featurecode with type |
|
|
Returns a string containing the runtime-object identifier of the hunt-group queue. Available only for calls received in the IVR via a featurecode with type |
|
|
Returns the current numeric value of the priority in the queue. Available only for calls received in the IVR via a featurecode with type |
|
|
|
Sets a new numeric priority value in the queue, and the queue is automatically moved. Available only for calls received in the IVR via a featurecode with type |
|
Returns the current position in the queue. Available only for calls received in the IVR via a featurecode with type |
|
|
Available only for calls received in the IVR via a featurecode with type |
|
|
Returns the number of operators in the hunt group. Available only for calls received in the IVR via a featurecode with type |
|
|
|
Returns the number of operators in the hunt group that are in state ( Available only for calls received in the IVR via a featurecode with type |
|
Returns a string with the name of the queue pending state. Available only for calls received in the IVR via a featurecode with type |
|
|
Returns the displayname from the URI of the Available only for |
|
|
Returns username from the URI of the Available only for |
|
|
Returns the domain from the URI of the Available only for |
|
|
Returns a string containing the operator call number (username from the URI of the Available only for |