Logic
Condition Node
Implement control-flow logic in your pipeline
The condition node allows you to implement control-flow logic in your pipeline by creating multiple execution paths based on conditional statements. Use a condition node when you want certain nodes to execute only when specific conditions are met.
How to Use
- Click “+ Add Path” to create additional paths
- Customize the logic statement in each path
- Input: the value you want to compare. Use:
{{
to open the variable builder to reference values from other nodes. - Operator: the operation to do the comparison. See full list of operators in the next section.
- Value: the comparison value.
- Input: the value you want to compare. Use:
- You can click “Add Clause” to build compound conditional statements within a path. Compound conditional statements are multiple clause logic statements combined with And / Or logic between them.
- Clauses are evaluated from top to bottom. The first path that evaluates as True will be the one that is taken.
- If no path executes as True, then “Path Else” is the one that will be taken.
- Connect the different downstream nodes to the different path depending on what you want to happen based on the logic.
Operators
- Comparison Operators:
- Equal to (
==
) - Not equal to (
!=
) - Greater than (
>
) - Less than (
<
) - Greater than or equal to (
>=
) - Less than or equal to (
<=
)
- Equal to (
- Text Operators:
- Contains
- Does Not Contain
- Begins With
- Does Not Begin With
- Ends With
- Does Not End With
- Greater Than N Characters
- Less Than N Characters
- Is Empty
- Is Not Empty
- Is True
- Is False
- List Operators:
- List Contains
- List Does Not Contain
- Map Operators:
- Map Contains Key
- Expression
- Custom Expression
Considerations
- Clauses can be reordered by dragging within their condition group
- Use a merge node to combine multiple conditional paths into a single flow (often used in chat flows before connecting to an output node)
- The condition node doesn’t produce data outputs - it only controls which path executes
- To access data from upstream nodes in nodes downstream of the condition node, reference the outputs of the upstream nodes.
Example
In the below example, we have a condition node with two paths.
- If
text_0 = hello
, then path 0 will execute (which is false;text_0 = orange
) - If
text_1 = apple
, then path 1 will execute (which is true) - Path 1 executes, and we merge both paths together before displaying the output. Path 1 is a text node that prints out
text_1
(“apple”). Hence, the output is apple.