> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bindai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 08.2 workflow condition

# Workflow Condition Template

The **Workflow Condition** template demonstrates how a workflow can make decisions and follow different execution paths based on runtime data.

Instead of always executing the same sequence of nodes, a Condition node evaluates the workflow context and routes execution to either the **true** or **false** branch.

This template introduces branching logic to BindAI workflows.

***

# Purpose

This template demonstrates how to:

* evaluate workflow variables
* create branching workflows
* execute different nodes based on conditions
* build decision-based automation

It extends the Basic Workflow template by introducing conditional execution.

***

# Workflow Structure

The workflow contains a single decision point.

```text id="wc1" theme={null}
Start

↓

Agent

↓

Condition

↙        ↘

True     False

↓

End
```

Only one branch continues execution.

***

# Execution Flow

The workflow executes sequentially until the Condition node.

```text id="wc2" theme={null}
Start

↓

Agent

↓

Evaluate Condition

↓

Choose Branch
```

The predicate determines which path is followed.

***

# Decision Logic

A Condition node evaluates a Boolean expression.

Conceptually:

```text id="wc3" theme={null}
approved == True

↓

True Branch
```

or

```text id="wc4" theme={null}
approved == False

↓

False Branch
```

The workflow automatically routes execution to the correct branch.

***

# Workflow Variables

Condition nodes commonly inspect workflow variables.

Example:

```text id="wc5" theme={null}
approved = True

↓

Condition

↓

Approved Path
```

Variables are typically created by earlier nodes, such as an Agent.

***

# Example

Suppose an AI agent determines whether a request should be approved.

```text id="wc6" theme={null}
Analyze Request

↓

approved = True

↓

Condition

↓

Approval Response
```

If approval is denied:

```text id="wc7" theme={null}
Analyze Request

↓

approved = False

↓

Condition

↓

Rejection Response
```

The remainder of the workflow depends on the decision.

***

# Agent Integration

Agents often provide the information required by the Condition node.

```text id="wc8" theme={null}
User Request

↓

Agent

↓

Workflow Variables

↓

Condition
```

This separation keeps reasoning inside the agent while orchestration remains inside the workflow.

***

# Branch Outputs

Each branch may execute completely different logic.

Example:

```text id="wc9" theme={null}
Condition

↙             ↘

Send Email   Create Ticket
```

Both branches eventually complete the workflow independently.

***

# Business Scenarios

Condition workflows are useful for:

* approval processes
* confidence thresholds
* document validation
* customer eligibility
* payment status
* routing requests
* escalation logic

Most production workflows contain multiple decision points.

***

# Condition vs Prompt Logic

Instead of embedding decisions inside prompts, BindAI separates orchestration from AI reasoning.

| Prompt Logic           | Workflow Condition      |
| ---------------------- | ----------------------- |
| Hidden inside prompts  | Visible workflow node   |
| Hard to debug          | Easy to inspect         |
| Mixed responsibilities | Clear separation        |
| Difficult to reuse     | Reusable workflow logic |

This separation improves maintainability.

***

# Extending the Template

Additional nodes can be added after each branch.

Example:

```text id="wc10" theme={null}
Condition

↙             ↘

Agent A      Agent B

↓

End
```

Or both branches can later merge into a common workflow.

***

# Related Templates

This template prepares you for more advanced workflow patterns:

* Workflow Loop
* Workflow Parallel
* Workflow Human
* Workflow Retry

Each builds upon conditional execution.

***

# Best Practices

* Keep predicates simple.
* Base decisions on workflow variables.
* Give branches descriptive names.
* Separate AI reasoning from workflow orchestration.
* Avoid placing complex business rules inside prompts.
* Test both the true and false branches.

***

# Summary

The **Workflow Condition** template introduces decision-making into BindAI workflows.

By evaluating workflow variables and routing execution dynamically, Condition nodes make workflows responsive, flexible, and significantly more powerful than simple sequential execution.
