If/Else Node

The If/Else Node is a logic node that lets you route the flow of your workflow based on conditions. It checks the output of a previous node (or nodes) and, depending on whether the condition is true or false, sends the data down different branches.


How It Works in Your Workflow

Condition Setup

In your workflow, the If/Else node always takes an input from the left side. The input allows you to define the conditions. Each condition is then routed to its corresponding output according to the branching logic defined.

The available condition operators you can use in the If/Else node are:

  • equals: Checks if the left variable is exactly equal to the right variable.

  • not equals: Checks if the left variable is not equal to the right variable.

  • contains: Checks if the left variable (usually a string or list) contains the right variable.

  • not contains: Checks if the left variable does not contain the right variable.

  • greater than: Checks if the left variable is greater than the right variable (for numbers).

  • greater than or equal: Checks if the left variable is greater than or equal to the right variable.

  • less than: Checks if the left variable is less than the right variable.

  • less than or equal: Checks if the left variable is less than or equal to the right variable.

  • is empty: Checks if the left variable is empty (no value, empty string, or empty list).

  • is not empty: Checks if the left variable is not empty.

You can combine multiple conditions using logical operators like and or or to create more complex branching logic.

Example usage:

  • {llm-0} contains "DONE"

  • {in-0} equals "yes"

  • {llm-1} is not empty


Adding Branches

Add another branch by choosing "+ Add IF/ELSE Branch"


Examples of Typical Use Cases

  • Multi-step reasoning

    • If an LLM response does not include "FINAL" or is missing a section, send it to another LLM to refine the answer.

    • If the answer is too short, route it to a second model for expansion.

  • Rule-based expert routing

    • If a question contains keywords like finance or healthcare, route it to an LLM configured for that industry.

    • If a request mentions a known product or system, route it to the corresponding tool or knowledge base.

  • Quality checks

    • If required fields (title, summary, ID) are missing, stop or reroute the workflow.

    • If the output is empty or malformed, retry or correct before continuing.

  • Efficiency-first routing

    • If a request can be answered with rules or lookup data, skip the LLM step.

    • If the input matches a known pattern, route directly to a lightweight tool.

Key Points

  • The If/Else node does not process or change the data itself; it only checks the condition and routes the data.

  • You can set up multiple conditions and even use "elif" branches for more complex logic.

  • The left and right variables can reference any previous node’s output or any input.

Routing Strategies & Best Practices

If/Else vs. AI Routing — When to Use Which

  • Use If/Else for clear, rule-based logic (exact matches, flags, thresholds, empty values, known keywords).

  • Use If/Else when routing must be predictable, transparent, and easy to debug.

  • Use AI Routing when decisions depend on semantic understanding or user intent.

  • Use AI Routing for fuzzy, ambiguous, or natural-language–driven routing where rules are hard to define.

Note: If/Else is faster and more cost-efficient, while AI Routing introduces additional latency because it requires a model call.

Note on error handling

You can handle LLM errors very effectively directly from the LLM Advanced Settings. Each LLM node supports fallback options that improve reliability without extra logic:

  • LLM Fallback Mode: automatically switch to a backup model/provider if the primary model fails.

  • Fallback Branch: route the workflow to a different path if the LLM execution fails.

Learn more in LLM Advanced Settingsarrow-up-rightFallbacks & Error Handling.

Last updated

Was this helpful?