Workflow conditions accept JavaScript expressions wrapped in double curly braces(`{{ ... }}`)
to dynamically evaluate logic. These expressions are enclosed in double curly braces (`{{ ... }}`)
and evaluated at runtime.
Expressions can access:
- Data from previous steps (
$json
, $prev
, etc.)
- The loop context
- Built-in functions and utility libraries
For example, this checks if a status is "active"
:
{{ $json["status"] === "active" }}
Expressions must be written as a single line of JavaScript. Multi-line code or variable declarations are not supported.
You can access the following contextual data inside expressions:
Token | Description |
---|
$json | The JSON object from the current or previous step |
$prev | Data from the previous node |
DateTime | Utility for working with dates and times (Luxon) |
Example:
{{ $json.customer.subscription.status === "trialing" }}
Type conversion tip
Some values (such as “true” or “false”) are returned as strings. To ensure your conditions behave as expected, you can enable “Convert types where required” in the Condition node settings.
Without type conversion:
{{ $json["isTrialActive"] }}
// Evaluates to string "true", which may not behave like a boolean
With type conversion enabled:
{{ $json["isTrialActive"] === "true" }}
Alternatively:
{{ Boolean($json["isTrialActive"]) }}
Example: Remove addon from a subscription
At the end of a billing period, remove a specific addon from a subscription if it exists.
-
Run this workflow on a schedule or based on a billing-related event.
-
Use the List Subscriptions action to retrieve active subscriptions.
-
Use a loop node to iterate through the returned subscriptions.
-
For each subscription, loop through its
addons
array.
-
Condition Check
Use a Condition node to check if a specific addon is present:
{{ $json["addonId"] === "target-addon-id" }}
- Update Subscription
If the addon exists, update the subscription using the Update Subscription action:
- Subscription ID: Pass from the previous loop context
- Addons: Supply a filtered list that excludes the unwanted addon
Example using a transformation node before update:
const filteredAddons = $json["addons"].filter(addon => addon.addonId !== "target-addon-id");
return { addons: filteredAddons };
To remove all addons, pass an empty array: []
.
Using Luxon for date manipulation
The DateTime
object is available for date handling inside expressions.
Examples: get dates
Get today’s ISO date:
{{ DateTime.now().toISODate() }}
Get the number of months between two dates:
{{ DateTime.fromISO('2025-07-01').diff(DateTime.fromISO('2025-04-01'), 'months').toObject() }}
Multi-line code blocks and variable declarations are not allowed in expressions.
Invalid (multi-line code block)
{{
let start = DateTime.fromISO('...');
let end = DateTime.fromISO('...');
return end.diff(start, 'days');
}}
Valid (single-line expression)
{{ DateTime.fromISO('2025-07-01').diff(DateTime.fromISO('2025-06-01'), 'days').toObject() }}
If your input JSON contains nested fields, you can access them like this:
{{ $json["body"]["user"]["location"] }}
Or with optional chaining:
{{ $json?.body?.user?.location }}
Troubleshooting common issues
Issue | Solution |
---|
Condition fails unexpectedly | Enable “Convert types where required” or check your type comparisons |
Expression returns undefined | Make sure the key path is correct; use optional chaining (?. ) |
Cannot reference a value | Confirm the value exists in the current execution context ($json ) |
Date math errors | Use ISO-formatted strings and the DateTime library |