# Condition Funnel

The **Condition Funnel** block lets you route a conversation into different paths based on variable values, user input, or message content.\
It is commonly used to validate inputs (such as email or phone number), check user attributes, or control logic using numeric or text-based conditions.

***

### 1. Condition Funnel Overview

<figure><img src="https://605198658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP7nf2G1iCRba8EP7DawZ%2Fuploads%2FSXef8uKmfonF7Hs1smq6%2Fimage.png?alt=media&#x26;token=9e314df2-82b4-4adc-8621-b347a3ab822b" alt="" width="316"><figcaption></figcaption></figure>

#### Main components

1. **Select a variable**\
   Choose the variable you want to evaluate (for example: user input, custom field, or system variable).
2. **Condition operator**\
   Defines how the selected variable will be compared to the value or rule you provide.
3. **Enter value / rule**\
   The comparison value.
   * For basic operators, this is a text or number.
   * For regex, this is a regex pattern.
4. **Add condition (+)**\
   Add multiple conditions. Each condition creates its own branch.
5. **Otherwise path**\
   If none of the conditions are met, the conversation will follow the **Otherwise** path.

***

### 2. Condition Operators Explained

<figure><img src="https://605198658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP7nf2G1iCRba8EP7DawZ%2Fuploads%2FllCBSfbHXXIzDNXdqwU2%2FCleanShot_2026-01-23_at_17.23.202x.webp?alt=media&#x26;token=cc701582-1a0c-4d21-8f88-3e6ee8f78241" alt="" width="292"><figcaption></figcaption></figure>

#### Equality & comparison operators

| Operator                  | Meaning                            | Example           |
| ------------------------- | ---------------------------------- | ----------------- |
| **Equal**                 | Variable value is exactly the same | `country = USA`   |
| **Not Equal**             | Variable value is different        | `country ≠ SG`    |
| **Less Than**             | Numeric comparison                 | `order_count < 3` |
| **Less Than or Equal**    | Numeric comparison                 | `score ≤ 60`      |
| **Greater Than**          | Numeric comparison                 | `order_count > 5` |
| **Greater Than or Equal** | Numeric comparison                 | `amount ≥ 1000`   |

> 💡 Numeric operators should only be used with number-based variables.

***

#### List & Text Matching Operators

| Operator     | Meaning                              | Example                     |
| ------------ | ------------------------------------ | --------------------------- |
| **In**       | Variable matches any value in a list | `country in [USA, SG]`      |
| **Contains** | Variable includes the given text     | Message contains `"refund"` |
| **Is Empty** | Variable has no value                | Phone number is empty       |

***

### 3. Matches Regular Expression (Regex)&#x20;

The **Matches Regex** operator allows advanced pattern matching using regular expressions.\
It is useful for validating formats such as email addresses, phone numbers, or structured user input.

<figure><img src="https://605198658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP7nf2G1iCRba8EP7DawZ%2Fuploads%2F9bqYZvHB8BKMYOgrqUNw%2FCleanShot%202026-01-23%20at%2017.48.31%402x.png?alt=media&#x26;token=f9ec0fab-ed87-4611-a0fa-fae775bdd0fd" alt="" width="375"><figcaption></figcaption></figure>

#### How it works

* Enter a regex pattern between `/ /`
* Optionally enable regex flags for additional control
* The condition passes if the variable matches the regex pattern

#### Common examples

| Use case                                | Regex example                | Example                |
| --------------------------------------- | ---------------------------- | ---------------------- |
| Validate email format                   | `^[^\s@]+@[^\s@]+\.[^\s@]+$` | `example@chatalog.com` |
| Validate phone number with country code | `^\+[1-9]\d{6,14}$`          | `+14155552671`         |
| Only numeric input                      | `^\d+$`                      | `123456`               |

***

### 4. Advanced Regex Flags Explained (Optional)

Regex flags control how the pattern is evaluated.

<figure><img src="https://605198658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FP7nf2G1iCRba8EP7DawZ%2Fuploads%2FvMk3PeBpADCag4Jo93y0%2Fimage.png?alt=media&#x26;token=87ae5735-5ef3-452e-912e-f651340581f2" alt="" width="375"><figcaption></figcaption></figure>

| Flag  | Name             | Description                       |
| ----- | ---------------- | --------------------------------- |
| **g** | Global           | Matches all occurrences           |
| **m** | Multi Line       | `^` and `$` apply to each line    |
| **i** | Case Insensitive | Ignores letter casing             |
| **x** | Extended         | Allows whitespace and comments    |
| **s** | Single Line      | `.` matches newline characters    |
| **u** | Unicode          | Enables Unicode matching          |
| **U** | Ungreedy         | Makes quantifiers lazy by default |
| **A** | Anchored         | Forces matching from the start    |
| **J** | Jchanged         | Allows duplicate named groups     |

***

### 5. Example Scenarios

#### Example 1: Email validation

* **Variable:** `User Input`
* **Operator:** **Matches Regex**
* **Pattern:** `^[^\s@]+@[^\s@]+\.[^\s@]+$`

**Result**

* Matches → Continue to the next step
* Does not match → Ask the user to re-enter a valid email address

***

#### Example 2: Route by country

* **Variable:** `Country`
* **Operator:** **In**
* **Value:** `USA, SG`

**Result**

* Matches (USA or SG) → Route to the regional flow
* Otherwise → Route to the global/default flow

***

#### Example 3: Empty phone number check

* **Variable:** `Phone Number`
* **Operator:** **Is Empty**

**Result**

* Empty → Ask the user to provide their phone number
* Not empty → Continue the flow

***

### 6. Best Practices & Tips

* Start with **simple operators** (Equal, In, Contains) before using regex.
* Always configure an **Otherwise** path to prevent dead ends.
* When using regex:
  * Anchor patterns with `^` and `$` to avoid partial matches
  * Test patterns with real user input
* Keep condition logic readable—multiple simple conditions are often clearer than one complex rule.
