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

# Conditional

> Control workflow execution by defining conditions that determine whether steps should run or be skipped.

<img
  src="https://mintcdn.com/cortex-891fd898/4MLfFrvXy66YjKyF/assets/workflows/steps-advanced/conditional/conditional-overview.png?fit=max&auto=format&n=4MLfFrvXy66YjKyF&q=85&s=ca74f42a2b9dcfa6ddf77a9e3274ecf8"
  alt="Enabling conditional on a step"
  style={{
borderRadius: '10px',
}}
  width="1860"
  height="704"
  data-path="assets/workflows/steps-advanced/conditional/conditional-overview.png"
/>

## Enabling Conditional

To enable conditional for a step:

1. Click the step's options menu (⋮)
2. Click `Add Conditional`
3. Enter a condition that determines whether the step should run

## Conditional Expression

* A JavaScript expression that evaluates to a boolean value
* Must return `true` or `false`
* Cannot contain async operations

## Common Expressions

```javascript theme={"system"}
return input1.output.document_type === 'pdf';

return codeStep1.output.score > 0.8 && codeStep2.output.verified;

return codeStep1.output.results?.length > 0;
```

## Invalid Expressions

* Async operations
* Function declarations
* Complex logic blocks with if/else

## Step Skip Handling

When a step is skipped due to a conditional evaluating to `false`, subsequent steps need to handle this gracefully when accessing the output of the skipped step.
