# Condition

For chatbot flows requiring a logical condition to be evaluated to branch out to the next step in the flow, you can use the condition action block.

With the help of Branch action block, you have the ability to create multiple branches based on certain conditions, which have their own conversational flows.

{% hint style="success" %}
The default Sopro flow is using conditions to supports different message chat flows for identified prospects vs identified companies vs unidentified visitors.
{% endhint %}

#### Use case scenario: <a href="#use-case-scenario" id="use-case-scenario"></a>

Following are few of the scenarios in which the branch action block can be used:

* Let's say you want to separate the flows for identified prospects vs identified companies vs unidentified visitors
* When you want to branch out the flow based on a the time the chat is received.

You can create a set of conditions for each branch in the chatbot flow.

Each condition is made up of:

* **Variable** - which contains the value to be compared.
* **Operator** - specifies the operation to be carried out.
* **Value** - the value against which the variable's value is to be compared.

All conditions will be evaluated with **ANY** if you want any one condition to be satisfied, and ALL if you want all conditions to be satisfied.

### Operators supported

There are various types of operators that Sopro Webchat supports, they are:

| Operator         | Description                                                                                      | Example                               |
| ---------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------- |
| Equals To        | Commonly used when you want to match the value of the variable with the defined value            | "City" '**Equals To**' "New York"     |
| Not Equals To    | Commonly used when you don't want the value of the variable to be matched with the defined value | "City" '**Not Equals To**' "New York" |
| Contains         | Commonly used when you want the variable to contain the defined value                            | "URL" '**Contains**' "Web"            |
| Does Not Contain | Commonly used when you do not want the variable to contain the defined value                     | "URL" '**Does Not Contain**' "Web"    |
| Is Empty         | You can use this operator to identify whether the variable is empty or not                       | "Phone" is '**Empty**'                |
| Is Not Empty     | You can use this operator to ensure that variable is not empty                                   | "Name" is '**Not Empty**'             |

#### How do I set it up? <a href="#how-do-i-set-it-up" id="how-do-i-set-it-up"></a>

You can follow the following steps to set up the branch action block;

1. Add action block on canvas by clicking on '**+**'
2. Choose '**Condition**'
3. Configure it on the right panel
   * **Add a Branch:** You can add multiple branches by clicking on '**+ Branch**'. The maximum number of branches that you can add is 10
   * **Define the condition:** Click on the branch to open the configuration window. You can configure following once the panel opens up;
     1. **Variable:** Click on 'Variable' to open the drop down list of the defined variables and select the variable as per your preference
     2. **Operator:** Click on 'Operator' to open the drop down list of supported operators and select it as per your preference
     3. **Value:** Define the value with which the variable value will be compared with. Here you can enter multiple values by hitting enter and they will be displayed as chip
   * Choose '**Any/All**' condition: You can select either of the condition from Any or All **Any:** System will route the visitors through this branch if any of the condition is met or holds true **All:** System will route the visitors through this branch if all the conditions are met or holds true


---

# 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://help.webchat.portal.sopro.io/action-blocks/condition.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.
