How to Use the 'If → Then' Component in wolkvox Studio
Table of Contents
Introduction
The **"If → Then"** component allows you to create logical conditions within a flow to branch the customer's path based on the fulfillment of one or more rules. It is ideal for validating information stored in variables, directing conversations down different paths, and creating automations based on decisions.
It is located in the **"Basics"** group and is available in all types of **wolkvox Studio** routing: **Voice**, **Interaction**, **Chat**, **CRM + Webhook**, and **Agent Scripting**.
Configuration
When you select the component, the configuration panel will open. Here, you will find the **"Logical Expression"** section, which functions as a board where the generated code is displayed as you add expressions.
Important: This board is not edited manually but through the form fields and buttons.
An expression is built using three main fields:
-
Variable: Enter the variable you want to evaluate.
- For variables, always prefix with the $ sign.
- Example: $customer_type
- Comparison Operator: Choose from "<=, <, ==, ===, >, >=, <>, !=, !==".
-
Value or Variable to Compare:
- If it is text, it must be enclosed in single quotes. Example: 'premium'
- You can also compare with another variable. Example: $order_status
- Once the three fields are completed, click **"Add Expression"** to add it to the board and the expressions table.

The **"and"** and **"or"** operators allow you to combine multiple conditions (you cannot add "and" or "or" without first having an expression created):
- and: All conditions must be met.
- or: If any condition is met, the expression will be true.
The **"("** and **")"** buttons allow you to define groups of expressions for more complex evaluations:
- Examples:
- ($status=='active' and $balance>0)
- ($type=='premium' or $type=='gold')

Each expression or operator is listed in this table, where you can see in order:
- EXP: The added expression
- LOGIC: Connectors such as and / or
Editing via right-click: You can edit any element.
- For expressions (EXP): Right-click → IF → Expression. A window opens to modify the fields and update the expression.
- For logical operators (LOGIC): Right-click → IF → Logic → switch between "and" and "or".
The **"Delete"** button removes the last added element.
When you finish adding all expressions, click **"Save IF"**.

Once the **"IF"** is saved, connect the component to the next steps in the flow.
When connecting an arrow from the **"If → Then"** component to another component, a window will appear with the field **"Select the menu number"**, where you must choose:
- THEN: The path the flow follows if the expression is true.
- ELSE: The path the flow follows if the expression is false.
