If / Else
Evaluates one or more conditions and continues down the If True or the If False port.
To route to more than two branches use Switch; to drop items from a list use Filter. Both use the same condition builder.
Conditions
Build conditions like sentences: field · check · value.
- Field to check: click + Data (or type
{{) and pick a field of an earlier step. - Check: the list is in plain words for what the field holds, for example is, contains, is empty for text, is greater than, is at least for numbers, is before, is after for dates, has more items than for lists. Under the field, Checked as a date (etc.) shows how it is compared.
- Value: type a value or insert data. Checks such as is empty need no value.
Choose all or any at the top: the workflow continues on True when all (or any) of the conditions are true. Add group adds conditions with their own all/any, e.g. status is "paid" and (country is "DE" or country is "AT"). The ⋯ menu of a row sets Compare as explicitly, Match upper / lower case for text, and moves the row.
Picking a field sets the row's type from the field's data (If / Else 2.0 typed conditions). Rows you don't change are saved exactly as they were, so workflows built with If / Else 1.x keep their behaviour.
Reference
Each stored condition has:
| Field | Description |
|---|---|
| Value | The left-hand value, usually an expression, e.g. {{ $nodes['HTTP Request'].statusCode }} |
| Type | How both sides are compared: Auto (default), Text, Number, Boolean, Date, Array or Object |
| Operator | The comparison (see below). The list is narrowed to operators that fit the type |
| Compare value | The right-hand value. Hidden for operators that need only one value |
| Case sensitive | Text comparisons ignore case unless this is on |
Combining conditions
Conditions are combined with AND (all must match) or OR (any must match). You can also add a group
of conditions with its own AND/OR, e.g. status equals "paid" AND (country equals "DE" OR country equals "AT").
Operators
| Group | Operators |
|---|---|
| Equality | equals, does not equal |
| Text & lists | contains, does not contain, starts with, ends with, matches regex, does not match regex |
| Length (Text / Array type only) | length equals, length greater than, length less than |
| Comparison | greater than, greater than or equal to, less than, less than or equal to, is before, is after |
| Existence | exists, does not exist, is empty, is not empty |
| Boolean | is true, is false |
is empty is true for null, an empty string, an empty array or an empty object. exists is true when the
value is not null. Regular expressions time out after 1 second.
Types
With a type set, both values are converted before comparing:
- Number —
"10"is greater than"9". - Date — ISO strings and timestamps are compared as instants, so
is before/is afterare exact. - Text — ordinal comparison;
greater thanetc. compare alphabetically. - Boolean —
"true"/"false"strings and real booleans. - Array —
containschecks whether an element equals the compare value. - Object —
containschecks whether the object has a key named by the compare value.
If a value can't be converted to the chosen type, the condition is false. An operator that doesn't apply to
the type (for example starts with on a Number) fails the step.
Auto infers the comparison from the values — the behaviour of If/Else 1.x. Workflows built with If/Else 1.x keep working unchanged; their conditions simply use Auto.
Output ports
| Port | When |
|---|---|
true (If True) | The conditions matched |
false (If False) | The conditions did not match |
Only the matching branch runs. You can leave a port unconnected if you only care about one outcome.
Examples
Check that an API call succeeded:
- Value:
{{ $nodes['HTTP Request'].statusCode }} - Type: Number
- Operator: less than
- Compare value:
400
Branch on whether an earlier step failed (useful after an error port):
- Value:
{{ $status['HTTP Request'].isSuccess }} - Operator: is true
Orders placed in the last 7 days:
- Value:
{{ $trigger.body.createdAt }} - Type: Date
- Operator: is after
- Compare value:
{{ $now.minus({ days: 7 }).toISO() }}
Errors
The step fails if no condition is configured, a condition has no operator, or a regular expression is invalid.