LibraryDocsBlogPricing
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: "{{ event.data.email }}"

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

json
{
"data": {
"email": "whyhi@example.com"
},
"name": "test.event"
}

Then the above template will produce:

Email address: "whyhi@example.com"

You can also process data when templating:

Email address: "{{ event.data.email | trim | lower }}"

Given event.data.email is " HELLO@example.net " (with spaces around the email), this will produce "hello@example.com". Trim removes leading and trailing spaces, and lower lower-cases the input.

Templating functions

String functions (for text)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

json_encode: transforms a value into a JSON string
{{ event.name | 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