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

# Condition Node

> Go different directions based on yes/no questions

The Condition node asks a yes/no question and sends your workflow down different paths based on the answer. It's like a fork in the road: "If this is true, go left. If not, go right."

<Frame caption="Condition configuration — build the check with dropdowns or write an expression.">
  <img src="https://mintcdn.com/glorium/eqWkhSfBUec9afZU/images/nodes/node-condition-form.png?fit=max&auto=format&n=eqWkhSfBUec9afZU&q=85&s=1d2bf1ee9e14cc72bf22c3a1477a7a1a" alt="Condition node configuration form" width="1440" height="1200" data-path="images/nodes/node-condition-form.png" />
</Frame>

## When to Use

* **Checking data** - Make sure something looks right before continuing
* **Making decisions** - Do different things based on what happened
* **Handling errors** - Check if something worked, handle it if not
* **Filtering** - Only process things that match certain criteria

## Three Ways to Set Up Conditions

### Manual Mode (Easiest - No Code)

Just pick from dropdown menus:

1. Choose what to check (like the email subject)
2. Choose how to check it (contains, equals, greater than, etc.)
3. Enter what you're looking for

**Example: Check if an email subject contains "urgent"**

```
Check: {{event_from_app_1.email.subject}}
How: contains
Value: urgent
```

**What you can check for:**

| Check        | What It Means             |
| ------------ | ------------------------- |
| equals       | Exactly matches           |
| not equals   | Doesn't match             |
| contains     | Includes this text        |
| not contains | Doesn't include this text |
| starts with  | Begins with this          |
| ends with    | Ends with this            |
| greater than | Number is bigger          |
| less than    | Number is smaller         |
| is empty     | Nothing there             |
| is not empty | Something there           |

### Expression Mode (More Flexible)

Type a formula. Useful when you need to check multiple things:

```
{{llm_1.score}} > 80
```

```
{{webhook_1.body.amount}} > 1000 AND {{webhook_1.body.customer.tier}} == "enterprise"
```

**You can use:**

* Comparisons: `==` (equals), `!=` (not equals), `>`, `<`, `>=`, `<=`
* Logic: `AND`, `OR`, `NOT`
* Parentheses: `( )` to group things

### AI Mode (Let AI Decide)

Just describe what you're looking for in plain English:

```
The email seems like a complaint or sounds frustrated with our service.
```

The AI reads the data and decides if your description matches.

<Note>
  AI mode takes 1-3 seconds to think. Use manual or expression mode when you can for faster results.
</Note>

## Example: Lead Qualification

Route leads based on score:

<Steps>
  <Step title="Score the lead">
    Use an Ask AI node to analyze lead data and return a score 0-100.
  </Step>

  <Step title="Add the condition">
    Add a Condition node:

    * Mode: **expression**
    * Expression: `{{llm_1.response.score}} >= 70`
  </Step>

  <Step title="Connect both paths">
    * **Met** → External API (add to "Hot Leads" in CRM)
    * **Unmet** → External API (add to "Nurture" campaign)
  </Step>
</Steps>

**Workflow:**

```
├── Webhook (new lead)
├── Ask AI (score lead 0-100)
├── Condition (score >= 70?)
│   ├── Met: External API (CRM: Hot Leads)
│   └── Unmet: External API (Nurture campaign)
```

## Example: Error Handling

Check if an API call succeeded:

```
├── HTTP Request (call external API)
├── Condition (statusCode == 200?)
│   ├── Met: Continue with data processing
│   │   └── Ask AI (analyze response)
│   └── Unmet: Error handling
│       ├── Update Variable (log error)
│       └── External API (Slack: alert team)
```

**Configuration:**

* Mode: **expression**
* Expression: `{{http_request_1.statusCode}} == 200 AND {{http_request_1.success}} == true`

## Example: Content Filtering

Only process emails that meet criteria:

```
├── Event from App (Gmail)
├── Condition (should process?)
│   ├── Met: Continue workflow
│   └── Unmet: (no connection - ends here)
```

**Manual mode configuration:**

* Group 1 (AND):
  * `{{event_from_app_1.email.from}}` NOT contains `noreply`
  * `{{event_from_app_1.email.subject}}` NOT starts with `Re:`
  * `{{event_from_app_1.email.subject}}` NOT starts with `Fwd:`

## Combining Conditions

### AND Logic (all must be true)

Manual mode: Add rules to the same group

Expression mode:

```
{{a}} > 10 AND {{b}} == "active" AND {{c}} != null
```

### OR Logic (any can be true)

Manual mode: Create multiple groups

Expression mode:

```
{{status}} == "urgent" OR {{priority}} > 5 OR {{escalated}} == true
```

### Complex Logic

Use parentheses in expression mode:

```
({{score}} > 80 OR {{tier}} == "enterprise") AND {{status}} != "blocked"
```

## Nested Conditions

Chain conditions for complex decision trees:

```
├── Condition (is customer?)
│   ├── Met:
│   │   └── Condition (is enterprise?)
│   │       ├── Met: Enterprise flow
│   │       └── Unmet: Standard customer flow
│   └── Unmet:
│       └── Condition (is qualified lead?)
│           ├── Met: Lead nurture flow
│           └── Unmet: Cold prospect flow
```

<Tip>
  For more than 3-4 branches, consider using a Multi-Condition node instead of nested Conditions. It's cleaner and easier to maintain.
</Tip>

## Tips

<Tip>
  Use descriptive condition names like "Is High Priority?" or "Has Valid Email" instead of "Condition 1".
</Tip>

<Tip>
  The unmet branch doesn't need to connect to anything. If a condition is unmet and there's no unmet path, that execution branch simply ends.
</Tip>

<Warning>
  Be careful with type comparisons. `"100"` (string) is not equal to `100` (number). Use Execute Code to convert types if needed.
</Warning>

## Settings

<ParamField path="name" type="string" default="Condition">
  What to call this node (shown on the canvas).
</ParamField>

<ParamField path="key" type="string" default="condition_1">
  A short code to reference this node's result.
</ParamField>

<ParamField path="mode" type="string" default="manual">
  How to set up your condition:

  * **manual** - Choose from dropdowns (easiest, no code needed)
  * **expression** - Type a formula like `{{score}} > 80`
  * **ai** - Describe it in plain English and let AI figure it out
</ParamField>

<ParamField path="conditionRules" type="object">
  For manual mode: the rules you've set up.
</ParamField>

<ParamField path="conditionExpression" type="string">
  For expression mode: your formula.
</ParamField>

<ParamField path="condition" type="string">
  For AI mode: your plain English description.
</ParamField>

## Outputs

The Condition node has two outputs:

<ParamField path="met" type="handle">
  **Green (Yes)** - Goes here when the condition is true.
</ParamField>

<ParamField path="unmet" type="handle">
  **Red (No)** - Goes here when the condition is false.
</ParamField>

<ParamField path="result" type="boolean">
  True or false - you can use this value in later nodes.
</ParamField>

## Related Nodes

<CardGroup cols={2}>
  <Card title="Multi-Condition" icon="arrows-split-up-and-left" href="/nodes/logic/multi-condition">
    For multi-way branching with more than two paths.
  </Card>

  <Card title="Wait and Combine" icon="code-merge" href="/nodes/logic/wait-and-combine">
    Rejoin branches after conditional splits.
  </Card>
</CardGroup>
