Skip to content
Docs

How-to: Use expressions

Every string field in a node’s configuration is an expression field. You can type a plain string and it passes through unchanged, or you can embed dynamic references, functions, and logic that the runtime resolves before the node executes. This guide covers the full expression surface with examples for every pattern.

Every expression-capable field has a built-in CodeMirror 6 editor. Fields open in literal mode by default — a plain text input you can type into directly. Click Insert a value ({x}) on the right to switch to expression mode, which activates syntax highlighting, autocomplete, and real-time linting. On a node’s settings it also takes you to the input data, to pick a value for the field (see Putting a value into a field).

Literal mode: a plain text input with the expression toggle beside it
Literal mode: a plain text input with the expression toggle beside it

In expression mode the field expands into a full multi-line editor. The expression label and ↓ literal button at the bottom let you know you are in expression mode and allow you to switch back. The editor detects expression syntax ({{ }}, @if, etc.) automatically — fields that already contain expressions open in expression mode on load. Typing {{ in a literal field also switches it to expression mode, keeping what you typed.

Expression mode: a CodeMirror editor with syntax highlighting
Expression mode: a CodeMirror editor with syntax highlighting

The editor provides real-time linting via the server-side compiler. Orange dots in the gutter mark lines with warnings or errors. Hover any marked line to read the diagnostic message. Diagnostics are also checked on save so invalid expressions cannot be stored.

Expression mode showing a lint error indicator in the gutter
Expression mode showing a lint error indicator in the gutter

In a node’s settings, the editor shows the data your expressions read, taken from a recent run of the flow, and what each expression works out to over it. A portal setting shows what its variable holds instead.

The node’s name is the heading, and you click it to rename the node. Under it are the node’s type and a Docs link when the type has a page in this documentation. The ⋯ button beside them copies the node’s ID.

The Input data panel beside a node’s settings shows what reached the node in a run: $prev first, then the earlier nodes by name, then $start, then a Workspace group with your Key-Value Store entries and the names of your secrets. A secret’s value is never shown.

Each group starts with the name of the node it holds, with what you write to read it beside the name: the node $prev reads, then $prev; an earlier node, then its type and $workflow->node('…'); Start, then $start.

The Input data panel: a run picker, Filter by key, $prev and $start with the fields the run started with, and the Workspace group with $kv, $secrets and $signals
The Input data panel: a run picker, Filter by key, $prev and $start with the fields the run started with, and the Workspace group with $kv, $secrets and $signals
  • Pick the run to show at the top of the panel. Failed runs are offered too: a failed run holds what the node saw before it failed. A run that ended before it reached this node is offered as well, marked stopped before this node, or not here yet while it is still going. The panel opens on the newest run that reached the node.

    The run picker open on recent draft runs, marked running and not here yet, failed, and stopped before this node
    The run picker open on recent draft runs, marked running and not here yet, failed, and stopped before this node
  • Open this node on a run’s page opens the node’s settings on that run instead, however old the run is. When the run failed at this node, a banner above the settings says so, with a link back to the run. The first field that does not work out over the run’s data is marked Fails on this run’s data, and the cursor is put in it, so a value you click in the input data goes there. The mark goes once your change makes the field work out. It checks your current settings against that run’s data, so it can differ from what failed if the node changed since. Save and re-run, beside Save, saves the node and asks to re-run that run with the same start data, on your draft unless you pick the live version.

  • A node that runs once per item inside a split shows an item stepper, so you can see each item it was given.

    The Input data panel of a node inside a split, reading Item, inside the split, with a stepper at 1 of 3
    The Input data panel of a node inside a split, reading Item, inside the split, with a stepper at 1 of 3
  • Type in Filter by key to narrow the tree.

Only runs whose data Publicus still keeps are offered. Once a run’s data is removed at the end of the retention period, the run leaves the list. A flow with no run at all still shows the Workspace group.

In a run that never reached the node, $prev is worked out from the nearest earlier node that did run, and a note above the tree says how:

  • A Conditional Exit that stopped the run is looked through, so you see what would have passed it.
  • A node that hands on what it was given, such as Key-Value Set, passes the value on.
  • A node that only reads or reshapes data, such as a Transformer, is run on the value, with nothing saved.
A note above the input data of a run that did not reach the node, saying how $prev was worked out from each node before it
A note above the input data of a run that did not reach the node, saying how $prev was worked out from each node before it

A node that sends a request, changes your workspace or reads a secret is never run for this. The note then names that node and says why, and $prev shows as not known. Pick a run that got further, or give $prev a value in the sample.

Click into a field, then click a value in the input data. Its path goes in at the cursor, wrapped in {{ }} unless the cursor is already inside one. A field in literal mode switches to expression mode first. You can also drag a value onto a field and drop it where it belongs.

The Input data panel with the hint Click, press Enter or drag a value into Template, beside a Template field and the Result it works out to
The Input data panel with the hint Click, press Enter or drag a value into Template, beside a Template field and the Result it works out to

From the keyboard, Tab into the tree and move with the arrow keys: Right opens a branch, Left closes it or moves to its parent, and Home and End jump to the first and last row. Enter puts the value into the field you were last in, and Space opens or closes a branch.

The quickest way from the keyboard is Insert a value, the button after each field. Tab to it and press Enter: the field switches to expression mode and the cursor goes to Filter by key in the input data. Type part of a key, press Down to reach the values, and press Enter on the one you want. It goes in after what the field already holds, and the cursor goes back to the field. Under the editor of a field in expression mode the same button puts the value where the cursor was. In Test a node, which has no input data beside the settings, the larger editor opens with the input data in it.

An earlier node’s values are read by the node’s name, as in $workflow->node('Fetch orders')->status, so a path you insert keeps working after the flow is exported and imported.

In a node’s settings, a {{ }} that reads one value of an earlier node shows as a chip in words: Fetch orders › Status. The field still holds the expression, and hovering the chip shows it. The cursor steps over a chip whole, and Backspace removes it whole. To change the path, press Show the expression under the field, which shows the code for that field until you press Show node names. A {{ }} that does more than read the value, such as {{ $workflow->node('Fetch orders')->total + 1 }}, stays as code.

Inside a @json block, a value goes in as the quoted path the block reads, such as "$.prev.customer.id", rather than in {{ }}. In a block scoped to a variable, as in @json($start), the path is relative to that variable, so only values under it can go in. Pick another and the panel says why it cannot.

Under each expression, Result shows what it works out to over the run picked in the input data, and updates as you type. It shows the value the node would be given, so in a number field "5" shows as 5. An expression that would fail in that run shows Would fail with the reason.

A Template field with the Result strip under it, showing the JSON the expression works out to over the picked run
A Template field with the Result strip under it, showing the JSON the expression works out to over the picked run

The result never reads a secret: $secrets->api_key shows as ••••••. If you type quickly enough to pause the checks, the strip says so and catches up by itself.

⤢ Expand under a field opens it over the whole window, with the input data beside it and a larger result. Done or Escape takes you back with your text kept. With the completion list open, Escape closes only the list.

The expanded editor over the whole window: the input data on the left, the expression in the middle, what it works out to on the right, and Done
The expanded editor over the whole window: the input data on the left, the expression in the middle, what it works out to on the right, and Done

The Output card under the settings shows what the node gave in the picked run. Run on this sample runs the node with the settings as they stand in the form, unsaved, over that run, and shows what it gives. Nothing is saved, and nothing is added to the run.

The Output card with what the node gave in the run, and Try on recent runs and Run on this sample
The Output card with what the node gave in the run, and Try on recent runs and Run on this sample

A node that only reads or reshapes data runs on the click. A node that sends a request or changes your workspace shows Send it for real and asks first, because that request or change happens for real.

A trigger node, and a node that needs the run around it (a branch, a pager or a signal), cannot run here. Run the flow to see what it gives. An agent has its own way to be tried, below.

When you change a node’s settings, you can see what it would have done with what earlier runs gave it before you save.

  • Try its first step is on an agent’s Output card. The agent plans one step with the settings in the form, over the picked run. It shows the reply, or each tool the agent would call and with what, beside what the run’s own first step did. Every tool the agent has is offered, and none of them runs. It costs one model call, so it asks first, and you can pick another model to try it on.

  • Try on recent runs tries the settings on the five newest runs that reached the node, one after another. Each row says Same or Changed against what that run did, with what changed, and links to the run. An agent is compared by what it did (which tools it called, or that it replied), not by its exact words. Same tools means it called the same tools but asked them for something else, and the row says what.

    The Output card after Try on recent runs, with one run marked Same and two marked Changed, each naming what differs
    The Output card after Try on recent runs, with one run marked Same and two marked Changed, each naming what differs

Nothing is saved, and nothing is added to the runs. Try on recent runs is offered only for an agent and for a node that changes nothing: a node that sends a request or writes to your workspace would do that once per run, so it keeps the single Send it for real.

An agent is tried on the conversation as it was during the run, when the run still holds it. Its other memory is read as it is now.

A flow that has never run has no data of its own to show. When its trigger starts runs with data, such as a webhook, a form, a channel or an email, the input data shows an example of what the trigger starts a run with, named Example, not from a run in the run picker. A form’s fields are listed with no values, and a webhook’s request body is empty. The example is not kept anywhere until you use it as the sample. A schedule starts with nothing, so a scheduled flow has no example.

Give the flow a sample, a stand-in run that only the editor reads. The two icons at the top of the input data make one:

  • Use this as the sample copies the run you are looking at. Secrets and fields that look like credentials are left out of the copy, and the copy is removed when the run’s own data is. On the example, it keeps the example as the sample, for you to fill in with Edit the sample.

  • Edit the sample lets you type what the run starts with ($start) and what the previous node gives ($prev), as JSON. With no run, it opens on the trigger’s example, so a form’s fields are there for you to fill in. A sample you have edited is yours, and stays until you remove it.

    The flow's sample window with What the run starts with as JSON, an empty What Start gives, and Save the sample
    The flow's sample window with What the run starts with as JSON, an empty What Start gives, and Save the sample

The sample appears as Sample in the run picker, and the result, the input data and Run on this sample use it like a run. No run ever reads it, and it is not exported with the flow. Remove the sample in the same window takes the editor back to the flow’s runs.

Try the saved node opens Test a node with the node’s saved settings and the run you picked. Input from the previous node holds the node’s $prev in that run, and What the run started with holds its $start. Change either to try the node on other input.

Test a node opened from a run: a Transformer with its saved Template and result, Input from the previous node, What the run started with, and Run this node
Test a node opened from a run: a Transformer with its saved Template and result, Input from the previous node, What the run started with, and Run this node

A portal setting shows its data under the field. Show the data opens what its variable holds:

  • $row holds the table’s first rows, with only the columns the block lists, and a stepper to move between them;
  • $visitor is you, as a visitor;
  • $value and $point show a stand-in, marked stand-in, because the figure is worked out when the page is shown.

The result under the field is worked out over that data, as the page works it out.

The same expression field appears across Publicus. What an expression can read depends on where the field is, because each place has different data to hand it.

Where Which settings What the expression reads
A node in a flow Every setting with Insert a value ({x}), including headers, parameters, mapping rules and an agent tool’s pinned arguments The flow’s variables: $prev, $start, $workflow, $kv, $secrets and $signals, and $loop and $page where they apply. See Bound roots.
A Form node that asks during a run The wording of its questions The same variables as the node’s other settings.
Test a node The settings of the node you test $prev is the JSON under Input from the previous node, and $start the JSON under What the run started with. Opened from a node, both are filled from a run.
A portal table, button or calendar A column’s text options, a button’s Message afterwards on a row, a calendar’s Title and Colour $row, the row it is drawn for.
A portal figure Its Description and Colour $value, the figure.
A portal chart The colour of each bar, slice or point $point, the bar, slice or point.
A portal page or form, or a Form node’s form Wording that greets the person, such as a field’s help text or what it is prefilled with $visitor, the person it is shown to.

In a node’s settings, the following variables are available:

Variable What it contains
$prev Full JSON output of the immediately upstream node.
$start The payload that started the flow (webhook body, manual trigger data, etc.).
$kv All Key-Value Store entries — read one with $workflow->kv('myKey'), or $kv->myKey for a key with no dot or dash in it.
$secrets Secrets store — read with $secrets->myApiToken. Values are redacted in all logs.
$signals Workflow-signal lookup bag — call $signals->get('eventName') or use the proxy form $workflow->signal('eventName').
$page Current page context inside a Pager connector — see Page context in Pager flows.
$workflow Full proxy object — use $workflow->node('id or name') for named ancestor access.
$loop Iteration metadata available only inside @foreach — see Building collections with @foreach.

A portal page or form reads its own variables instead, described in Variables on a portal page or form.

A setting on a portal page reads one variable, named for what the setting describes, and nothing else: no node’s output, no secret, and no table other than the one its block shows. Saving or publishing the page names an expression that reaches further. The expression reference lists the four with an example each.

The row a table, a calendar or a button on a row is drawn for. It holds the columns the block lists, by name, so $row->plaats reads the column plaats. A column you need only in an expression must still be listed: tick Only for expressions to keep it off the page. The column options that take an expression are in Shape a table’s columns.

{{ $row->klant }} · {{ $row->plaats }}

The figure’s own number, in a figure’s Description and Colour. Compare it as a number:

{{ $value }} open orders

One bar, slice or point of a chart, in the chart’s colour setting: its label and its value.

{{ $point->value > 100 ? 'danger' : 'primary' }}

A colour must come out as one of gray, primary, success, warning, danger or info. Anything else leaves the usual colour.

The person the page or form is shown to: their name and email. Wording that greets them reads it, such as a field’s help text or the value it is prefilled with.

Hello {{ $visitor->name }}

The person can change a prefilled value, so never prefill one your flow must be able to trust.

If a field value contains no {{ }} delimiters and no @ directives, the runtime passes it through as-is. You do not need to wrap static values:

source: publicus-flow
version: 2

A mix of literal and dynamic content within the same field is fine — only the {{ }} portions are evaluated:

Hello {{ $prev->name }}, your order {{ $prev->orderId }} is ready.

Use {{ expr }} to embed an expression in HTML a person reads, such as an email body. The result is HTML-escaped: <, >, & and quotes come out as entities, so a value cannot break the page around it.

Use {!! expr !!} wherever a machine reads the result: a JSON body, a URL, a header, a SQL value, a search query. The value arrives exactly as it is. In JSON, wrap it in json_encode(), which quotes it and escapes it the way JSON needs:

Escaped, for people: {{ $prev->comment }}
Raw, for machines: {!! $prev->url !!}
A JSON value: {!! json_encode($prev->comment) !!}

{{ }} in a field a machine reads changes the data without failing: Q&A arrives as Q&amp;A, and O'Brien as O&#039;Brien.

$prev is the output of the node immediately upstream. Access properties using ->:

{{ $prev->id }}
{{ $prev->user->email }}
{{ $prev->address->city }}

Access array elements with brackets:

{{ $prev->items[0]->name }}
{{ $prev->results[0]->id }}

Use $prev directly when the upstream output is a scalar (a string or number rather than an object):

{{ $prev }}

Every name you read on $prev is a key of the upstream output, value included. Microsoft Graph and OData put their list of results under value, so this counts the results:

{{ count($prev->value) }}

To work on the whole output, pass $prev itself. Functions that take an array (array_map(), array_keys(), in_array(), implode() and the like), count(), json_encode(), @foreach, the casts (array) and (object), and checks such as is_array() all receive the output as data:

{!! json_encode(array_map(fn ($order) => $order->id, $prev)) !!}

The same holds for $row on a portal page or a table’s column, where $row->value reads a column called value, and for $point in a chart, where $point->value is the point’s number.

One check does not see the data: @if ($prev) is true even when the output is an empty list or object. Write count($prev) > 0, or test the key you need.

Nodes wired to a connector’s iteration handle run once per element, and the first node of that branch reads its element as $prev. The element has the same shape as any other node output, so every accessor on this page works on it:

{{ $prev->hs_id }}
{{ $prev['hs_id'] }}
{{ jsonpath($prev, '$.hs_id') }}

The same element is also available as $page->startData, which is what a sub-graph written for a Pager uses. See Parallel processing for connector setup.

Build a dynamic URL from upstream output:

https://api.example.com/users/{{ $prev->userId }}/orders

Parameterise a database query:

:accountId → {{ $prev->accountId }}
:status → active

Forward a single field to the next node:

In a TextExpression node:

{{ $prev->data->cursor }}

$start holds the payload that started the flow — the webhook body, the manual trigger JSON, or the schedule’s injected data:

{{ $start->tenantId }}
{{ $start->event->type }}
{{ $start->payload->customerId }}

A webhook-started flow receives the request wrapped in an envelope: the request body sits under $start->payload, next to $start->method, $start->url, and $start->headers.

For a GitHub push webhook:

{{ $start->payload->repository->full_name }}
{{ $start->payload->ref }}
{{ $start->payload->pusher->email }}

For a Stripe event:

{{ $start->payload->type }}
{{ $start->payload->data->object->id }}
{{ $start->payload->data->object->amount }}

For a scheduled flow that injects a JSON payload:

{{ $start->runDate }}
{{ $start->batchSize }}

Read an entry by the key you created in Key-value:

{{ $workflow->kv('lastSyncCursor') }}
{{ $workflow->kv('acme.tenant-slug') }}

This works for every key, and the run fetches only the keys you name. $kv exposes all entries as an object, so a key made of letters, digits and underscores can also be written as a property:

{{ $kv->lastSyncCursor }}

That form loads every entry in the workspace, and it cannot spell a key with a dot, a dash or a colon in it: $kv->smoke.gating reads the key smoke and is refused when you save, with a message naming the $workflow->kv('…') form. KV entries are read-only in expression context — use a KeyValueStore / Set node to update them.

{
"sinceId": "{{ $kv->lastSyncCursor }}",
"limit": 100
}
{{ $kv->featureEnabled == 'true' ? 'yes' : 'no' }}

$secrets exposes secrets by their slug. Secret values are never written to the run’s audit log — they are redacted in all input/output displays:

Authorization: Bearer {!! $secrets->stripeApiKey !!}
X-Api-Key: {!! $secrets->serviceApiKey !!}

Secret slugs match the names you set in Secrets. Use the raw tags, so the key reaches the server exactly as it is stored.

In a Rest / Operation node’s headers field:

Authorization → Bearer {!! $secrets->myServiceToken !!}
{
"apiKey": {!! json_encode($secrets->myServiceToken) !!},
"userId": {!! json_encode($prev->id) !!}
}

Use jsonpath($root, '$path') to run an RFC 9535 JSONPath query against any value. The path string is compiled once and cached — literal paths have no runtime parsing cost.

{{ jsonpath($prev, '$.user.email') }}
{{ jsonpath($prev, '$.items[*].id') }}

Returns an array of all id values from every element of items.

{{ jsonpath($prev, '$.results[?(@.status == "active")]') }}

Returns every element of results whose status field equals "active".

Both are equivalent:

jsonpath($prev, '$.address.city')
jsonpath($prev, '$["address"]["city"]')

Use bracket notation when a key contains dots or special characters:

jsonpath($prev, '$["meta.source"]')
{{ implode(', ', jsonpath($prev, '$.tags[*].name')) }}

Extracts all tag names and joins them with a comma.

Use the . operator:

{{ $prev->firstName . ' ' . $prev->lastName }}

Use sprintf for structured output:

{{ sprintf('Order #%s placed on %s', $prev->orderId, $prev->createdAt) }}
{{ sprintf('%.2f', $prev->amount) }}
{{ sprintf('%05d', $prev->referenceNumber) }}
{{ strtolower($prev->email) }}
{{ strtoupper($prev->countryCode) }}
{{ Str::title($prev->displayName) }}
{{ Str::slug($prev->category) }}
{{ trim($prev->input) }}
{{ ltrim($prev->path, '/') }}
{{ rtrim($prev->value, ',') }}
{{ Str::squish($prev->description) }}
{{ str_replace('@example.com', '@newdomain.com', $prev->email) }}
{{ Str::replace(["\n", "\r"], ' ', $prev->body) }}

In a ConditionalExit condition:

str_contains($prev->email, '@company.com')
str_starts_with($prev->ref, 'refs/heads/main')
str_ends_with($prev->filename, '.pdf')
{{ explode(',', $prev->tagsCsv) }}
{{ str_split($prev->code, 2) }}
{{ implode(', ', $prev->names) }}
{{ implode(' | ', jsonpath($prev, '$.tags[*].label')) }}
{{ Str::slug($prev->productName) }}
{{ Str::camel($prev->field_name) }}
{{ Str::snake($prev->FieldName) }}
{{ $prev->quantity * $prev->unitPrice }}
{{ $prev->total - $prev->discount }}
{{ $prev->score / $prev->maxScore * 100 }}
{{ $prev->index + 1 }}
{{ round($prev->amount, 2) }}
{{ number_format($prev->revenue, 2, '.', ',') }}
{{ ceil($prev->pages) }}
{{ floor($prev->ratio) }}
{{ abs($prev->delta) }}
{{ min($prev->count, 100) }}
{{ max($prev->offset, 0) }}
{{ intval($prev->stringId) }}
{{ floatval($prev->stringPrice) }}

PHP scalar and structural casts are available — useful when converting between scalar forms or coercing an object back to an array:

{{ (string) $prev->numericId }} — force string
{{ (array) $prev->settingsObject }} — object → assoc array
{{ (object) ['name' => $prev->displayName] }} — array → stdClass
(int) $prev->count — force integer
(float) $prev->price — force float
(bool) $prev->flag — force boolean

(int), (float), and (bool) are equivalent to the intval, floatval, and boolval functions — use whichever reads better. Only (unset) and (void) are rejected. Note the numeric/bool casts are shown bare above: a typed (int/float/bool) field wants a bare expression, so (int) $prev->count, not {{ (int) $prev->count }} (see Expressions in typed fields).

Not every field expects a string result. Fields that declare a specific type evaluate the expression and cast or validate it against that type. For all typed fields, write a bare expression — no {{ }} echo tags. Echo tags always produce a string, which is type-unsafe.

Write a bare condition expression:

$prev->status == 'active'
str_contains($prev->email, '@company.com')
($prev->count ?? 0) > 0
$workflow->signal('onApproval') !== null
Str::startsWith($prev->ref, 'refs/heads/main')
! in_array($prev->status, [200, 404], true)

The primary consumer of boolean expressions is ConditionalExit’s condition field — the exit predicate. A truthy result stops the flow at that node; a falsy result lets it continue, so phrase the condition as the reason to stop. Wrapping in {{ }} would produce the string "1" or "" rather than a boolean — the editor warns you if you add echo tags to a boolean field.

Write a bare arithmetic expression or a single function call that returns a number:

$prev->quantity * $prev->unitPrice
intval($prev->stringId) + 100
round($prev->score / $prev->maxScore * 100, 1)
min($prev->count, 500)

A plain numeric literal (42, 3.14) also satisfies a number field without any expression syntax.

A field backed by an enum expects a string that matches one of the declared case values. Write the bare string literal, or a bare expression that resolves to a matching string:

'draft'
$prev->status
($prev->score >= 90) ? 'excellent' : 'standard'
$start->env == 'production' ? 'live' : 'sandbox'

The editor lists the available cases beside the field. A plain string literal like 'draft' satisfies an enum field without any expression syntax.

A Method field open on its cases, Get, Post, Put, Delete and Patch, with the expression toggle beside it
A Method field open on its cases, Get, Post, Put, Delete and Patch, with the expression toggle beside it

Fields that declare an array type expect an expression that returns a PHP array — no {{ }} echo tags:

jsonpath($prev, '$.items[*].id')
array_map(fn($x) => $x->id, $prev->records)
explode(',', $prev->tagsCsv)
['id', 'email', 'createdAt']

Most keyColumns and multi-value configuration fields in node settings are array fields. A plain array literal like ['id', 'email'] satisfies an array field without expression syntax.

The expression editor’s status bar shows the declared type for the active field (expression → bool / expression → int / etc.).

Saving a template that wraps its result in echo tags into a bool, int, or float field is rejected at save time with a clear error. Wrapping in {{ }} always produces a string — write the expression bare (no echo tags) so the inferred return type matches the cast.

A Condition field written with echo tags, its status bar reading expression → bool, and an error that the field expects bool so the expression should be written bare
A Condition field written with echo tags, its status bar reading expression → bool, and an error that the field expects bool so the expression should be written bare

A bool, int, or float field also rejects an expression that does not read as one: a syntax error such as $prev->status ==, or a word such as ten. Without the check, the field would resolve to the text you typed, and any non-empty text counts as true. The error quotes what went wrong. Wrapping the whole expression in parentheses makes it read as an expression, and a fixed value belongs in literal mode instead.

Use ?? to provide a fallback when a value is null or absent:

{{ $prev->nickname ?? $prev->username }}
{{ $prev->expiresAt ?? 'never' }}
{{ $kv->lastCursor ?? '0' }}
{{ $start->batchSize ?? 50 }}

Chain multiple fallbacks:

{{ $prev->preferredEmail ?? $prev->email ?? 'no-reply@example.com' }}

Use ?? in a ConditionalExit condition to guard against missing fields while phrasing the check as the reason to stop — a truthy result exits:

($prev->status ?? '') != 'active'

Use condition ? valueIfTrue : valueIfFalse for inline branching:

{{ $prev->isActive ? 'enabled' : 'disabled' }}
{{ $prev->count > 0 ? $prev->count : 'none' }}
{{ $start->env == 'production' ? $secrets->prodKey : $secrets->devKey }}
{{ ($prev->label ?? '') != '' ? $prev->label : 'Untitled' }}

Use ?-> when a property may not exist on an object:

{{ $prev->user?->email }}
{{ $prev->address?->city ?? 'Unknown' }}
{{ $prev->metadata?->tags?->primary }}

If any step in the chain is null, the whole expression returns null rather than throwing an error.

Use |> to pass a value through a sequence of transformations without deeply nested function calls:

{{ $prev->email |> strtolower() |> trim() }}
{{ jsonpath($prev, '$.prices[*]') |> array_sum() }}
{{ jsonpath($prev, '$.items[*].name') |> array_unique() |> array_values() }}

The pipe operator passes the left-hand value as the first argument to the right-hand function call.

Use @if to conditionally include content in a string or JSON document:

@if ($prev->status == 'active')
Running
@elseif ($prev->status == 'paused')
Paused
@else
Unknown
@endif

A @json body cannot contain directives, so build the document as raw text with echo tags instead:

{
"id": {!! json_encode($prev->id) !!},
"status": "@if ($prev->isActive)active@else inactive@endif"
}

In a Rest / Operation URI field:

@if ($start->env == 'production')
https://api.example.com/v2/orders
@else
https://sandbox.example.com/v2/orders
@endif

Include an optional field only when present

Section titled “Include an optional field only when present”
@if ($prev->metadata?->source)
{{ $prev->metadata->source }}
@endif
@if ($prev->score >= 90)
Excellent
@elseif ($prev->score >= 70)
Good
@elseif ($prev->score >= 50)
Passing
@else
Failing
@endif

Use @foreach to iterate over an array and produce a transformed collection or string.

Inside any @foreach body, a synthetic $loop object is available with metadata about the current iteration:

Property Type Meaning
$loop->index int 0-based iteration index
$loop->iteration int 1-based iteration
$loop->count int | null Total items (null when the loop runs over a JSON object rather than a list)
$loop->remaining int | null Items left after this one (null when count is null)
$loop->first bool True on the first iteration
$loop->last bool True on the final iteration (false when count is null)
$loop->even bool True when index is even
$loop->odd bool True when index is odd
@foreach ($prev->users as $user)
{{ $loop->iteration }}/{{ $loop->count }}: {{ $user->name }}@if (! $loop->last), @endif
@endforeach

$loop is only valid inside a @foreach body. Outside one, it is undefined and the compiler rejects the reference.

{{ implode(', ', array_map(fn ($user) => $user->name, Arr::wrap(jsonpath($prev, '$.users[*]')))) }}

@php blocks assign to plain $name variables only, so you cannot append to an array ($out[] = …) inside a @foreach. Build the list with array_map instead.

In a TextExpression node, produce an array of extracted values:

{{ json_encode(array_map(fn ($item) => $item->id, Arr::wrap(jsonpath($prev, '$.results[*]')))) }}

In a Database / Select node’s SQL body:

SELECT * FROM orders
WHERE account_id = :accountId
AND status IN (
@foreach ($prev->statuses as $status)
@if (! $loop->first), @endif :status{{ $loop->index }}
@endforeach
)
@foreach ($prev->events as $event)
@if ($event->type == 'purchase')
{{ $event->amount }}
@endif
@endforeach

The @json directive wraps a JSON document so that "$.path" strings inside it are automatically resolved via JSONPath. There are two forms depending on whether you want a global or scoped root.

Without an argument, $. is the global expression scope — the same root available to every expression. All bound variables are accessible by their top-level names:

@json
{
"id": "$.prev.id",
"email": "$.prev.user.email",
"tenant": "$.start.tenantId",
"currency": "USD"
}
@endjson

Non-path strings like "USD" pass through unchanged.

Pass a bound variable as an argument to make $. relative to that value inside the block. The most common form scopes to $prev:

@json($prev)
{
"id": "$.id",
"email": "$.user.email",
"total": "$.order.amount"
}
@endjson

$.id here is equivalent to $prev->id. This form keeps paths short when the whole document comes from a single upstream node.

A key with a dash, a space or a dot in it goes in brackets: "$.prev['content-type']" in a global block, "$['content-type']" in a scoped one.

Scope to any bound variable — for example, flow start data:

@json($start)
{
"tenantId": "$.tenantId",
"event": "$.event.type"
}
@endjson
@json($prev)
{
"user": {
"id": "$.userId",
"email": "$.userEmail"
},
"items": "$.lineItems",
"meta": {
"source": "publicus"
}
}
@endjson

A quoted "$.path" resolves to whatever type the value actually is. A number stays a number, a boolean stays a boolean, and a list stays a list:

@json($prev)
{
"name": "$.name",
"count": "$.count",
"ratio": "$.score",
"active": "$.isActive",
"tags": "$.labels",
"metadata": "$.meta",
"deletedAt": null
}
@endjson

Given a $prev where count is 42 and isActive is true, that produces "name": "Ada", "count": 42, and "active": true. The quotes are how you write the reference, not what the value becomes.

You never need a cast to get a number out of a path. Writing "(int)$.count" does not produce a number, it fails to compile.

The body is strict JSON, so every dynamic reference is a quoted string and everything else is a JSON literal:

Written as Result
"$.path" Resolved, with its native type preserved
$.path unquoted Compile error, because the body is no longer valid JSON
"(int)$.path" Compile error, because a path reference must be the whole string
"{{ expr }}" Compile error, because echoes are not supported here
@if, @foreach Compile error, because directives are not supported here
true, false, null, 42 Passed through as JSON literals
"...$.path" as an array element Spread, see Spread and map below

To compute a value, do it in an upstream node or in a separate {{ }} expression field, then reference the result here.

To build an array from a list, prefix the path with ... as an array element. The list is spread into the surrounding array:

@json($prev)
{
"skus": ["...$.lineItems"]
}
@endjson

To reshape each item as you go, follow the path with a mapper object. Inside a mapper, "@.field" refers to the current item:

@json($prev)
{
"lines": ["...$.lineItems", {
"sku": "@.productCode",
"quantity": "@.qty"
}]
}
@endjson

The ... prefix is optional when a mapper is present, so ["$.lineItems", { ... }] does the same thing.

The template field of a Transformer node is the primary home for @json blocks — it replaces the older bare-$.path string convention.

Use @php ... @endphp when you need to compute several intermediate values before emitting a result. A block holds four kinds of statement:

  • $name = expression; — assignment to a plain local variable
  • if / elseif / else
  • foreach
  • switch, with a plain break; to end a case

Everything else is rejected at compile time: echoes, function calls at the statement level, return, and the loops that can spin (while, do, for). Assignment only ever targets a plain $name, never a property or an array offset — $prev->foo = 1 and $out[] = 1 are both refused, so a template can never write back through a bound root. break may only leave a switch, and takes no level (break 2 is refused). Only functions on the allowlist may appear on the right-hand side.

@php
$items = jsonpath($prev, '$.orders[*]');
$total = array_sum(array_map(fn($o) => $o->amount, $items));
$count = count($items);
@endphp
{{ sprintf('%d orders totalling %.2f', $count, $total) }}
@php
$active = array_filter($prev->users, fn($u) => $u->isActive);
$emails = array_map(fn($u) => $u->email, $active);
@endphp
{{ implode(',', $emails) }}

match (true) reads better than a nested ternary once there are more than two outcomes. Every arm is an expression, the first matching arm wins, and there is no fallthrough:

@php
$sender = $prev->deliveryIdentifier?->value ?? '';
$status = match (true) {
($prev->hasAgentReply ?? false) => 'answered',
preg_match('/@internal\./i', $sender) === 1 => 'internal',
preg_match('/@(example\.com)$/i', $sender) === 1 => 'known vendor',
default => 'new',
};
@endphp
{{ $status }}

Write a default arm unless a miss really should fail the node: a match with no arm hit throws at runtime.

preg_match binds its third argument, so a captured group is available to the statements after it — preg_match('/@(.+)$/', $sender, $m) makes $m[1] the domain. The same holds for preg_match_all, and for the match-count argument of preg_replace and str_replace.

The same decision written as statements, when each branch has to set more than one variable:

@php
if ($prev->total > 1000) {
$tier = 'gold';
$discount = 0.1;
} elseif ($prev->total > 100) {
$tier = 'silver';
$discount = 0.05;
} else {
$tier = 'bronze';
$discount = 0;
}
@endphp
{{ sprintf('%s: %.2f', $tier, $prev->total * (1 - $discount)) }}

switch also works, and reads the same way:

@php
$sender = $prev->deliveryIdentifier?->value ?? '';
switch (true) {
case $prev->hasAgentReply ?? false:
$status = 'answered';
break;
case preg_match('/@internal\./i', $sender) === 1:
$status = 'internal';
break;
default:
$status = 'new';
}
@endphp
{{ $status }}

Prefer match where either fits. switch compares with == and match with ===, and expressions read decoded JSON, where the same field arrives as "1" from one API and 1 from the next — a switch arm can match a value you did not mean. switch also falls through when you forget a break, which is invisible in a text field. match has neither problem and needs no break.

A {{ … }} echo ends at the first }} it sees, so a match written inside one needs a space before the closing tag:

{{ match (true) { … default => '' } }} ← fine
{{ match (true) { … default => ''}}} ← parse error

Variables introduced in a @php block are visible to subsequent directives and echoes in the same template, but cannot shadow a bound root ($prev, $start, $kv, $secrets, $signals, $page, $workflow, or $loop inside a @foreach).

A @php block takes up lines in the editor that you do not want in the output, so its line is removed: the newline after @endphp, and the indentation the block sits on. Everything else is left exactly as you typed it — a blank line you left under the block stays, and so does a space in Value: @php … @endphp, which is text rather than layout.

So this renders as just the message, with no leading blank line:

@php
$message = 'Klaar.';
@endphp
{{ $message }}

These are the helper methods used most. The expression reference lists every one.

{{ Str::slug($prev->title) }} — "my-product-name"
{{ Str::title($prev->name) }} — "John Smith"
{{ Str::camel($prev->field_name) }} — "fieldName"
{{ Str::snake($prev->FieldName) }} — "field_name"
{{ Str::upper($prev->code) }} — "ABC"
{{ Str::lower($prev->code) }} — "abc"
{{ Str::limit($prev->description, 100) }} — truncate to 100 chars
{{ Str::contains($prev->email, '@') }} — true/false
{{ Str::after($prev->path, '/users/') }} — extract after prefix
{{ Str::before($prev->email, '@') }} — extract before suffix
{{ Str::replace(' ', '_', $prev->label) }} — replace spaces
{{ Str::random(16) }} — random 16-char string
{{ Arr::first($prev->items) }}
{{ Arr::last($prev->items) }}
{{ Arr::pluck($prev->users, 'email') }}
{{ Arr::flatten($prev->nested) }}
{{ json_encode(array_unique(Arr::wrap($prev->tags))) }}
{{ Arr::wrap($prev->maybeArray) }} — coerce scalar/null to an array
{{ json_encode(Arr::only((array) $prev->record, ['id', 'email'])) }}
{{ json_encode(Arr::except((array) $prev->record, ['password'])) }}
{{ Arr::get($prev->data, 'user.address.city', 'Unknown') }}

Arr::get is the safe alternative to ?-> chains — it accepts a dot-notation path and a default value. Use (array) to coerce an upstream object into an associative array before passing it to Arr::only or Arr::except.

Number — locale-aware numeric formatting

Section titled “Number — locale-aware numeric formatting”
{{ Number::format($prev->amount) }} — "1,234.56"
{{ Number::currency($prev->total, 'USD') }} — "$1,234.56"
{{ Number::percentage($prev->ratio * 100, 1) }} — "12.3%"
{{ Number::fileSize($prev->bytes) }} — "1.2 MB"
{{ Number::forHumans($prev->views) }} — "1.2 thousand"
{{ Number::ordinal($prev->position) }} — "3rd"
{{ Number::spell($prev->count) }} — "forty-two"
{{ now()->toIso8601String() }}
{{ now()->subDays(7)->toDateString() }}
{{ now()->addHours(24)->toIso8601String() }}
{{ today()->toDateString() }}
{{ Carbon::parse($prev->createdAt)->diffForHumans() }}
{{ Carbon::parse($prev->startDate)->format('Y-m-d') }}
{{ Carbon::parse($prev->startDate)->addMonth()->toDateString() }}
{{ Carbon::parse($prev->date)->isToday() }}
{{ Carbon::parse($prev->expiresAt)->isPast() }}
{{ Carbon::now()->startOfMonth()->toDateString() }}
{{ Carbon::now()->endOfMonth()->toDateString() }}

now() and today() are also available as standalone functions:

{{ now()->toIso8601String() }}
{{ today()->toDateString() }}

The expression reference lists every function and helper method you can call, with its signature, what it does and an example of what it returns. The editor shows the same description and example when you pick a function from autocomplete or point at one in a field.

Autocomplete in a Body field listing the str_ functions, with the description of str_contains and its example beside the list
Autocomplete in a Body field listing the str_ functions, with the description of str_contains and its example beside the list

Expressions cannot read environment variables. Store sensitive values in Secrets and access them via $secrets->name; store tenant configuration in the Key-Value Store and read it via $kv->name.

By default, $prev refers to the immediately upstream node. To reference output from a non-adjacent ancestor — for example, in a branching flow where you need data from several nodes back — use $workflow->node(). It accepts the node’s ID or its name:

{{ $workflow->node('Fetch Account')->account->plan }}
{{ $workflow->node('fetch-account')->account->plan }}
{{ $workflow->node('d9erva7160kgd7v1b0sg')->userId }}

Name matching ignores case and punctuation, so 'Fetch Account' and 'fetch-account' refer to the same node. The ID is shown (and copyable) in the node’s Configure panel; an ID reference keeps working if the node is later renamed. Node names are unique within a flow, so either form is unambiguous. A reference that matches no node fails the node’s execution with a clear error — and is already flagged when you save the expression.

If you need the original record ID after several transformation steps:

{{ $workflow->node('initial-fetch')->record->id }}

This avoids passing the ID through each intermediate node’s output.

$workflow->items() — iterate any node’s output

Section titled “$workflow->items() — iterate any node’s output”

When an ancestor emits a list, iterate it with $workflow->items($id) inside an @foreach. Omit the argument to iterate $prev:

@foreach ($workflow->items('fetch-users') as $user)
{{ $user->email }}@if (! $loop->last), @endif
@endforeach

Internally this returns a Generator, so memory stays bounded even for very large upstream outputs.

Paired-item lineage — $workflow->pairedItem()

Section titled “Paired-item lineage — $workflow->pairedItem()”

When the immediately upstream node emits a list and opts into lineage tracking (Mapper, Database/Select, TableStore/Query, OpenApi/Operation, Wsdl/Operation), each output item carries a sourceIndex pointing back to the input item it derived from:

@foreach ($prev as $i => $row)
Item {{ $loop->index }} came from source index {{ $workflow->pairedItem($i)->sourceIndex ?? 'unknown' }}
@endforeach

sourceIndex is null when the upstream node did not opt in to lineage or did not emit a list. Always guard with ??.

Lineage pairs items by position. If you build a derived list inside a @foreach and call array_filter, array_values or array_unique on the way out, the compiler emits a LINEAGE_BREAK warning: once an item is dropped, the positions no longer line up, so a later node’s pairedItem() would name the wrong source. The warning does not block save. When a later node needs to know where an item came from, carry the source item’s own id (an order number, a row key) in the item itself.

Signals let one part of a flow communicate with another at runtime. In expression context, read a received signal by event name — either via the proxy method or the $signals bag (both return the same value):

{{ $workflow->signal('onPaymentReceived')?->payload?->amount }}
{{ $signals->get('onApproval')?->receivedAt }}

If the signal has not been received yet, both forms return null — use ?-> or ?? to guard against that case.

A received signal has these fields:

Field Meaning
event The event name the signal was sent with
node The name of the node the signal was sent to, or null
payload The data the signal carried, for example a form answer or a webhook body
receivedAt When the signal arrived, as an ISO 8601 timestamp

When the same event arrives more than once, you read the latest one. $signals->all() lists every received signal, keyed by event name.

In a ConditionalExit condition — stop while the signal is absent, so the flow continues only once it arrives:

$workflow->signal('onApproval') === null

Inside a Pager connector’s sub-flow, $page gives you the current pagination state:

Property Type Meaning
$page->index int Zero-based page number (the first page is 0)
$page->prevOutput mixed The output of the previous page’s terminal node — null on the first page
$page->startData mixed The pager’s start data — typically carries cursor values, configured page sizes, and other connector-specific fields the pager seeded
$page->prevPageLogId string | null The workflow log ID of the previous page’s last activity, useful for re-reading detailed previous-page output
$page->nodeDefinition object The NodeData of the pager node that scheduled this page

The specific properties available on $page->startData depend on how the parent Pager connector populates them — typical fields include the page index, the page size, and any cursor values the connector emits.

{{ $page->index + 1 }}

Read connector-injected values from $page->startData:

https://api.example.com/records?limit={{ $page->startData['size'] }}&offset={{ $page->startData['offset'] }}
https://api.example.com/records?cursor={{ $page->startData['cursor'] }}&limit={{ $page->startData['size'] }}

See Connectors for the full $page reference and connector configuration.

These patterns combine expressions across multiple nodes to accomplish common tasks.

Schedule → KV/Get (lastSyncedId) → Rest/Operation → Transformer → ... → KV/Set

KV/Get reads the cursor key.

Rest/Operation URI:

https://api.example.com/records?sinceId={{ $prev }}&limit=100

KV/Set value (after processing):

{{ $prev->maxId }}

Rest/Operation (fetch user) → Transformer → Database/Insert

Transformer template. insertedAt is computed rather than read from a path, so this one is raw text with echo tags rather than a @json block:

{
"userId": {!! json_encode($prev->id) !!},
"email": {!! json_encode($prev->email) !!},
"plan": {!! json_encode($prev->subscription->plan) !!},
"insertedAt": {!! json_encode(now()->toIso8601String()) !!}
}

Webhook → ConditionalExit (stop unless purchase) → purchase flow
Webhook → ConditionalExit (stop unless refund) → refund flow

Each ConditionalExit is the exit predicate for its branch: it stops the flow unless the event matches, so only matching events fall through.

ConditionalExit 1 — stop unless it is a purchase:

$start->type != 'charge.succeeded'

ConditionalExit 2 — stop unless it is a refund:

$start->type != 'charge.refunded'

OpenApi/Operation (returns array) → TextExpression

TextExpression:

@php
$items = jsonpath($prev, '$.data[*]');
$total = array_sum(array_map(fn($x) => $x->amount, $items));
$count = count($items);
$avg = $count > 0 ? round($total / $count, 2) : 0;
@endphp
{{ json_encode(['count' => $count, 'total' => $total, 'average' => $avg]) }}

TableStore/Query → TextExpression → Rest/Operation (Slack)

TextExpression:

@php
$open = count(array_filter($prev, fn($t) => $t->status == 'open'));
$urgent = count(array_filter($prev, fn($t) => $t->priority == 'urgent'));
@endphp
{{ $open }} open ticket{{ $open == 1 ? '' : 's' }}, {{ $urgent }} urgent.

Rest/Operation (user) → Rest/Operation (orders) → Transformer

Transformer template, referencing the first node by name. $workflow->node() is a function call rather than a path, so this one is raw text with echo tags rather than a @json block:

{
"userId": {!! json_encode($workflow->node('fetch-user')->id) !!},
"email": {!! json_encode($workflow->node('fetch-user')->email) !!},
"orders": {!! json_encode($prev->data) !!},
"fetchedAt": {!! json_encode(now()->toIso8601String()) !!}
}

The bare $.path prefix syntax is only supported inside a @json block. Outside it, write the full function call:

// Wrong outside @json:
$.prevOutput.userId
// Correct:
{{ jsonpath($prev, '$.userId') }}

Inside @json, the root depends on whether you passed an argument:

// Global root — $.prev.userId, $.start.tenantId, etc.
@json
{ "userId": "$.prev.userId" }
@endjson
// Scoped root — $.userId means $prev->userId
@json($prev)
{ "userId": "$.userId" }
@endjson

If $prev->metadata can be absent, $prev->metadata->source throws at runtime. Use null-safe access for missing intermediate properties and null-coalesce for a default value:

// May throw:
{{ $prev->metadata->source }}
// Safe — null-safe property access:
{{ $prev->metadata?->source }}
// Safe with default:
{{ $prev->metadata?->source ?? 'unknown' }}

$prev is the upstream node’s output; $start is the flow’s start payload. In a webhook flow, $start contains the inbound request body. After a Transformer, $prev is the transformer’s output — not the original webhook body. Use $workflow->node('...') or $start to access earlier data.

{{ expr }} HTML-escapes the result. If you are building a JSON body and the value contains characters like ", <, or >, use {!! expr !!} to avoid double-encoding:

// Escapes quotes and angle brackets:
{{ $prev->description }}
// Raw value — safe for JSON:
{!! $prev->description !!}

Only functions on the allowlist can be called. Calling file_get_contents, exec, preg_replace_callback with closures, or any other function not in the list results in a compile-time error. The expression reference lists everything that is available.

Methods work on the helpers that return text, dates and lists (Str::of(…), Str::matchAll(…), now(), Carbon::parse(…)), on $workflow, and on the stores themselves: $kv->get(), $secrets->get() and $secrets->getString(), $signals->get() and $signals->all(). What a store hands back is data, like a node’s output, the start data and $page: read its fields with ->name, as in $prev->customer->email. A method call on them, such as $prev->toJson(), is refused when you save. When Publicus cannot tell until the flow runs, the node fails with the method’s name.

Casting or unquoting a path to get a native JSON type

Section titled “Casting or unquoting a path to get a native JSON type”

A quoted "$.count" already resolves to whatever type the value is, so a number arrives as a number. Both attempts to force it fail to compile:

Unquoting it stops the body being valid JSON:

@json($prev)
{ "count": $.count }
@endjson

Casting it stops the reference being the whole string, so it is emitted as the literal text (int)$.count:

@json($prev)
{ "count": "(int)$.count" }
@endjson

The quotes are how you write the reference, not what the value becomes:

@json($prev)
{ "count": "$.count" }
@endjson

The (int) form is pre-0.50 syntax. It no longer casts anything, and until 2026-08-21 it compiled without complaint and sent its own source text downstream. It is now a compile error.

Every @if must have a matching @endif. The editor checks this on blur (before saving) and shows an “unclosed directive” error.

  • Run timeline — open the run in Runs and inspect each node’s Input panel. The values shown are the resolved values after expression evaluation.

  • Lint markers in the editor — the editor compiles every keystroke (debounced) against the live scope. Gutter markers carry the exact compile diagnostic, including line and column of the offending token.

  • Transformer as a probe — add a temporary Transformer node with {{ json_encode($prev) }} as its template to dump the full upstream output and confirm the shape before writing your expression.

  • ConditionalExit logging — set a descriptive message field on ConditionalExit using expression syntax to record resolved values on the exit event. The message is written when the condition is truthy and the flow stops here:

    Account {{ $start->accountId }} has status {{ $prev->status }} — skipping.