nebulaflow

Condition Nodes (If/Else Nodes)

Condition nodes, also called If/Else nodes, provide conditional branching in workflows. They evaluate expressions and route execution to either the “true” or “false” path based on the result. These nodes are essential for creating dynamic workflows that respond to data and execution outcomes.

How Condition Nodes Work

A condition node evaluates a boolean expression and directs workflow execution accordingly:

The node has two distinct output ports labeled “True” and “False” in the UI, allowing you to connect different branches of your workflow.

Condition Evaluation Modes

Condition nodes support two evaluation modes based on their input connections:

1. Exit Code Mode (CLI-Connected)

When a condition node is connected to a CLI node, it automatically evaluates the CLI command’s exit code:

This is the most common pattern for checking command success or failure.

Example:

CLI Node (mkdir /tmp/data) → If/Else Node → [True: Process Data] / [False: Error Handler]

2. Expression Mode (Custom Condition)

When not connected to a CLI node (or when you want to override the exit code behavior), the condition node evaluates a custom expression stored in the content field.

Supported Operators:

Syntax:

[left_side] [operator] [right_side]

Example Conditions:

Configuration

Condition Expression (Content Field)

Node Properties

Input/Output

Inputs

Outputs

Execution Behavior

Path Selection

Parallel Execution

Examples

Example 1: Check CLI Exit Code

Workflow:

CLI Node: mkdir /tmp/data
  ↓
If/Else Node: (auto-evaluates exit code)
  ↓
True Path → LLM Node: "Directory created successfully"
False Path → CLI Node: echo "Failed to create directory"

Configuration:

Example 2: Validate Output Content

Workflow:

LLM Node: "Generate a status message"
  ↓
If/Else Node: ${1} == success
  ↓
True Path → CLI Node: echo "Task completed"
False Path → LLM Node: "Analyze the failure"

Configuration:

Example 3: Compare Two Values

Workflow:

Variable Node: "expected" = "done"
  ↓
CLI Node: process-data.sh
  ↓
If/Else Node: ${1} == ${2}
  ↓
True Path → Preview Node: "Values match"
False Path → Preview Node: "Values don't match"

Configuration:

Example 4: Error Handling Pattern

Workflow:

CLI Node: fetch-data.sh
  ↓
If/Else Node: (checks exit code)
  ↓
True Path → LLM Node: "Process the data"
False Path → CLI Node: send-alert.sh
  ↓
If/Else Node: ${1} == retry
  ↓
True Path → Loop Node (retry fetch)
False Path → End Workflow

Best Practices

1. Clear Naming

2. Exit Code vs Expression

3. Template Variables

4. Error Handling

5. Avoid Complex Conditions

6. Testing

Troubleshooting

Condition Always Evaluates to False

Condition Always Evaluates to True

Exit Code Not Working

Template Variables Not Substituted

Both Paths Executing

Condition Node Not Executing

Integration with Other Nodes

Before Condition

After Condition (True Path)

After Condition (False Path)

Common Patterns

Configuration Example

ifelse_node:
  title: "Check Data Quality"
  content: "${1} == valid"
  active: true
  bypass: false
  needsUserApproval: false
  shouldAbort: false

Next Steps