# Logic

Logic blocks control the flow — branching, variable assignment, redirects, custom scripts, delays, jumps, and A/B testing. They do not display content to the user directly.

---

## Set Variable

Creates or updates a flow variable with a computed or static value. Supports many assignment types — dates, random IDs, expressions, list operations, and more.

**How to use**

Drag **Set Variable** onto the canvas, select the target variable, and choose the assignment type.

**Configuration**

| Field | Description |
| --- | --- |
| Variable | The variable to create or update. |
| Type | How the value is computed. See assignment types below. |
| Expression / Value | The value or expression to assign (fields vary by type). |

**Assignment types**

| Type | Description |
| --- | --- |
| Custom | Assign a static value or `{{expression}}`. |
| Empty | Clear the variable. |
| Today | Current date. |
| Now | Current date and time. |
| Yesterday / Tomorrow | Date relative to today. |
| Random ID | Short random identifier. |
| Random UUID | Full UUID v4. |
| Transcript | Full conversation transcript up to this point. |
| Chat History | Conversation history as structured data. |
| User ID / Session ID / Result ID | Platform-assigned identifiers. |
| Pop / Shift | Remove and assign the last or first item from a list variable. |
| Append value(s) | Add value(s) to a list variable. |
| Map item with same index | Look up a value from one list at the index matching an item in another list. |

---

## Condition

Branches the flow based on one or more logical comparisons. Routes to different paths depending on whether the combined condition is true or false.

**How to use**

Drag **Condition** onto the canvas. Configure one or more comparison rows and connect the **If true** and **If false** paths to different blocks.

**Configuration**

Each condition row has:

| Field | Description |
| --- | --- |
| Variable | The variable to evaluate. |
| Operator | Comparison operator: Equal to, Not equal to, Contains, Does not contain, Starts with, Ends with, Is set, Is empty, Is greater than, Is less than, Matches regex, etc. |
| Value | The value to compare against. |

Multiple rows are combined with a logical operator (AND / OR) at the group level.

---

## Redirect

Sends the user’s browser to an external URL. This is typically the last block in a group since it navigates away from the chatbot.

**Configuration**

| Field | Description |
| --- | --- |
| URL | The URL to redirect the user to. Supports `{{variable}}` interpolation. |
| Open in new tab | When enabled, opens the URL in a new browser tab instead of the current one. |

---

## Script

Executes a custom JavaScript snippet at this point in the flow. Use it for calculations, DOM manipulation, or calling browser APIs.

**Configuration**

| Field | Description |
| --- | --- |
| Name | Optional label for the script block. |
| Code | JavaScript to execute. Variables are accessible via `{{variable}}` syntax or the `variables` object. |
| Run on client | When enabled, the script runs in the user’s browser. When disabled, it runs server-side. |
| Execute in parent context | When enabled, the script runs in the parent window context (useful inside iframes). |

---

## Wait

Pauses the flow for a configurable number of seconds before continuing. Useful for adding delays between messages.

**Configuration**

| Field | Description |
| --- | --- |
| Seconds | How many seconds to wait before advancing. |
| Should pause | When enabled, the wait is a hard pause; when disabled, it’s a display delay only. |

---

## Jump

Jumps execution to a specific group or block elsewhere in the flow, bypassing the normal sequential path.

**Configuration**

| Field | Description |
| --- | --- |
| Target group | The group to jump to. |
| Target block | Optional specific block within the target group. |

---

## AB Test

Splits traffic between two paths (A and B) at a configurable percentage. Use it to test different conversation flows or messages.

**Configuration**

| Field | Description |
| --- | --- |
| A percent | Percentage of conversations routed to path A (0–100). The remainder go to path B. |

Connect the **A** and **B** outputs to different downstream groups or blocks.
