Now the Assign Value node supports general operation to be assigned as a value. This is a big improvement because you can use various types of functions as well as basic calculations.

To use this feature, create an Assign Value node and click 'Add Variable', select the target variable, then select 'Operation' as a type. Then you're all ready to type in operation.

As you see in the example above, you can use variables to be included in operation. And here are the calculations and the functions you can use in operation.

Basic Calculations

  • +, -, *, /, ( )
  • % (modulus)
    Example: 100%2 = 0, 100%8 = 4.
  • ** (power)
    Example: 100**2 = 10,000.

Basic Functions

Any function works with function() format. For example, abs(-5).

  • to_number: Converts the value to number format.
    Example: to_number('4') = 4
  • to_string: Converts the value to string format.
    Example: to_string(7) = '7'
  • to_boolean: Converts the value to boolean format.
    Example: to_boolean(1) = True
  • length: Returns the length of the value.
    Example: length('abcde') = 5
  • abs: Returns the absolute value of the value.
    Example: abs(-5) = 5
  • sin, cos, tan: Returns sin, cos, tan of the value.
    Example: tan(90) = 1
  • ceil, floor, round: Returns round up, round down, or round value.
    Example: floor(2.1) = 2
  • random, random_int: random() returns random number value between 0 and 1. random_int(min, max) returns a random whole number value between the min and the max values.
    Example: random_int(-1, 2) = -1, 0, 1, or 2
  • unix_timestamp:  Returns Unix timestamp value.
    Example: unix_timestamp() = 1601672447

Advanced Functions

A lot of the advanced functions are used to manage JSON or String List type variables. Again, you can replace any value with a matching type of variable. Don't forget to use quotation marks when you use any string value in the function (for example, 'Allganize').

dict

  • Format: dict(key1, value1, key2, value2, ...)
  • Create a JSON type variable's value structure using the key and value pairs. The function overwrites the values if the key exists.
  • Variable type to assign the value: JSON
  • Example: When @NAME variable has 'Allganize' as the value, dict('Name',@NAME,'Email','test@allganize.ai') = {'Name':'Allganize', 'Email':'test@allganize.ai'}

dict_set

  • Format: dict_set(@JSON_variable, key1, value1, key2, value2...)
  • Add the keys and the values to the JSON variable. The function overwrites the values if the key exists.
  • Variable type to assign the value: JSON
  • Example: When @JSON_VAR has {'Name':'Allganize'} as the value, dict_set(@JSON_VAR,'Email','test@allganize.ai') = {'Name':'Allganize', 'Email':'test@allganize.ai'}

dict_del

  • Format: dict_del(@JSON_variable, key)
  • Deletes the key from the JSON variable.
  • Variable type to assign the value: JSON
  • Example: When @JSON_VAR has {'Name':'Allganize', 'Email':'test@allganize.ai'} as the value, dict_del(@JSON_VAR,'Email') = {'Name':'Allganize'}

dict_update

  • Format: dict_update(JSON_variable_1, JSON_variable_2)
  • Merge the two JSON variables. If there's the same key in both JSON variables, the latter one's value has priority.
  • Variable type to assign the value: JSON
  • Example: When @JSON_VAR has {'Name':'Allganize', 'Email':'test@allganize.ai'}, and @JSON_VAR2 has {'Name':'Alli', 'Type':'AnswerBot'}, dict_update(@JSON_VAR, @JSON_VAR2) = {'Name':'Alli', 'Email':'test@allganize.ai', 'Type':'AnswerBot'}

list

  • Format: list(string1, string2, ...)
  • Create a String List type variable with the strings.
  • Variable type to assign the value: String List
  • Example: list('Allganize', 'Test') = ['Allganize', 'Test']

list_append

  • Format: list_append(@string_list_variable, string1, string2, ...)
  • Add the strings to the string variable.
  • Variable type to assign the value: String List
  • Example: When @STR_LIST has ['Allganize', 'Test'] as the variable value, list_append(@STR_LIST,"Alli") = ['Allganize', 'Test', 'Alli']

list_reverse

  • Format: list_reverse(@string_list_variable)
  • Reverse the order of values in a string list variable.
  • Variable type to assign the value: String List
  • Example: When @STR_LIST has ['Allganize', 'Test'] as the variable value, list_reverse(@STR_LIST) = ['Test', 'Allganize']

get_by_json_path

  • Format: get_by_json_path(@JSON_variable, JSON_path)
  • Returns the value in the JSON path from the JSON variable.
  • Variable type to assign the value: String
  • Example: When @JSON_VAR has {'Name':'Allganize', 'Email':'test@allganize.ai'} as the value, get_by_json_path(@JSON_VAR, '$.Email') = 'test@allganize.ai'

contains

  • Format: contains(@string_list_variable, string)
  • Returns a boolean value after checking if the string list variable has the string value.
  • Variable type to assign the value: Boolean, String
  • Example: When @STR_LIST has ['Allganize', 'Test'] as the variable value, contains(@STR_LIST, 'Allganize') = 'True'

append

  • Format: append(@string_list_variable, string)
  • Add the string value to the string list variable.
  • Variable type to assign the value: String List
  • Example: When @STR_LIST has ['Allganize', 'Test'] as the variable value, contains(@STR_LIST, 'Variable') = ['Allganize', 'Test', 'Variable']

unique

  • Format: unique(@string_list_variable)
  • Remove duplicated values from the string list variable.
  • Variable type to assign the value: String List
  • Example: When @STR_LIST has ['Allganize', 'Test', 'Test'] as the variable value, unique(@STR_LIST) = ['Allganize', 'Test']

urlencode

  • Format: urlencode(@JSON_variable)
  • Convert the JSON variable to a URL encoded form.
  • Variable type to assign the value: String
  • Example: When @JSON_VAR has {'key':'hello world!'} as the variable value, urlencode(@JSON_VAR) = 'key=hello+world%21'

regex_sub, regex_isub

  • Format: regex_sub(regex_pattern, string1, string2) or regex_isub(regex_pattern, string1, string2)
  • Replace regex pattern in the string 2 with string 1. regex_sub is case sensitive, regex_isub is not.
  • Variable type to assign the value: String
  • Example: When @STR has 'ooAoO' as the variable value, regex_isub(r'o{2}', 'A', @STR) = 'AAA'

date_format

  • Format: date_format(regex_date_format, date)
  • Convert the date to the regex date format.
  • Variable type to assign the value: String
  • Example: When @DATE (Date or String variable) has '2020-01-11' as the variable value, date_format(r'%Y-%m', @DATE) = '2020-01'

find_all, find_iall

  • Format: find_all(regex_pattern, string) or find_iall(regex_pattern, string)
  • Find and return the first matching result with the regex pattern from the string. find_all is case sensitive, find_iall is not.
  • Variable type to assign the value: String
  • Example: When @STR has 'Type of the OS: Windows' as the variable value, find_iall(r'(windows|mac|linux)', @STR) = 'Windows'

substr

  • Format: substr(string, number)
  • Return the first [number] characters from the string.
  • Variable type to assign the value: String
  • Example: When @STR has '3months' as the variable value, substr(@STR, 2) = '3m'

Learn More About Allganize's Technology