Proto Script
Last updated
Last updated
The Proto script and template language provides users with the ability to utilize simple scripting for data manipulation within the platform. This includes processing JSON API responses, modifying values in the Modify Variable block, and adding conditions in the Branch block, among other functionalities.
You can use Proto Script in the following actions:
Bot Message
Branch
Carousel
Create Case
JSON API
Hyperlink
Modify Variable
Survey
Proto Script Delimiter
{ … }
- to print out the variable/script values
Requires { … }
delimiter
Bot Message
Carousel
Create Case
Hyperlink
Survey
Do not require { … }
delimiter
Branch
JSON API
Modify Variable
_.dt_diff(datetime1, datetime2, unit)
Calculates the difference between two datetime objects and returns the result in the specified time unit. Unit - d for day, h for hour, m for minute, s for second.
Example
_.fmt(string, value)
Formats the specified value(s) and insert them inside the string's placeholder.
Example
_.format_time(datetime, format, timezone)
Format datetime.
Example
_.join(separator, items)
Join all items in a tuple into a string, using a character as a separator.
Example
_.json_parse(data)
Parses a JSON string and returns a Python object.
Example
_.json_stringify(data)
Serializes Python objects into JSON format. It returns a JSON string representing the input data.
Example
_.len(x)
The number of characters in a variable.
Example
_.lower(string)
Convert string to lowercase.
Example
_.now(timezone, format)
Retrieves the current date and time in the Coordinated Universal Time (UTC) timezone. If a timezone is define, it would display the current year and hour based on the timezone, formatted as a string. If a dateime format code is define, it will output based on the format set.
Example
_.replace(string, search, replacement)
Replaces a specified phrase with another specified phrase.
Example
_.split(string, separator)
Split a string into a list where each word is a list item.
Example
_.str2datetime(timestring, format)
Convert string to datetime.
Example
_.upper(string)
Convert string to uppercase.
Example
_.as_int(string)
Convert string to integer.
Example
_.as_float(string)
Convert string to float.
Example
_.as_str(string)
Convert specified value to string.
Example
_.round_num(number,precision)
Returns a floating point number that is a rounded version of the specified number.
Example
_.random_num(min,max)
Returns an integer number selected element from the specified range.
Example
_.random_choice(list)
Returns a randomly selected element from the specified sequence. The sequence can be a string, a range, a list, a tuple, or any other kind of sequence.
Example
_.match_pattern(string, pattern)
Search the regular expression pattern and return the first occurrence.
Example
_.obj_keys(dictionary)
Takes a dictionary as input and returns a list containing all the keys from the input dictionary.
Example
_.obj_values(dictionary)
Takes a dictionary as input and returns a list containing all the values from the input dictionary.
Example
_.get(dictionary, path)
Retrieves the value at a specified path within a nested dictionary or list.
Example
_.map_get(list[dict], path)
Maps the get function over a list of dictionaries. It retrieves the value at a specified path within each dictionary in the list.
Example