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:
{{ $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:
| Field | Language | Page |
|---|---|---|
expr of data.transform, and expr of flow.if or flow.switch written without braces | JSONata | JSONata |
template of data.template | Handlebars | Handlebars |
schema of data.validate | JSON Schema | JSON Schema |
code of code.js and code.python | JavaScript or Python programs | Code nodes |
Pure and mixed fields
How the result is inserted depends on what else the field contains.
| Field value | Kind | Result |
|---|---|---|
{{ $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 }} USD | Mixed: text with one or more expressions. | Always text. Objects and lists are inserted as JSON; null and undefined become the words null and undefined. |
Total | Plain text | Unchanged. |
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:
{{ ({ 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 exampleHello [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.iftries to read it as JSONata, fails and leaves through itserrorport;io.httpwould send the literal text. Guard reads that can fail with optional chaining (?.),$ifEmptyor atry/catch.
What an expression can use
- Variables:
$json,$input,$('Node label'),$execution,$workflow,$node,$now,$todayand$uuid. See variables. - Helpers:
$jmespath,$ifEmpty,$isEmpty,$slugify,$toQueryString,$base64Encode,$base64Decodeand$randomId. See helpers. - Libraries: lodash as
_, Luxon through$nowand$today, and JMESPath through$jmespath. - JavaScript built-ins:
Math,JSON,Date,String,Number,Boolean,ArrayandObject, plus the methods of strings, numbers, lists and objects.
Next steps
Every variable and helper with its signature, parameters, return value, errors and examples run against the engine.
VariablesEvery variable, its type and an example.
RecipesPatterns that work in production, ready to copy.
GotchasThe mistakes that break expressions and how to avoid them.
NodesThe fields of every node, where you write expressions.