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. ---- .. _chatbot-ref-set-variable: 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** .. list-table:: :widths: 30 70 :header-rows: 1 * - 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** .. list-table:: :widths: 25 75 :header-rows: 1 * - 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. ---- .. _chatbot-ref-condition: 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: .. list-table:: :widths: 30 70 :header-rows: 1 * - 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. ---- .. _chatbot-ref-redirect: 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** .. list-table:: :widths: 30 70 :header-rows: 1 * - 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. ---- .. _chatbot-ref-script: Script ------ Executes a custom JavaScript snippet at this point in the flow. Use it for calculations, DOM manipulation, or calling browser APIs. **Configuration** .. list-table:: :widths: 30 70 :header-rows: 1 * - 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). ---- .. _chatbot-ref-wait: Wait ---- Pauses the flow for a configurable number of seconds before continuing. Useful for adding delays between messages. **Configuration** .. list-table:: :widths: 30 70 :header-rows: 1 * - 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. ---- .. _chatbot-ref-jump: Jump ---- Jumps execution to a specific group or block elsewhere in the flow, bypassing the normal sequential path. **Configuration** .. list-table:: :widths: 30 70 :header-rows: 1 * - Field - Description * - Target group - The group to jump to. * - Target block - Optional specific block within the target group. ---- .. _chatbot-ref-ab-test: AB Test ------- Splits traffic between two paths (A and B) at a configurable percentage. Use it to test different conversation flows or messages. **Configuration** .. list-table:: :widths: 30 70 :header-rows: 1 * - 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.