> For the complete documentation index, see [llms.txt](https://docs.empowergpt.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.empowergpt.ai/workflows/block-types/if-else.md).

# If/Else

The **If/Else** block adds conditional logic to a workflow, allowing different workflow paths to execute based on data from previous blocks.

Each **IF** branch contains one or more conditions. EmpowerGPT evaluates these conditions and determines which branch or branches should execute based on the configured **Branch Execution** mode.

Use If/Else when different actions should be performed depending on the value of a field, variable, or output from a previous block.

<div data-with-frame="true"><figure><img src="https://2192711725-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fc2KRGWrkyRO0iZN5Lyeg%2Fuploads%2F5tjD6UL4Ri39mGbL9Kjf%2Fimage.png?alt=media&amp;token=1a6884bb-36a2-4513-b35f-238eaa4a88f7" alt=""><figcaption></figcaption></figure></div>

### When to Use If/Else

Use the If/Else block when your workflow needs to make decisions based on specific conditions.

Common examples include routing requests based on status or category, checking whether a value exceeds a threshold, determining whether text contains a specific value, handling different outcomes from an Agent, and creating approval or exception paths.

For example:

**Form Trigger → Agent → If/Else**

The Agent could classify a request as `High`, `Medium`, or `Low` priority. The If/Else block can then route the workflow to the appropriate branch.

***

## Configuration

The If/Else block has two main areas of configuration:

1. **Branch Execution** – determines how matching IF branches are executed.
2. **IF/Else Conditions** – defines the rules used to determine whether a branch matches.

***

## Branch Execution

**Branch Execution** determines what happens when more than one IF branch matches the provided data.

| Option                            | Description                                                                                                                             |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| **First match wins (Sequential)** | Conditions are evaluated sequentially. Once a matching IF branch is found, that branch executes and the remaining branches are skipped. |
| **Allow multiple conditions**     | All configured IF branches are evaluated, allowing multiple matching branches to execute.                                               |

### First Match Wins (Sequential)

With **First match wins**, EmpowerGPT evaluates the IF branches in order.

As soon as a matching branch is found, that branch is executed and the remaining IF branches are not evaluated for execution.

For example:

**IF 1:** Score greater than or equal to `80`\
→ High Score

**IF 2:** Score greater than or equal to `50`\
→ Medium Score

**ELSE**\
→ Low Score

If the score is `90`, both IF conditions could logically match. However, because **IF 1** is evaluated first, only the **High Score** branch executes.

> **Tip:** When using First match wins, place more specific conditions before broader conditions.

### Allow Multiple Conditions

With **Allow multiple conditions**, EmpowerGPT evaluates all configured IF branches.

If multiple IF conditions match, each corresponding branch can execute.

For example:

**IF 1:** Message contains `urgent`\
→ Notify Support Team

**IF 2:** Message contains `refund`\
→ Start Refund Process

If a message contains both `urgent` and `refund`, both matching branches can execute.

Use this option when conditions are independent and more than one workflow path may need to run.

***

## Configuring an IF Condition

Each IF condition consists of three main fields:

| **Field**      | **Description**                                                                                                       |
| -------------- | --------------------------------------------------------------------------------------------------------------------- |
| **Field**      | The value that should be evaluated. You can enter text directly or reference data from previous blocks using `{{ }}`. |
| **Operator**   | Defines how the Field should be compared with the Match Text.                                                         |
| **Match Text** | The value against which the Field is evaluated.                                                                       |

A basic condition follows this structure:

**Field → Operator → Match Text**

For example:

**Field:** `{{Agent.Priority}}`\
**Operator:** Equals\
**Match Text:** `High`

If the referenced field contains `High`, the condition matches and the corresponding IF branch can execute.

***

## Operators

The **Operator** determines how the Field is compared against the configured Match Text.

EmpowerGPT provides the following operators:

| Operator                  | Description                                                               | Example                             |
| ------------------------- | ------------------------------------------------------------------------- | ----------------------------------- |
| **Equals**                | Checks whether the Field equals the Match Text.                           | Status equals `Approved`            |
| **Not Equals**            | Checks whether the Field does not equal the Match Text.                   | Status does not equal `Rejected`    |
| **Contains**              | Checks whether the Field contains the specified Match Text.               | Message contains `urgent`           |
| **Less than**             | Checks whether the Field is less than the specified value.                | Score less than `50`                |
| **Less than or equal**    | Checks whether the Field is less than or equal to the specified value.    | Score less than or equal to `50`    |
| **Greater than**          | Checks whether the Field is greater than the specified value.             | Amount greater than `1000`          |
| **Greater than or equal** | Checks whether the Field is greater than or equal to the specified value. | Score greater than or equal to `80` |

Choose the operator according to the type of comparison required by your workflow

***

## Else Branch

The **Else** branch provides a fallback path for cases where the configured IF conditions do not match.

For example:

**IF:** Amount **Greater than or equal** `5000`\
→ Approval Required

**ELSE**\
→ Continue Processing

If the amount is `7500`, the IF branch executes. If the amount is `3000`, the workflow follows the Else branch.

The Else branch is useful for ensuring that the workflow has a defined path when the configured IF conditions are not satisfied.

***

## Example: Priority-Based Routing

Suppose an Agent analyzes incoming requests and returns a priority.

Configure the If/Else block as follows:

#### IF 1

**Field:** Agent Priority\
**Operator:** Equals\
**Match Text:** `High`

→ Send to High Priority Processing

#### IF 2

**Field:** Agent Priority\
**Operator:** Equals\
**Match Text:** `Medium`

→ Send to Standard Processing

#### ELSE

→ Send to Low Priority Processing

The workflow becomes:

**Integration Trigger → Agent → If/Else**

From the If/Else block, the workflow follows the appropriate path based on the priority returned by the Agent.

***

## Example: Numerical Threshold

Suppose a Form Trigger collects a purchase amount and requests above a certain value require additional approval.

Configure:

**Field:** Amount\
**Operator:** Greater than or equal\
**Match Text:** `5000`

The workflow can then branch as:

**IF → Amount ≥ 5000 → Approval Process**

**ELSE → Continue Processing**

This provides a simple way to implement threshold-based business rules without writing code.

***

## Best Practices

**Order conditions carefully**\
When using **First match wins (Sequential)**, place the most specific conditions first because the first matching branch is the one that executes.

**Use Allow multiple conditions only when branches are independent**\
Enable it when it is valid for more than one workflow path to execute for the same input.

**Choose the appropriate operator**\
Use Equals or Not Equals for exact comparisons, Contains for text matching, and the numerical comparison operators for thresholds and ranges.

**Use an Else path for unmatched cases**\
Where appropriate, configure the Else branch to handle values that do not satisfy any IF condition.

**Test boundary values**\
For numerical comparisons, test values at the boundaries. For example, if your condition is **Greater than or equal to 5000**, test values such as `4999`, `5000`, and `5001`.

**Use clear branch logic**\
Configure conditions so that another person reviewing the Canvas can easily understand why each workflow path executes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.empowergpt.ai/workflows/block-types/if-else.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
