If Condition
Evaluates a boolean condition against the input payload to bifurcate the execution flow.
Evaluates a condition and sends the unchanged payload through true or false.
This operator functions as a gateway that routes execution to either the 'true' or 'false' port based on the result of the configured expression. It supports two evaluation modes: the Sommatic AI Expression Engine ({{ }} syntax, full JavaScript via vm.Script) as the primary engine, and raw JSONata as a simpler fallback for expressions entered without {{ }}.
Behavior:
- If the expression evaluates to a truthy value, execution proceeds through the 'true' port.
- If the expression evaluates to a falsy value, execution proceeds through the 'false' port.
- If 'treat_missing_as' is set to true and the expression yields undefined/null, it is treated as false.
How it works
- Resolves
expr: a{{ }}is evaluated by the Expression Engine (JavaScript in an isolated context, 100 ms limit) with$json,$("Node"),$nowand the other engine variables. - If the resolved value is
undefined,nullor"", returns an error envelope without a port (see errors). - A boolean is used as is.
- A string is evaluated as JSONata against the payload, where fields are referenced directly:
amount > 1000,status = "active". This also applies to a{{ }}that returned a string, and to a{{ }}that failed in the engine (its raw text is then parsed as JSONata and fails). - Any other type (number, object, array) cannot be compiled as JSONata and goes to
error. - Converts the result with
!!resultand sends the payload throughtrueorfalse, withmeta.evaluation{ expr, result, raw_result }(expris the original text).
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-high-value",
"label": "High value?",
"operator_slug": "flow.if",
"operator_version": "1.0.0",
"config": {
"expr": "{{ $json.amount > 1000 }}",
"treat_missing_as": false
}
}{
"ok": true,
"data": {
"order_id": "ord_123",
"amount": 1250,
"status": "active"
},
"port": "true",
"meta": {
"evaluation": {
"expr": "{{ $json.amount > 1000 }}",
"result": true,
"raw_result": true
}
}
}Configuration
-
exprstring Required Accepts expressions -
An expression that must evaluate to a boolean. Wrap it in {{ }} to use the Sommatic AI Expression Engine (JavaScript) with variables like $json, $input or $("Node Name"), e.g. {{ $json.age >= 18 }} or {{ $json.status === "active" }}. Without {{ }} the text is evaluated as JSONata against the payload, where fields are referenced directly: age >= 18 or status = "active". $json is not bound in JSONata, so $json.age >= 18 without {{ }} always evaluates to false.
-
treat_missing_asboolean Optional -
If enabled, undefined or null results from the expression will automatically route to the False port instead of throwing an error.
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
expr - Without
{{ }},$jsonis not bound in JSONata:$json.amount > 1000is always false. A{{ }}returning a string such as{{ $json.name }}is evaluated again as a JSONata path and is usually false. -
treat_missing_as - Has no visible effect:
undefinedandnullresults always go tofalse, and nothing is thrown either way.
Output ports
true default The condition is truthy.
{
"order_id": "ord_123",
"amount": 1250,
"status": "active"
}false The condition is falsy, including undefined and null JSONata results.
{
"order_id": "ord_124",
"amount": 80,
"status": "active"
}error JSONata compilation or evaluation failed.
{
"ok": false,
"errors": [
"Expression evaluation failed: path.charAt is not a function"
],
"port": "error"
}In expressions
What a later node can read from this node's output with $("If Condition").item.json.<path> (write your node's label instead of If Condition). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through true, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("If Condition").item.json.payload | — | |
$("If Condition").item.json.order_id | — | |
$("If Condition").item.json.amount | — | |
$("If Condition").item.json.status | — |
— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.
— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).
Errors
| Message | Port | Cause and fix |
|---|---|---|
Missing configuration: expr is required. | out | expr is empty or its {{ }} returned undefined, null or "" (for example {{ $json.flag }} on a missing field). The envelope has no port, so the engine routes it to out, which this node does not have: the branch stops silently. Compare explicitly, for example {{ $json.flag === true }}. |
Expression evaluation failed: path.charAt is not a function | error | The {{ }} returned a number, object or array. Return a boolean, for example {{ $json.items.length > 0 }}. |
Expression evaluation failed: <JSONata message> | error | Invalid JSONata, or a {{ }} with a JavaScript error whose raw text was then parsed as JSONata (for example Expected ":", got "}"). |
Input contract
-
payloadobject Optional
Output contract
-
payloadobject Optional
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "flow.if",
"name": "If Condition",
"category": "flow",
"description": "Evaluates a boolean condition against the input payload to bifurcate the execution flow.\n\n This operator functions as a gateway that routes execution to either the 'true' or 'false' port based on the result of the configured expression. It supports two evaluation modes: the Sommatic AI Expression Engine ({{ }} syntax, full JavaScript via vm.Script) as the primary engine, and raw JSONata as a simpler fallback for expressions entered without {{ }}.\n\n **Behavior:**\n - If the expression evaluates to a truthy value, execution proceeds through the 'true' port.\n - If the expression evaluates to a falsy value, execution proceeds through the 'false' port.\n - If 'treat_missing_as' is set to true and the expression yields undefined/null, it is treated as false.",
"capabilities": [
"branching",
"logic",
"expression-engine",
"jsonata"
],
"config_schema": {
"type": "object",
"required": [
"expr"
],
"properties": {
"expr": {
"type": "string",
"title": "Condition Expression",
"description": "An expression that must evaluate to a boolean. Wrap it in {{ }} to use the Sommatic AI Expression Engine (JavaScript) with variables like $json, $input or $(\"Node Name\"), e.g. {{ $json.age >= 18 }} or {{ $json.status === \"active\" }}. Without {{ }} the text is evaluated as JSONata against the payload, where fields are referenced directly: age >= 18 or status = \"active\". $json is not bound in JSONata, so $json.age >= 18 without {{ }} always evaluates to false.",
"format": "expression"
},
"treat_missing_as": {
"type": "boolean",
"title": "Treat Missing as False",
"description": "If enabled, undefined or null results from the expression will automatically route to the False port instead of throwing an error.",
"default": false
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
},
"input_contract_schema": {
"type": "object",
"description": "The JSON payload to be evaluated by the expression.",
"properties": {
"payload": {
"type": "object"
}
}
},
"output_contract_schema": {
"type": "object",
"description": "The original payload is passed through to the selected output port.",
"properties": {
"payload": {
"type": "object"
}
}
},
"ports": [
{
"port_id": "true",
"label": "True",
"is_default": true,
"supports_condition": true,
"description": "Active when expression is true."
},
{
"port_id": "false",
"label": "False",
"supports_condition": true,
"description": "Active when expression is false."
},
{
"port_id": "error",
"label": "Error",
"description": "Active when expression evaluation fails."
}
],
"execution_mode": "sync",
"tags": [
"logic",
"condition",
"branch",
"control-flow"
],
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"required": [
"expr"
],
"properties": {
"expr": {
"type": "string",
"title": "Condition Expression",
"description": "An expression that must evaluate to a boolean. Wrap it in {{ }} to use the Sommatic AI Expression Engine (JavaScript) with variables like $json, $input or $(\"Node Name\"), e.g. {{ $json.age >= 18 }} or {{ $json.status === \"active\" }}. Without {{ }} the text is evaluated as JSONata against the payload, where fields are referenced directly: age >= 18 or status = \"active\". $json is not bound in JSONata, so $json.age >= 18 without {{ }} always evaluates to false.",
"format": "expression"
},
"treat_missing_as": {
"type": "boolean",
"title": "Treat Missing as False",
"description": "If enabled, undefined or null results from the expression will automatically route to the False port instead of throwing an error.",
"default": false
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
}{
"type": "object",
"description": "The JSON payload to be evaluated by the expression.",
"properties": {
"payload": {
"type": "object"
}
}
}{
"type": "object",
"description": "The original payload is passed through to the selected output port.",
"properties": {
"payload": {
"type": "object"
}
}
}[
{
"port_id": "true",
"label": "True",
"is_default": true,
"supports_condition": true,
"description": "Active when expression is true."
},
{
"port_id": "false",
"label": "False",
"supports_condition": true,
"description": "Active when expression is false."
},
{
"port_id": "error",
"label": "Error",
"description": "Active when expression evaluation fails."
}
]Execution
- Execution
sync- Stateful
- No
- Retries (
retryOnFail) - No
- Capabilities
branchinglogicexpression-enginejsonata- Tags
logicconditionbranchcontrol-flow
Notes and limits
metais recorded in the run steps only: downstream nodes receivedataas their payload and cannot readmetathrough$jsonor$("Node").- When the envelope has no
data(ordatais falsy), the engine stores the whole envelope as the node output: onerrorthe next node receives{ ok: false, errors: [...], port: "error" }as its payload.
Reviewed against the orchestrator code · 31e874b · 2026-11-26