Developer Guide: The Conditional Node
Here is the updated documentation for the new Conditional node.
Logic & Control Flow: The Conditional Node
The Conditional node is a powerful control flow utility that evaluates a complex logical expression. Its purpose
is to return the string "TRUE" or "FALSE" based on the outcome. This node is a fundamental building block for
creating dynamic workflows, as its output can be used by a ConditionalCustomWorkflow node to decide whether or not to
execute a subsequent sub-workflow.
It supports:
- Comparisons between numbers or strings (e.g.,
{score} > 90,'{status}' == 'complete'). - Logical operators
ANDandORto combine multiple conditions. - Parentheses
()to group expressions and control the order of evaluation.
How It Works
- Configuration Loading: The processor loads the node's JSON configuration and its
conditionstring. - Variable Substitution: The
conditionfield is processed, replacing any placeholders like{agent1Output}with their runtime values. - Expression Parsing: The system uses a standard Shunting-yard algorithm to parse the entire expression. This
correctly handles operator precedence (
ANDis evaluated beforeOR) and nested expressions within parentheses. - Type Inference: During evaluation, the node intelligently parses each value.
- A value enclosed in single or double quotes (e.g.,
"Admin") is treated as a string. - The special words
TRUEandFALSE(case-insensitive, without quotes) are treated as booleans. - Any other unquoted value is first attempted as a number. If it's not a valid number, it's treated as a * string* (e.g., the resolved output of a variable).
- A value enclosed in single or double quotes (e.g.,
- Evaluation: The full expression is evaluated according to logical rules. Comparing a number to a string (e.g.,
5 > "cat") will safely result inFALSE. - Output Handling:
- The node returns the string
"TRUE"if the final expression evaluates to true, and"FALSE"otherwise. - If the condition is malformed or a syntax error occurs, it safely returns
"FALSE"and logs a warning. - The string output is captured as a variable (e.g.,
{agent2Output}), which can be directly used to control other nodes.
- The node returns the string
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
type |
String | Yes | N/A | Must be "Conditional". |
title |
String | No | "" |
A descriptive name for the node, used for logging and debugging. |
condition |
String | Yes | N/A | The logical expression to evaluate (e.g., ({val} >= 100 AND '{status}' != 'ERROR') OR {is_override} == TRUE). |
returnToUser |
Boolean | No | false |
This node is designed for internal logic and its output is not intended for the end-user. |
Variable Usage
The condition property supports all available workflow variables. The node will automatically determine the type (
number, string, or boolean) of the resolved variable. For string literals in the condition itself, it is best practice
to enclose them in quotes (e.g., "completed").
⚠️ Critical Usage Note: Comparing Booleans vs. Strings
The node's type inference engine makes a critical distinction between a boolean TRUE and a string 'TRUE'. This is
especially important when checking the output of a previous Conditional node.
The Conditional node outputs the raw string TRUE or FALSE. When this output (e.g., {agent3Output}) is used in
another condition, the parser interprets it as a boolean.
INCORRECT Comparison:
"{agent3Output} == 'TRUE'"- This will evaluate as
(boolean) True == (string) 'TRUE', which is FALSE.
- This will evaluate as
CORRECT Comparison:
"{agent3Output} == TRUE"- This will evaluate as
(boolean) True == (boolean) True, which is TRUE.
- This will evaluate as
Always compare the output of a Conditional node against the unquoted keywords TRUE or FALSE.
Full Syntax Examples
Simple Numeric Comparison This example checks if a calculated score from a previous node is passing.
{
"title": "Check if score is passing",
"type": "Conditional",
"condition": "{agent4Output} >= 65"
}
Combined Logic with AND
This example checks if the string output from a task is 'complete' and was not assigned to a user named 'guest'.
{
"title": "Check if task is complete and not a guest task",
"type": "Conditional",
"condition": "{agent2Output} == 'complete' AND {agent1Output} != 'guest'"
}
Complex Logic with OR and Parentheses
This example demonstrates how to check for multiple valid states or an override condition. The parentheses ensure the
OR conditions are evaluated together before the AND. Note the correct comparison to the unquoted boolean TRUE.
{
"title": "Check for valid state or admin override",
"type": "Conditional",
"condition": "({agent1Output} == 'Admin') OR ({agent2Output} == 'Approved' AND {agent3Output} == TRUE)"
}