Skip to main content
The Functions in Keep Workflow Engine are utilities that can be used to manipulate data, check conditions, or perform transformations within workflows. This document provides a brief overview and usage examples for each available function.

Mathematical Functions

add

Description: Adds all provided numbers together. All arguments are converted to integers. Example:

sub

Description: Subtracts all subsequent numbers from the first number. All arguments are converted to integers. Example:

mul

Description: Multiplies all provided numbers together. All arguments are converted to integers. Example:

div

Description: Divides the first number by all subsequent numbers. All arguments are converted to integers. Returns an integer if the division result is whole, otherwise returns a floating-point number. Example:

mod

Description: Calculates the remainder of dividing the first number by all subsequent numbers sequentially. All arguments are converted to integers. Example:

exp

Description: Raises the first number to the power equal to the product of all subsequent numbers. All arguments are converted to integers. Example:

fdiv

Description: Performs integer division of the first number by all subsequent numbers sequentially. All arguments are converted to integers. Example:

eq

Description: Checks if two values are equal. Example:

String Functions

uppercase

Description: Converts a string to uppercase. Example:

lowercase

Description: Converts a string to lowercase. Example:

capitalize

Description: Capitalizes the first character of a string. Example:

title

Description: Converts a string to title case (capitalizes each word). Example:

split

Description: Splits a string into a list using a delimiter. Example:

strip

Description: Removes leading and trailing whitespace from a string. Example:

replace

Description: Replaces occurrences of a substring with another string. Example:

remove_newlines

Description: Removes all newline and tab characters from a string. Example:

encode

Description: URL-encodes a string. Example:

slice

Description: Extracts a portion of a string based on start and end indices. Example:

List and Dictionary Functions

first

Description: Retrieves the first element from a list. Example:

last

Description: Retrieves the last element from a list. Example:

index

Description: Retrieves an element at a specific index from a list. Example:

join

Description: Joins a list of elements into a string using a delimiter. Example:

len

Description: Returns the length of a list. Example:

dict_to_key_value_list

Description: Converts a dictionary into a list of key-value pairs. Example:

dict_pop

Description: Removes specified keys from a dictionary. Example:

dict_pop_prefix

Description: Removes all keys that start with a specified prefix from a dictionary. Example:

dict_filter_by_prefix

Description: Returns only the dictionary entries whose keys start with a specified prefix. Example:

dictget

Description: Gets a value from a dictionary with a default fallback. Example:

Date and Time Functions

from_timestamp

Description: Converts unix timestamp int, float or string to datetime object, with optional timezone option. Example:

utcnow

Description: Returns the current UTC datetime. Example:

utcnowtimestamp

Description: Returns the current UTC datetime as a Unix timestamp (seconds since epoch). Example:

utcnowiso

Description: Returns the current UTC datetime in ISO format. Example:

to_utc

Description: Converts a datetime string or object to UTC. Example:

to_timestamp

Description: Converts a datetime object or string into a Unix timestamp. Example:

datetime_compare

Description: Compares two datetime objects and returns the difference in hours. Example:

is_business_hours

Description: Checks whether a given time falls within business hours. Example:

JSON Functions

json_dumps

Description: Converts a dictionary or string into a formatted JSON string. Example:

json_loads

Description: Parses a JSON string into a dictionary. Example:

Utility Functions

get_firing_time

Description: Calculates the firing duration of an alert in specified time units. Example:

add_time_to_date

Description: Adds time to a date string based on specified time units. Example:

timestamp_delta

Description: Adds or subtracts a time delta to/from a datetime. Use negative values to subtract time. Example:

is_first_time

Description: Checks if an alert with a given fingerprint is firing for the first time or first time within a specified period. Example:

all

Description: Checks if all elements in an iterable are identical. Example:

diff

Description: Checks if any elements in an iterable are different (opposite of all). Example: