On this page
Sommatic Docs
Open portal

Expressions

Expressions let a node read data from the trigger and from earlier nodes. Write JavaScript between double braces in a node field and Sommatic AI evaluates it right before the node runs.

View as Markdown
Open in

Expressions connect the nodes of a workflow. With them a node reads the webhook body, the label an AI node chose, the id of the run or today’s date, and turns it into the value one of its fields needs: a URL, a condition, a message, an object for the next step.

Syntax

An expression is JavaScript between double braces. It is evaluated when the node runs, and its result replaces it:

JavaScript
{{ $json.body.email }}
{{ $('Classify request').item.json.label === 'billing' }}
{{ $now.setZone('America/Bogota').toFormat('yyyy-LL-dd') }}

Inside the braces you write one JavaScript expression: property access, operators, ternaries, method calls, arrow functions. When you need several statements, wrap them in a function that you call at once (see recipes).

Where expressions are evaluated

Sommatic AI evaluates expressions in the fields of a node’s configuration: plain text fields and the text values nested in objects and lists, such as the headers or the body of an io.http request. Evaluation happens right before the node runs, so an expression sees every node that has already run in this execution.

Some fields use another language on purpose:

FieldLanguagePage
expr of data.transform, and expr of flow.if or flow.switch written without bracesJSONataJSONata
template of data.templateHandlebarsHandlebars
schema of data.validateJSON SchemaJSON Schema
code of code.js and code.pythonJavaScript or Python programsCode nodes

Pure and mixed fields

How the result is inserted depends on what else the field contains.

Field valueKindResult
{{ $json.total }}Pure: the whole value is one expression (spaces around it are allowed).Keeps its type: number, boolean, object, list or null.
Total: {{ $json.total }} USDMixed: text with one or more expressions.Always text. Objects and lists are inserted as JSON; null and undefined become the words null and undefined.
TotalPlain textUnchanged.

Use a pure field whenever the node expects something other than text: a boolean in flow.if, an object for a request body, a number for a limit. To build an object, wrap it in parentheses:

JavaScript
{{ ({ id: $json.id, received: $now.toISO(), run: $execution.id }) }}

When an expression fails

  • Mixed field: only the part that failed is replaced by [ERROR: message], for example Hello [ERROR: Cannot read properties of undefined (reading 'name')]. The other parts resolve and the node does not fail, so read the node’s output when a text looks wrong.
  • Pure field: the field keeps its original text, {{ … }} unresolved, and the node receives that text. What happens next depends on the node: flow.if tries to read it as JSONata, fails and leaves through its error port; io.http would send the literal text. Guard reads that can fail with optional chaining (?.), $ifEmpty or a try/catch.

What an expression can use

  • Variables: $json, $input, $('Node label'), $execution, $workflow, $node, $now, $today and $uuid. See variables.
  • Helpers: $jmespath, $ifEmpty, $isEmpty, $slugify, $toQueryString, $base64Encode, $base64Decode and $randomId. See helpers.
  • Libraries: lodash as _, Luxon through $now and $today, and JMESPath through $jmespath.
  • JavaScript built-ins: Math, JSON, Date, String, Number, Boolean, Array and Object, plus the methods of strings, numbers, lists and objects.

Next steps

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs