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

# Conditional Logic & Routing

> Create dynamic workflows with intelligent branching based on user responses

Create workflows that adapt to user responses by using conditions on connections between entities. Instead of showing the same questions to everyone, your flows can branch and show relevant content based on what users have entered.

<Note>
  **Smart Connections**
  Connections between entities can include conditions that control when users follow specific paths, creating personalized experiences within a single workflow.
</Note>

## How It Works

### Connections (Edges)

Connections represent the pathways between components in your flow. They link entities and determine the sequence in which components appear to users during a conversation.

<CardGroup cols={2}>
  <Card title="Linear Flow" icon="arrow-right">
    **Simple Sequence**
    Connect entities in order for straightforward, step-by-step workflows
  </Card>

  <Card title="Branching Flow" icon="code-branch">
    **Multiple Paths**
    A single entity can connect to multiple destinations with different conditions
  </Card>
</CardGroup>

### Adding Conditions

Each connection can include a condition. When a condition is applied to a connection, that pathway will only be followed if the condition evaluates as true, enabling personalized conversation experiences based on user responses.

**Example:**

* Age question connects to two different paths
* If Age \< 25 → Show student insurance options
* If Age ≥ 25 → Show standard insurance options

***

## Available Conditions

Based on the Wizflow platform, these condition types are available:

<Tabs>
  <Tab title="Value Checks">
    <CardGroup cols={2}>
      <Card title="eq (equals)" icon="equals">
        Check if a response equals a specific value
      </Card>

      <Card title="cmp (compare)" icon="less-than-equal">
        Compare values (greater than, less than, etc.)
      </Card>

      <Card title="range" icon="arrows-left-right">
        Check if a value falls within a specified range
      </Card>

      <Card title="has" icon="check">
        Verify if an entity has a specific value or property
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Data Existence">
    <CardGroup cols={2}>
      <Card title="resource" icon="database">
        Check if a data resource or entity exists
      </Card>

      <Card title="userExists" icon="user-check">
        Validate if a user record exists in the system
      </Card>

      <Card title="houseExists" icon="home">
        Check if house/property data exists (Danish context)
      </Card>

      <Card title="pensionExists" icon="piggy-bank">
        Validate if pension data exists for the user
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Multiple Choice">
    <CardGroup cols={2}>
      <Card title="mcqHas" icon="list-check">
        Check if multiple choice question has specific selection
      </Card>

      <Card title="count" icon="hash">
        Count items/records and validate against thresholds
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Boolean Logic">
    <CardGroup cols={2}>
      <Card title="boolean" icon="toggle-on">
        Direct boolean value check (true/false)
      </Card>

      <Card title="truthy" icon="check-circle">
        Check if value evaluates to true (non-empty, non-zero)
      </Card>

      <Card title="falsy" icon="x-circle">
        Check if value evaluates to false (empty, zero, null)
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="System State">
    <CardGroup cols={2}>
      <Card title="isUserAuthenticated" icon="lock">
        Check if user is logged in/authenticated
      </Card>

      <Card title="minWidth" icon="monitor">
        Check if screen meets minimum width (responsive design)
      </Card>

      <Card title="isInAppBrowser" icon="mobile">
        Detect if user is in mobile app browser vs regular browser
      </Card>

      <Card title="isFeatureFlagProtected" icon="flag">
        Check if feature is behind a feature flag
      </Card>
    </CardGroup>
  </Tab>
</Tabs>

***

## Simple Examples

### Basic Age Routing

```
Age Question: "How old are you?"
├─ If age < 18 → "You must be 18 or older"
├─ If age >= 18 AND age <= 65 → Standard Application
└─ If age > 65 → Senior Application with Additional Questions
```

### Choice-Based Routing

```
Insurance Type Question: "What type of insurance do you need?"
├─ If choice = "Life Insurance" → Life Insurance Questions
├─ If choice = "Home Insurance" → Property Details
└─ If choice = "Auto Insurance" → Vehicle Information
```

### Danish Services Integration

```
User Authentication Check
├─ If isUserAuthenticated = true → Skip basic info, load from systems
└─ If isUserAuthenticated = false → Collect basic information manually

Property Information
├─ If houseExists = true → Load property details automatically  
└─ If houseExists = false → Manual property entry form
```

***

## Building Conditional Flows

<Steps>
  <Step title="Plan Your Branches">
    Identify where your workflow needs to split based on different user responses or data
  </Step>

  <Step title="Connect Entities">
    Create connections between entities in the visual flow builder
  </Step>

  <Step title="Add Conditions">
    Click on connections to add conditions that determine when users follow each path
  </Step>

  <Step title="Test Your Logic">
    Use the preview feature to test different user paths through your workflow
  </Step>
</Steps>

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Keep It Simple" icon="minimize">
    Start with basic conditions before building complex branching logic
  </Card>

  <Card title="Test All Paths" icon="route">
    Make sure every possible user journey has a valid path through your flow
  </Card>

  <Card title="Provide Fallbacks" icon="shield">
    Always include default paths for unexpected conditions or missing data
  </Card>

  <Card title="Use Clear Logic" icon="eye">
    Make your conditions easy to understand and maintain for your team
  </Card>
</CardGroup>

***

## Common Use Cases

<AccordionGroup>
  <Accordion title="Skip Irrelevant Questions">
    Show only questions that apply to each user based on their previous answers
  </Accordion>

  <Accordion title="Different Application Processes">
    Route users through different approval or verification processes based on their profile
  </Accordion>

  <Accordion title="Personalized Information">
    Display relevant product information or advice based on user characteristics
  </Accordion>

  <Accordion title="Progressive Disclosure">
    Reveal more detailed questions only when needed based on initial responses
  </Accordion>
</AccordionGroup>

***

## Related Documentation

* [Entities Overview](/features/entities-overview) - Understanding the components you can connect
* [Flow Builder Basics](/features/flow-builder-basics) - Creating and connecting entities
