Log inSign up for free →

Using data via templating

On this page
  1. 1. Templating overview
  2. 2. Templating functions
  3. 3. Developers: The templating engine

Now that we know what data is available (event, action, and user), let's talk about how you can use that data when configuring actions within a workflow.

If you're writing custom actions and want to access this data, read our documentation on actions.

Templating overview

Firstly, it's important to understand that actions are reusable. For example, we provide a built-in "HTTP" action that makes (you guessed it) HTTP requests. You can configure this action when you use it in a workflow, changing the URL, body, and headers that are sent each time you use the action.

When you want to use data within an action's configuration, you must use templating to reference data.

Here's an example:

Email address: "{{ }}"

This replaces the text in quotes, using the email field in event data. If this workflow runs with the following event:

"data": {
"email": ""
"name": "test.event"

Then the above template will produce:

Email address: ""

You can also process data when templating:

Email address: "{{ | trim | lower }}"

Given is " " (with spaces around the email), this will produce "". Trim removes leading and trailing spaces, and lower lower-cases the input.

Templating functions

String functions (for text)

lower: lowercase the string
{{ | lower }}
Input: "HI", output: "hi"

upper: uppercase the string
{{ | upper }}
Input: "hi", output: "HI"

capitalize: capitalize the first letter, and lowercase every other letter
{{ | capitalize }}
Input: "HELLO there", output: "Hello there"

title: capitalize each word
{{ | title }}
Input: "hi there", output: "Hi There"

replace: replace parts of the text with something else
{{ | replace(from="Hello", to="Hola") }}
Input: "Hello there", output: "Hola there"

addslashes: adds slashes before quotes
{{ | addslashes }}
Input: "I'm excited!", output: "I\'m excited!"

slugify: transforms the string into a url slug
{{ | slugify }}
Input: "Status: in progress", output: "status-in-progress"

trim: remove leading and trailing whitespace
{{ | trim }}
Input: " hi ", output: "hi"

trim_start: remove leading whitespace
{{ | trim }}
Input: " hi ", output: "hi "

trim_end: remove trailing whitespace
{{ | trim }}
Input: " hi ", output: " hi"

truncate: truncate the string to a given length
{{ | truncate(length=3, end="...") }}
Input: "Longer than three", output: "Lon..."

striptags: removes HTML tags from the input
{{ | striptags }}
Input: "<b>hi!</b>", output: "hi!"

escape: escapes HTML
{{ | urlencode }}
Input: "<b>hi!</b>", output: "&lt;b&gt;hi!&lt;&#x2F;b&gt;"

length: returns the string length
{{ | length }}
Input: "hi!", output: 3

reverse: reverses the string
{{ | reverse }}
Input: "hi!", output: "!ih"

urlencode: percent-encodes non-url safe characters
{{ | urlencode }}
Input: "why hi", output: "why%20hi"

json_encode: transforms a value into a JSON string
{{ | json_encode(pretty=false) }}
Input: "why hi", output: ""why hi""

Developers: The templating engine

Under the hood, our templating is based off of the extremely powerful rust templating engine Tera. We've made some changes to the engine such that it doesn't error when fields are invalid (they become blank), and we've made some changes to compile the engine down to webassembly.

This lets us use the templating engine on the backend, and also lets us use the same templating engine in the UI to preview templates.

    On this page
  1. 1. Templating overview
  2. 2. Templating functions
  3. 3. Developers: The templating engine