---
title: "If-Else"
description: "Add conditional logic and branching to workflows"
icon: "code-branch"
---

The If-Else node adds decision-making logic to your workflows by routing execution down different paths based on conditions you define. It evaluates variables and determines which branch your workflow should follow.

<Frame caption="If-Else conditional branching example">
  <img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/d26ffff1b2ad0989d46e80d6812cf2e7.png" alt="Text summary workflow with conditional logic" />
</Frame>

## Branching Logic

The node supports multiple branching paths to handle complex decision trees:

**IF Path** executes when the primary condition evaluates to true.

**ELIF Paths** provide additional conditions to check in sequence when the IF condition is false. You can add multiple ELIF branches for complex logic.

**ELSE Path** serves as the fallback when no conditions match, ensuring your workflow always has a path to follow.

## Condition Types

Configure conditions to test variables using various comparison operators:

<Tabs>
  <Tab title="Text Operations">
    **Contains** / **Not contains** - Check if text includes specific words or phrases
    
    **Starts with** / **Ends with** - Test text beginnings or endings for pattern matching
    
    **Is** / **Is not** - Exact value matching for precise text comparison
  </Tab>
  
  <Tab title="Value Checks">
    **Is empty** / **Is not empty** - Check for blank, null, or missing values
    
    **Greater than** / **Less than** - Numerical comparisons for numbers and dates
    
    **Equals** / **Not equals** - Exact matching for any data type
  </Tab>
</Tabs>

## Complex Conditions

Combine multiple conditions using logical operators for sophisticated decision-making:

<Frame caption="Complex condition configuration with AND/OR logic">
  <img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/0b71ee7363e07298348e0c81e63481b0.png" alt="Multiple Condition Judgments" />
</Frame>

**AND Logic** requires all conditions to be true. Use this when you need multiple criteria to be met simultaneously.

**OR Logic** requires any condition to be true. Use this when you want to trigger the same action for different scenarios.

## Variable References

Reference any variable from previous workflow nodes in your conditions. Variables can come from user input, LLM responses, API calls, or any other workflow node output.

Use the variable selector to choose from available variables, or type variable names directly using the `{{variable_name}}` syntax.

## Common Patterns

**Content Routing** - Direct different types of content to specialized processing nodes based on categories, languages, or complexity.

**User Role Management** - Implement different workflow behaviors based on user permissions, subscription levels, or account types.

**Error Handling** - Check response status codes, data validity, or processing results to route workflows appropriately.

**Dynamic Processing** - Adjust workflow behavior based on input characteristics, processing results, or external conditions.

**Multi-path Workflows** - Create sophisticated branching logic that handles various scenarios and edge cases in your application.