# Condition Action

The **Condition** Action is very useful for designing dynamic workflows. Whenever you need to divide a conversation into two or more branches, this Action comes in handy — for example, sending sales inquiries directly to the sales team.

<figure><img src="/files/7Kw4syxRICnnee3MplaR" alt=""><figcaption></figcaption></figure>

There are two Condition Actions under **Flow actions** in the left toolbar. In this tutorial we’ll focus on **Condition w/ else**. This Action lets you define a condition:

* if the condition is true, the **green endpoint** is triggered,
* if the condition is false, the **red endpoint** is triggered.

<figure><img src="/files/dxx9F2xN1hafUJGvVWgm" alt=""><figcaption></figcaption></figure>

### How to use it

1. Find **Condition w/ else** under *Flow actions* in the left toolbar.
2. Drag and drop it onto the canvas where you need it.
3. Click on it: a panel opens on the right where you can choose the Attribute you want to evaluate.

<figure><img src="/files/vOX5eL2YOAbysW6i7Qdi" alt=""><figcaption></figcaption></figure>

### To create a condition:

1. Click **Add a new condition**.
2. A pop-up will appear.
3. Select the [Attribute](/ai-chatbots-and-automation/visual-builder-101/flows-attributes.md) (for example, *userEmail*).
4. Define the condition by choosing one of the available options.
5. Enter a value if required (for some conditions, no value is needed).
6. Click **Apply condition**.

That’s it — you’ve set a new condition.

<figure><img src="/files/ntTJQtOZoqqSGys7g2hO" alt=""><figcaption></figcaption></figure>

### Available condition options

Here’s what each option means in simple words:

* **= equal As Numbers / = equal As Text** → check if two values are exactly the same (as numbers or text).
* **≠ not Equal As Numbers / ≠ not Equal As Text** → check if two values are different.
* **> greater Than / ≥ greater Than Or Equal** → check if a number is larger (or larger/equal).
* **< less Than / ≤ less Than Or Equal** → check if a number is smaller (or smaller/equal).
* **starts With / not starts With** → check if a text begins with (or does not begin with) a specific value.
* **starts With Ignore Case** → same as above but ignoring uppercase/lowercase differences.
* **ends With** → check if a text ends with a specific value.
* **contains / contains Ignore Case** → check if a text contains a specific value (ignoring case if selected).
* **is Empty** → true if the attribute has no value.
* **is Null** → true if the attribute is null.
* **is Undefined** → true if the attribute is not defined at all.
* **matches** → check if the value matches a specific pattern (for advanced use cases).

<figure><img src="/files/Q6Yfhr6oJtmarUi8fVYm" alt=""><figcaption></figcaption></figure>

### Examples

**1. Ask for email before closing a chat**\
Check if *userEmail* is **Undefined**. If true, the green endpoint will trigger and you can ask for the email before ending the conversation.

<figure><img src="/files/u73R6IYZ7heTW4Vz06ml" alt=""><figcaption></figcaption></figure>

**2. Ask a series of questions before moving on**\
Use a [Chatgpt task](/ai-chatbots-and-automation/actions-explained/chatgpt-task.md) to collect details step by step (for example: name, needs, phone number).\
In the prompt, you can write:

```
Your role is to ask one by one the questions below:  
- name  
- needs  
- phone number  
Once you receive all the responses, answer strictly with the word "eject".
```

When the user has answered everything, the **gpt\_reply** will contain ***eject***.\
Set a condition: if **gpt\_reply contains "eject"**, continue the Flow.&#x20;

Otherwise, connect the Else branch to a [Reply Action](/ai-chatbots-and-automation/actions-explained/reply-action.md) so the user keeps receiving questions until the condition is met. Keep in mind you also need a [Capture User Reply](/ai-chatbots-and-automation/actions-explained/capture-user-reply-action.md) action to receive the user's response, and you need to connect it to the ChatGPT task again.&#x20;

Then ChatGPT will ask the next question until it responds with "eject".

<figure><img src="/files/xGVQZecV1anUjhX16pap" alt=""><figcaption></figcaption></figure>

**3. Immediate handover to human support**\
Use a Chatgpt task to run sentiment analysis on the conversation transcript.\
In the prompt, you can write:

```
Check if there are signs of frustration or negative sentiment in the lastUserText.
If yes, answer strictly with the word "human".
```

When the AI Agent detects frustration, the **gpt\_reply** will contain *human*.\
Set a condition: if **gpt\_reply equals "human"**, trigger the [**Transfer to human**](/ai-chatbots-and-automation/actions-explained/transfer-to-a-human.md) Action.

<figure><img src="/files/jiZPQOnZK5H9SDTyZtd8" alt=""><figcaption></figcaption></figure>

These are just a few examples of how the Condition Action can be used. There are many more possibilities to design smart, flexible workflows.

If you have any questions about the Condition Action or other Tiledesk features, contact us at [**support@tiledesk.com**](mailto:support@tiledesk.com).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.tiledesk.com/ai-chatbots-and-automation/actions-explained/condition-action.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
