Skip to main content

Branch

Controlled node

Overview

The Branch node routes workflow execution through different paths based on comparing an input value against a set of configurable conditions. It evaluates each branch condition in order and fires the output event corresponding to the first matching condition. If no conditions match, the node fires the default event.

This node is useful for implementing conditional logic, decision trees, or routing data based on thresholds (e.g., grading scores, categorizing values, or handling different API response codes).

Branch Configuration

Branches are configured in the node's properties panel. Each branch consists of:

  • Name: The identifier for the output event (e.g., "high", "medium", "low")
  • Operation: The comparison operator (<, <=, ==, >=, >)
  • Value: The threshold or target value to compare against
Dynamic Outputs

The output events are created dynamically based on your branch configuration. Each branch you add creates a corresponding output event socket with the branch's name.

Inputs

InputTypeDescriptionDefault
RunEventTriggers the branch evaluation-
ValueDataThe value to compare against branch conditions-

Outputs

OutputTypeDescription
DefaultEventFires when no branch conditions match the input value
[Branch Names]EventDynamically created outputs for each configured branch (e.g., "high", "medium", "low")

Runtime Behavior

When the Run event fires, the node evaluates the Value input against each branch condition in the order they were configured:

  1. Comparison Logic: Uses the specified operator to compare the input value against the branch's configured value

    • Numeric comparisons: Standard mathematical comparison (5 > 3 → true)
    • String comparisons: Lexicographic ordering ("apple" < "banana" → true)
    • Equality (==): Loose equality check (works for both strings and numbers)
  2. First Match Wins: The node fires the output event for the first branch where the condition evaluates to true, then stops evaluating remaining branches.

  3. Default Fallback: If no branch conditions match, the Default output event fires.

  4. Type Coercion: Values are compared as strings by default unless both values can be parsed as numbers, in which case numeric comparison is used.

Branch Order Matters

Since evaluation stops at the first match, order your branches carefully. For example, checking > 80 before > 90 would mean the > 90 branch never fires (as values over 90 are also over 80).

Example

Grading System

Route student scores to different grade categories:

Configuration:

  • Branch 1: Name=A, Operation=>=, Value=90
  • Branch 2: Name=B, Operation=>=, Value=80
  • Branch 3: Name=C, Operation=>=, Value=70
  • Branch 4: Name=D, Operation=>=, Value=60

Execution:

  • Input Value: 85
  • Result: Fires the B event (since 85 >= 80 and 80 < 90)
  • Connected nodes: Connect AI Write nodes to each grade branch to generate personalized feedback

Status Code Routing

Handle different HTTP response codes:

Configuration:

  • Branch 1: Name=success, Operation===, Value=200
  • Branch 2: Name=not_found, Operation===, Value=404
  • Branch 3: Name=error, Operation=>=, Value=500

Execution:

  • Input Value: 404
  • Result: Fires the not_found event
  • Connected nodes: Connect to different API request retry logic or error handling paths