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

# Conditions

<div style={{ display: 'flex', justifyContent: 'center', margin: '2rem 0' }}>
  <div className="video-card">
    <video src="https://lindy-docs-content.nyc3.digitaloceanspaces.com/Conditions.mp4" width="600" autoPlay muted loop playsInline style={{ display: 'block', width: '100%', borderRadius: '16px' }} />
  </div>
</div>

## Quick Overview

Conditions let your agent make smart decisions about which path to take in a workflow. Instead of rigid rules like "if field equals X", you write natural language prompts like "if the customer seems angry" or "if this email needs a response".

Your AI agent evaluates these conditions by understanding context, sentiment, and meaning, not just exact matches. This lets you handle more nuanced scenarios without hard-coding every rule.

Use conditions to route different types of requests, filter content intelligently, or handle multiple scenarios within a single workflow. Your agent chooses the best path based on what it actually understands from the data.

## Creating Your First Condition

To add a condition to your workflow, click the plus button (Add step) below any action or between two actions, then select "Condition".

<Frame>
  <img src="https://mintcdn.com/lindyai/XRHjWZiSf5VPQvY1/lindy-brand-assets/hit_plus_add_condition_first_thing_to_do.png?fit=max&auto=format&n=XRHjWZiSf5VPQvY1&q=85&s=74df4ec20357671fe9a7e0cd8dd6f996" alt="Adding a condition step" width="2922" height="1236" data-path="lindy-brand-assets/hit_plus_add_condition_first_thing_to_do.png" />
</Frame>

### Setting Up the Condition

Once you've added a condition, you'll see the condition configuration panel.

<Frame>
  <img src="https://mintcdn.com/lindyai/VHBHJwXMXFd-cbnu/lindy-brand-assets/conditions_initial.png?fit=max&auto=format&n=VHBHJwXMXFd-cbnu&q=85&s=7f6ab5fe8580e31db9a7c4ff0dc19f44" alt="Initial condition setup" width="2524" height="1228" data-path="lindy-brand-assets/conditions_initial.png" />
</Frame>

Every condition prompt starts with **"Go down this path if..."** followed by your criteria. For example:

* `the email received was asking a question and needs a response`
* `the email contains a 6 digit user ID number`
* `the user asked for a refund or seems angry`

<Tip>
  For best results, include examples in each condition prompt.
</Tip>

### Adding Multiple Condition Paths

You can create multiple branches to handle different scenarios. Click "+ Add Condition" to create alternate paths.

<Frame>
  <img src="https://mintcdn.com/lindyai/VHBHJwXMXFd-cbnu/lindy-brand-assets/condition_2_add_alternate_path.png?fit=max&auto=format&n=VHBHJwXMXFd-cbnu&q=85&s=fa6d9c1212ea8d8e26e9ec7c3c62eea9" alt="Adding alternate condition paths" width="2520" height="1322" data-path="lindy-brand-assets/condition_2_add_alternate_path.png" />
</Frame>

<Note>
  Each condition branch should have a clear, distinct criteria. Your agent will evaluate all conditions and follow the path the model deems "most true".
</Note>

## Advanced Configuration

### Force Agent to Select a Branch

By default, if no conditions are met, your agent will stop the task. You can change this behavior by enabling "Force the agent to select a branch".

<Frame>
  <img src="https://mintcdn.com/lindyai/vTETa6Bb9Fi7xfg7/lindy-brand-assets/force_agent_to_select_branch.png?fit=max&auto=format&n=vTETa6Bb9Fi7xfg7&q=85&s=f547d41e5a73591f43da9f07a8eff066" alt="Force agent to select branch option" width="3020" height="1342" data-path="lindy-brand-assets/force_agent_to_select_branch.png" />
</Frame>

When enabled, your agent must choose one of the defined paths even if none of the conditions perfectly match. This is useful when you want to ensure the workflow always continues.

### Renaming Conditions

For better organization, especially in complex workflows, rename your conditions with descriptive titles.

<Frame>
  <img src="https://mintcdn.com/lindyai/QWdJNkViLsD1veyH/lindy-brand-assets/rename_condition.png?fit=max&auto=format&n=QWdJNkViLsD1veyH&q=85&s=15b4a4186b349f594c7d49bf4a6e7294" alt="Renaming a condition" width="2190" height="1318" data-path="lindy-brand-assets/rename_condition.png" />
</Frame>

Click on the condition title (e.g., "Condition 1") and replace it with a meaningful name like "Found a response" or "Customer is angry".

## Best Practices

<AccordionGroup>
  <Accordion title="Write Clear, Specific Prompts">
    Be explicit about what you're looking for. Instead of "important email", use "email from a C-level executive or marked as high priority".
  </Accordion>

  <Accordion title="Test Edge Cases">
    Consider what happens when conditions overlap or when none match. Use the test panel to verify behavior.
  </Accordion>

  <Accordion title="Add Examples">
    Include examples in your condition prompts to improve accuracy: "the email asks about pricing (e.g., 'how much does it cost', 'what are your rates')".
  </Accordion>
</AccordionGroup>

<Tip>
  For conditions that require understanding context, sentiment, or complex logic, use more advanced models. For simple keyword matching or basic categorization, faster models work well.
</Tip>

## Troubleshooting

#### Common Issues

1. **Workflow stops when no conditions match**
   * Enable "Force agent to select branch" or add a catch-all condition

2. **Wrong path is chosen**
   * Review and refine your condition prompts
   * Add more specific examples

3. **Conditions overlap**
   * Make each condition mutually exclusive
   * Order from most specific to least specific

<Warning>
  If your workflow stops unexpectedly, check that each condition branch has at least one action following it. Empty branches will cause the execution to end.
</Warning>

## Next Steps

Now that you understand conditions, explore these related concepts:

<CardGroup cols={2}>
  <Card title="Loops" href="/fundamentals/lindy-101/looping" icon="arrows-repeat">
    Repeat actions for multiple items using conditions as filters
  </Card>

  <Card title="Knowledge Base" href="/fundamentals/lindy-101/knowledge-base" icon="database">
    Combine conditions with knowledge search for intelligent routing
  </Card>

  <Card title="Human in the Loop" href="/testing/human-in-the-loop" icon="user-check">
    Use conditions to determine when human review is needed
  </Card>

  <Card title="Testing Workflows" href="/testing/test-panel" icon="vial">
    Test your conditions with different scenarios
  </Card>
</CardGroup>
