> ## Documentation Index
> Fetch the complete documentation index at: https://help.wotnot.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Variables

> Variables are reusable objects containing a user-submitted value.

Variables are essential for capturing and utilizing the data dynamically in the conversation. With variables, you can personalize the chat experience by being able to say “Hey John!”, instead of “Hey there!”.

![Image](https://mintcdn.com/wotnot/rJU1ndzQnO6IbxAg/images/image-746.png?fit=max\&auto=format\&n=rJU1ndzQnO6IbxAg\&q=85\&s=ecff0f9f8c8f519b102e6a04061cffe6)

Canvas Look

![Image](https://mintcdn.com/wotnot/rJU1ndzQnO6IbxAg/images/image-745.png?fit=max\&auto=format\&n=rJU1ndzQnO6IbxAg\&q=85\&s=ba192e5d1d68fd7e57e688700d1a6100)

Real time Example

### Variable Type

There are 3 types of variable in WotNot and you can create it from 2 ways:

> [tab] Conversation Variable
>
> Used for storing temporary data that is only relevant within a single session.
>
> * Conversation variables are session-specific and do not persist
> * Values are reset after the conversation ends
> * Ideal for storing temporary inputs like selections, intermediate responses, or flow-specific data
> * Helps manage state within a single interaction without affecting future conversations

> [tab] Contact Variable
>
> Used for storing user-specific data that persists across conversations — making it ideal for personalization and long-term context.
>
> * Contact variables persist across all conversations with the same user
> * Values are stored at the user (contact) level, not session level
> * Ideal for storing information like name, email, preferences, lead status, etc.
> * Can be updated anytime and the latest value is always used
> * Enables personalized and contextual conversations over time

> [tab] Secret Variable
>
> Used for storing sensitive values, such as API keys and authentication tokens.
>
> * Secret variables are encrypted at rest — the value is never exposed in plain text.
> * Once a value is set, no one on the team can view it — not even admins.
> * The value cannot be read after it is saved. It can only be updated (replaced) with a new value.
> * Secret variables can only be referenced in — HTTP request, and  JavaScript blocks.
> * Use this type for API keys, OAuth tokens, webhook secrets, or any credential that should never be visible to teammates.

![Image](https://mintcdn.com/wotnot/9dFb9jDqAX6_tYFX/images/image-368.png?fit=max\&auto=format\&n=9dFb9jDqAX6_tYFX\&q=85\&s=f6486b97c397c30556c1bab365c30fb1)

### Data Types of Variables

| | **Accepts** | **Example** | **Validation** |
| :- | :- | :- | :- |
| TEXT | Any text input | John Doe | Accepts any text value |
| NUMBER | Numeric digits from 0-9 | 12345 | Only numeric values are accepted |
| BOOLEAN | 0 , 1 , true or , false | true | Only supported Boolean values are accepted |
| DATE | Date values | 15/08/2026 | Supports `DD/MM/YYYY` and `MM/DD/YYYY` formats. |
| EMAIL | Email addresses | [customer@example.com](mailto:customer@example.com) | Validates the input as an email address. |
| PHONE | Phone numbers | +91-9876543210 | Validates the input as a phone number. |
| REGEX | Input matching a custom validation rule | ABC-123 | Validates the input against the configured regular expression. |
| SINGLE SELECT | Number/ Text | 5,10,22 / (1-5),(6-10),(11-15) / Male,Female,Other | Enter fix numbers, number range or text or select it from dropdown |

### **Creating variables**

**How to Create:**

#### **From Variable Setting**

1. Open your bot in **Bot Builder**.
2. Open the **Variables** panel.
3. Click **Create Variable**.
4. Select the appropriate **variable type**(Contact /Conversation/secret).
5. Enter a name, description and type for the variable.
6. Review the configuration.
7. Click on **Create variable**.

The variable is now available to use throughout the bot flow.

![Image (2)](https://mintcdn.com/wotnot/KsQ-zr0VbihC7Wze/images/image-\(2\).png?fit=max\&auto=format\&n=KsQ-zr0VbihC7Wze\&q=85\&s=390d7d560892ed62e8aa7b22c28da773)

> [!TIP]
>
> Use descriptive variable names written in **lowercase with underscores**. For example, use `customer_name` instead of `Customer Name` or `customername`. Avoid spaces and unclear names such as `var1` or `data`. Choose the name carefully because renaming a variable later can require you to update blocks that already reference it.

#### **From the bot builder**

1. In action blocks that allow you save user input like “Collect Input”, “Buttons” etc. you have the option to create a new variable.
2. First, you choose the type of variable(Contact or Conversation), next you provide the details like name, description, type.
3. Enter a name, description and type for the variable.
4. Review the configuration.
5. Click on **Create variable**.

![Image (3) 1](https://mintcdn.com/wotnot/KsQ-zr0VbihC7Wze/images/image-\(3\)-1.png?fit=max\&auto=format\&n=KsQ-zr0VbihC7Wze\&q=85\&s=8b4c3f6f7656618c508a8201908b29d6)

### Setting a Value

A variable can be populated in four different ways depending on where the value comes from:

> [tab] Collect input
>
> Use **Collect Input** when the value comes directly from the user.
>
> 1. Add a **Collect Input** block to your flow.
> 2. Configure the question you want to ask the user.
> 3. Select the variable where the response should be stored.
> 4. Configure any required validation.
> 5. Continue the flow after the input is captured.
>
> The value entered by the user is stored in the selected variable and can be used in subsequent blocks.

> [tab] Set variable
>
> Use **Set Variable** when you want to assign a value directly within the bot flow.
>
> 1. Add a **Set Variable** block to your flow.
> 2. Select the variable you want to update.
> 3. Enter or select the value you want to assign.
> 4. Save the configuration.
> 5. Continue the flow.
>
> For example, you can set:
>
> `customer_type` → `premium`
>
> The variable can then be referenced later in the flow.

> [tab] API Response
>
> Use an **API response** when the value comes from an external system.
>
> * Configure your **HTTP Request / API** block.
> * Configure the API request and required parameters.
> * Run the API request.
> * Review the returned response.
> * Map the required response field to a WotNot variable.
> * Save the mapping.
> * Use the variable later in your bot flow.

> [tab] JavaScript
>
> Use **JavaScript** when a variable needs to be calculated, transformed, formatted, or generated using custom logic.
>
> For example, you can calculate a total:
>
> ```text theme={null}
> const total = quantity * price;
> ```
>
> The calculated result can then be stored in a variable and used later in the flow.
>
> 1. Add a **JavaScript** block to your flow.
> 2. Select or reference the input variables required by the calculation.
> 3. Add the JavaScript logic.
> 4. Calculate or transform the required value.
> 5. Store the result in the required variable.
> 6. Continue the flow.
>
> JavaScript is useful when the value cannot be assigned directly and needs to be generated from existing data.

## **Using a variable**

You can invoke a variable by typing **#** to preview the variable dropdown across the bot builder.

* **In messages:** Display stored values dynamically, such as a customer’s name or order ID.
* **In conditions:** Use variable values to control which path the conversation takes.
* **In API requests:** Pass stored or collected values to an API to retrieve or send information.

![Recording2026 08 27131039 Ezgif Com Optimize](https://mintcdn.com/wotnot/i8uopzIFkX-Q6WYU/images/Recording2026-08-27131039-ezgif.com-optimize.gif?s=381233b0f7dbfec94a276bafe011b11e)

## **Editing variables**

You can update an existing variable when its name, type, or configuration needs to change.

* Open your dashboard
* Go to Setting→ Account→ Variable
* Open the **Variables** panel.
* Find the variable you want to edit and click on **Edit**.

![Image](https://mintcdn.com/wotnot/9dFb9jDqAX6_tYFX/images/image-370.png?fit=max\&auto=format\&n=9dFb9jDqAX6_tYFX\&q=85\&s=0bec68d0c2992fb25831a5abcbb25ed9)

> [card] IMPORTANT
>
> * **You can edit description and data type from the dropdown.**
> * **Can not edit the Variable Name**

![Image](https://mintcdn.com/wotnot/9dFb9jDqAX6_tYFX/images/image-369.png?fit=max\&auto=format\&n=9dFb9jDqAX6_tYFX\&q=85\&s=3e6c5aa1852b5fce71660e571e42bcd2)

## **Deleting variables**

> [!CAUTION]
>
> Variables can **only be archived and not deleted.**

* Open the **Variables** panel.
* Find the variable you want to remove.
* Click on  **Archive**.

![Image](https://mintcdn.com/wotnot/9dFb9jDqAX6_tYFX/images/image-371.png?fit=max\&auto=format\&n=9dFb9jDqAX6_tYFX\&q=85\&s=73172dc1232676eab9cecf65b397fc0a)

### Restoring variables

You can restore variables from the "Archived" tabs, by choosing the 'Restore' button on the required variable.

![Image](https://mintcdn.com/wotnot/9dFb9jDqAX6_tYFX/images/image-373.png?fit=max\&auto=format\&n=9dFb9jDqAX6_tYFX\&q=85\&s=a255d4ad89b97a0ac346b6a7c199b397)

> [!WARNING]
>
> Variables can be referenced by multiple blocks across your bot. Renaming, changing, or deleting a variable can affect every block that depends on it. Review existing references before making changes. If the bot is already live, changes to variables can also affect conversations that are currently in progress depending on where the variable is used.

* Changing or deleting a variable can affect every block that already references it. This includes messages, conditions, API requests, JavaScript, and other actions that use the variable.

## **Adding default value to variables**

You can add a default value to the variable, so that incase there is no value present a default value can be shown to the user.

To add the default value,

* Open the bot builder canvas
* Add a variable on any message box
* Click on the variable tag and define the fallback value from the popup.

![Image](https://mintcdn.com/wotnot/9dFb9jDqAX6_tYFX/images/image-374.png?fit=max\&auto=format\&n=9dFb9jDqAX6_tYFX\&q=85\&s=366f3eeb9af15f565046900720841a1b)

## **Customizing error messages in variables**

You can customise error messages in variables.

1. Navigate to Settings > Variables.
2. Locate the variable with this format **(Number, Boolean, Date, Email, Phone & Regex)** used for validation.
3. Click "Edit" and edit the error message field.
4. Save the changes and test the flow to confirm the new error message is displayed.

This allows you to replace the default *“Invalid! Please enter a valid input”* with a custom, user-friendly error message (e.g., *“Please enter a valid business email address to continue”*).

## **Retrieving JSON objects from a variable**

If you are storing JSON objects into variables and want to refer a particular field from the JSON object, you can follow the below approach:

* Create a TEXT type variable
* Store the JSON object in that variable
* Use # followed by your variable name and append the field you want to refer
* Hit enter so the variable chip is created

For example:

```typescript theme={null}
// Assume this is your JSON object
[
  { "account_id": "A1", "user": "John" },
  { "account_id": "A2", "user": "Sara" },
  { "account_id": "A3", "user": "Mike" },
  { "account_id": "A4", "user": "Tina" }
]

// If I want to refer to the second object i.e. account_id=A2
#name[1].account_id#
```

# Troubleshooting

> [accordion] The variable renders blank in a message
>
> If a variable appears empty when displayed in a message, check whether the variable has been populated before the message is sent.
>
> Check:
>
> * Whether the variable is assigned a value.
> * Whether the Collect Input block successfully captured the value.
> * Whether the Set Variable block runs before the message.
> * Whether the API response contains the expected field.
> * Whether the variable reference is written correctly.
>
> For example, if `customer_name` has not been populated, a message containing `{{customer_name}}` may not display the expected value.

> [accordion] The condition never matches
>
> If a condition does not follow the expected path, verify the actual value stored in the variable.
>
> Check:
>
> * The variable contains a value.
> * The value matches the expected format.
> * The comparison operator is correct.
> * The comparison value matches the variable type.
> * There are no unexpected spaces or formatting differences.
>
> For example, a Number variable containing `100` may not behave the same way as a Text variable containing `"100"` in every comparison.

> [accordion] A value from an earlier flow is not carrying over
>
> If a variable was populated earlier but is empty later in the conversation, check where and when the value is assigned.
>
> Make sure:
>
> * The variable is the same variable throughout the flow.
> * The value is assigned before it is referenced.
> * Another block is not overwriting the value.
> * The flow path actually reaches the block that populates the variable.
> * The variable has not been renamed or deleted.
>
> If the value comes from an API or JavaScript block, also verify that the operation completed successfully before the variable is used.

> [accordion] Get a type mismatch when comparing a variable
>
> A type mismatch usually occurs when the value stored in the variable does not match the type expected by the condition or another block.
>
> * Check the variable type.
> * Check the actual value stored in the variable.
> * Make sure numeric values are stored as numbers when required.
> * Make sure text values are stored in a text-compatible variable.
> * If the value comes from an API, check the type returned by the API.

> [accordion] The variable is populated but is not reflected in an API call
>
> * Check how the variable is mapped into the HTTP request.
> * Confirm that the variable contains the expected value before the API block runs.
> * Check the variable reference used in the request.
> * Verify that the variable is mapped to the correct request field.
> * Check whether the API expects the value in the request body, header, or URL.
> * Test the API request and inspect the request payload and response.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.