Expression Syntax
An expression is JavaScript inside {{ }}. Modern syntax works: arrow functions, template literals, optional
chaining (?.), nullish coalescing (??), destructuring, spread, and the standard built-ins such as Math,
JSON, Date, String, Array and Object methods.
Reading data
Use bracket notation with the node's name. It works for every name, including names with spaces:
{{ $nodes['HTTP Request'].body.user.email }}
{{ $nodes['Parse Response'].items[0].id }}
Dot notation works for names that are valid JavaScript identifiers:
{{ $nodes.Webhook.body.orderId }}
The payload that started the run is always available as $trigger:
{{ $trigger.body.orderId }}
{{ $trigger.headers['x-request-id'] }}
Use optional chaining when a value may be missing, so the expression returns undefined instead of failing:
{{ $nodes['Get User'].body?.address?.city ?? 'Unknown' }}
Text
{{ $trigger.body.email.trim().toLowerCase() }}
{{ $nodes['Get User'].firstName + ' ' + $nodes['Get User'].lastName }}
{{ `Order #${$trigger.body.orderId} from ${$trigger.body.customer.name}` }}
{{ $trigger.body.sku.split('-')[0] }}
Multi-line text
To build a message with line breaks, use \n inside a string, as in JavaScript. \t (tab), \\ (a backslash),
\' and \" (quotes) and é (any character by its code) work too:
{{ 'Order ' + $trigger.body.orderId + ' is ready.\nTracking: ' + $trigger.body.tracking }}
{{ $nodes['Fetch Orders'].body.items.map(i => '- ' + i.quantity + ' × ' + i.title).join('\n') }}
{{ `Hi ${$trigger.body.name},
Thanks for your order.` }}
The second line turns a list of items into one line per item, ready for a Slack message, an email or a ticket.
A line break typed with Enter inside the quotes also counts as \n. Escapes work the same in every field,
including the text fields of a JSON body, and the preview shows what the run will send.
Numbers
{{ $nodes['Cart'].subtotal * 1.2 }}
{{ Math.round($nodes['Quote'].amount) }}
{{ $nodes['Quote'].amount.toFixed(2) }}
{{ Number($trigger.query.page ?? '1') + 1 }}
Conditions
{{ $trigger.body.status === 'paid' ? 'Ship it' : 'Wait' }}
{{ $vars.retries ?? 0 }}
{{ $if($vars.vip, 'priority', 'normal') }}
{{ $ifEmpty($trigger.body.name, 'Anonymous') }}
Lists
{{ $nodes['Fetch Orders'].body.items.length }}
{{ $nodes['Fetch Orders'].body.items.map(o => o.id) }}
{{ $nodes['Fetch Orders'].body.items.filter(o => o.total > 100) }}
{{ $nodes['Fetch Orders'].body.items.map(o => o.email).join(', ') }}
{{ $sum($nodes['Fetch Orders'].body.items, 'total') }}
Objects and JSON
Return an object from a single expression by writing an object literal. Blokkio treats { … } as an object, not
as a code block:
{{ { id: $trigger.body.id, email: $trigger.body.email, source: 'webhook' } }}
{{ JSON.stringify($nodes['Get User'].body) }}
{{ JSON.parse($nodes['Read File'].text).settings.theme }}
{{ Object.keys($trigger.headers) }}
In a template, objects and arrays are inserted as JSON automatically, so {{ $nodes['Get User'].body }} inside
a text field already produces JSON text.
Dates
$now and $today are DateTime values, and $dt() turns a string or timestamp into one. See
Helper functions.
{{ $now.toISO() }}
{{ $today.minus({ days: 1 }).toISODate() }}
{{ $dt($trigger.body.createdAt).setZone('Europe/Paris').toFormat('dd LLL yyyy, HH:mm') }}
{{ $now.diff($dt($trigger.body.createdAt), 'hours') > 24 }}
Secrets
Bearer {{ $secrets.API_TOKEN }}
{{ $secrets['stripe-key'] }}
Write the secret's name literally. Names that aren't valid identifiers (with -, for example) need bracket
notation. See Context variables.
Multi-line expressions
An expression can span several lines:
{{
$nodes['Fetch Orders'].body.items
.filter(o => o.status === 'paid')
.map(o => o.total)
.reduce((a, b) => a + b, 0)
}}
You can also use statements. The result is the value of the last expression; don't use a top-level
return:
{{
const items = $nodes['Fetch Orders'].body.items;
const paid = items.filter(o => o.status === 'paid');
paid.length
}}
If you prefer return, wrap the code in a function and call it:
{{ (() => {
const items = $nodes['Fetch Orders'].body.items;
if (items.length === 0) return 'none';
return items.length > 10 ? 'many' : 'some';
})() }}
}} inside a string, such as {{ 'a}}b' }}, and nested braces in object literals are handled correctly.
For anything longer than a few lines, a Code node is easier to read and test.
Common patterns
Build a URL:
https://api.example.com/users/{{ $nodes['Get User'].body.id }}/orders?limit={{ $vars.pageSize ?? 50 }}
Pass a whole object as a JSON body (single expression, so it stays an object):
{{ { customerId: $trigger.body.customer.id, items: $nodes['Cart'].items } }}
Check whether a list has items:
{{ ($nodes['Search'].body.results ?? []).length > 0 }}
Branch on the result of an earlier node:
{{ $status['HTTP Request'].isSuccess ? 'ok' : $status['HTTP Request'].errorMessage }}
Pick values with JMESPath:
{{ $jmespath($nodes['Fetch Orders'].body, "items[?status=='paid'].id") }}