Understand workflow helpers
Last Update: Jan 2025 • Est. Read Time: 2 MINAs you build out the steps and logic of a workflow, you may need certain actions to perform advanced or dynamic functions. For example, you may want to address a customer by their name in the body of an email, check if a text message arrived within business hours before sending an auto-response, or reformat data received from a webhook entirely.
Workflow helpers make this custom functionality possible by automating tasks and adding flexibility to your workflows through action and condition steps.
Who can access this feature? | |
User types | Admins can access the Workflows page. |
In this article
Available helpers by group
Kustomer provides various types of helpers to help you customize your workflows.
- Conditional helpers
Perform actions and generate content based on the value of an attribute. Learn more - Date & math helpers
Generate and manipulate date objects, and perform arithmetic functions and number formatting. Learn more - String modification helpers
Manipulate strings of text. Learn more - JSON data helpers
Format and extract information from JSON data. Learn more - Data validation helpers
Verify and reformat data. Learn more
Helper types
Expression helpers are a common type of helper which appear wrapped in double or triple handlebars, and output a string of text. For example, {{randomId}}
.
Block helpers are a special type of helper that use multiple expression blocks and also output a string. They are defined with an opening block (an expression marked by a hash symbol, #
), and a closing block (a second expression using a forward-slash, /
). The desired output string will typically be constructed between the opening and closing blocks. For example, {{#if true}}Hello {{steps.1.name}}{{/if}}
.
Function helpers take on a different syntax, foregoing handlebars completely. These helpers are initiated with a workflow function command (/#fn:
), and are capable of outputting both string and non-string data types. For example, /#fn:inBusinessHours
.
Note: Function helpers cannot nest or be nested in other helpers.
Use helpers in workflow data fields
In code view, standard workflow step input fields directly accept a value of the field's stated attribute value-type. They also accept any handlebars expression or workflow command.
However, a handful of input fields are designed as data fields, such as "meta", "data", "headers", "input", "error", and more. These input fields are distinct in that they use code-line numbers, and are built for constructing JSON. They accept inputs in the form of JSON objects and arrays, or quotation-wrapped blocks.
Any expression, command, or helper used in a data field must be wrapped inside quotation marks.
{"to": "/#steps.1.from", "text": "hello {{steps.1.name"}}, "date": "/#fn:dateFormat,steps.1.createdAt"}
"/#fn:dateFormat,steps.1.createdAt"
"{{steps.1.name}}"
Note: Commands and helpers wrapped in quotation marks do not automatically resolve to a string output.
Escape sequences
Some characters may necessitate the use of escape sequences in order to be processed correctly. Escape sequences are used in workflows to output literal representations of non-printing characters, or special characters that may have alternate meanings in code.
A common example, especially when working with data fields, is the use of standard quotation marks inside a string. When a string uses quotation marks to define itself, additional nested quotation marks may cause the string to break. To resolve an issue like this, the offending quotation marks must be escaped with a backslash.
{"string": "{{toUpper "one two three"}}"}
results in a broken string and an errored workflow step{"string": "{{toUpper \"one two three\"}}"}
results in an unbroken string and a successfully processed helper