Flows/Template Functions

Template Functions & Helpers

Built-in functions and special characters to transform and format data in your templates.

Date & Time

Date/Time Constants
Get current date and time values
{{now}}

Current timestamp in milliseconds (e.g., 1700000000000)

{{nowISO}}

ISO 8601 format (e.g., "2025-01-15T08:35:00.000Z")

{{nowDate}}

Date only (e.g., "2025-01-15")

{{nowDateTime}}

Date and time (e.g., "2025-01-15 08:35:00")

formatDate() Function
Format dates using Luxon tokens

Use the .format() method to format date values using Luxon tokens.

Works on: Built-in date constants (now, nowDate, nowISO) and date strings/objects from node outputs. For Unix timestamps, convert to date first.

{{#1.createdAt.format("yyyy-MM-dd")}}

Common Format Tokens:

yyyy - 4-digit year (2025)
yy - 2-digit year (25)
MM - 2-digit month (01-12)
M - Month (1-12)
dd - 2-digit day (01-31)
d - Day (1-31)
HH - 24-hour (00-23)
hh - 12-hour (01-12)
mm - Minutes (00-59)
ss - Seconds (00-59)
a - AM/PM
EEEE - Full weekday
MMMM - Full month name
MMM - Short month (Jan)

Examples:

  • {{nowDate.format("MMMM d, yyyy")}} -> "January 15, 2025"
  • {{#1.date.format("dd/MM/yyyy")}} -> "15/01/2025"
  • {{#1.timestamp.format("hh:mm a")}} -> "08:35 AM"

JSON Functions

JSON Functions
Parse and stringify JSON data

toJsonString()

Convert any value to a JSON string

{{#1.data.toJsonString()}}

parseJSON()

Parse a JSON string into an object

{{#1.jsonString.parseJSON()}}

escapeJSON()

Escape special characters for use inside JSON strings

{{#1.text.escapeJSON()}}

Special Characters

Special Character Constants
Insert whitespace and special characters

Use these constants to insert special characters that are hard to type or visualize.

{{space}}

Single space character

{{newline}}

Line break (\n)

{{tab}}

Tab character (\t)

{{empty}}

Empty string

{{cr}}

Carriage return (\r)

{{crlf}}

Windows line ending (\r\n)

Example - Multi-line text:

Line 1{{newline}}Line 2{{newline}}Line 3

Escape Sequences

Literal Braces
Output literal {{ }} characters

If you need to output literal curly braces without template evaluation, escape them with backslash.

Input:

\{{notATemplate\}}

Output:

{{notATemplate}}

JavaScript String Methods

Since templates are evaluated as JavaScript, you can use any standard JavaScript string method:

{{#1.name.toUpperCase()}}

Convert to uppercase

{{#1.name.toLowerCase()}}

Convert to lowercase

{{#1.text.trim()}}

Remove whitespace

{{#1.text.replace("old", "new")}}

Replace text

{{#1.text.split(",")[0]}}

Split and get first item

{{#1.text.substring(0, 10)}}

Get first 10 characters

{{#1.text.length}}

Get string length

{{#1.text.includes("search")}}

Check if contains text

Array Methods

Work with arrays using JavaScript array methods:

{{#1.items.length}}

Get array length

{{#1.items.join(", ")}}

Join with separator

{{#1.items[0]}}

Get first item

{{#1.items.slice(0, 5)}}

Get first 5 items

Math Operations

Perform calculations directly in templates:

{{#1.price * 1.1}}

Add 10%

{{#1.total / #1.count}}

Calculate average

{{Math.round(#1.value)}}

Round number

{{#1.price.toFixed(2)}}

Format to 2 decimals

Template Functions - Flows Guide - Serenities