# Variables

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 Hardik!”, instead of “Hey there!”.

## Types of variables

### **Conversation variable**&#x20;

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

### 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

### 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.

## Creating variables from variables settings

Under Settings > Variables, you will find all the variables in your workspace. You can click “Create” to create a new variable and provide the details like -- name, description and type.&#x20;

<figure><img src="/files/hHt2AUfyYE7CzLhUxkcA" alt=""><figcaption></figcaption></figure>

## **Creating variables from the bot builder**

In action blocks that allow you save user input like “Collect Input”, “Buttons” etc. you have the option to create a new variable.&#x20;

<figure><img src="/files/N7zFV2MHvr2sHol0moK3" alt=""><figcaption></figcaption></figure>

First, you choose the type of variable, next you provide the details like name, description, type.&#x20;

## Editing variables

Go to Settings > Variables > Click “Edit” on the variable.&#x20;

You will be only allowed to edit the description and data type.&#x20;

<figure><img src="/files/evXlK4ySDI2hwm0c8wPR" alt=""><figcaption></figcaption></figure>

## Deleting variables

Variables can only be archived and not deleted.&#x20;

Go to Settings > Variables and click “Archive” on the variable you want to archive.

<figure><img src="/files/PQJNRye7xK0gfiH7FZGC" alt=""><figcaption></figcaption></figure>

## Using a variable

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

<figure><img src="/files/pGa9qaBimt7uSvsArPik" alt=""><figcaption></figcaption></figure>

## Data types in variables

You can store the following type of data in variables:

<table><thead><tr><th width="169">Data type</th><th>Description</th></tr></thead><tbody><tr><td>Text</td><td>Stores any text input.</td></tr><tr><td>Number</td><td>Stores only numeric digits from 0 to 9.</td></tr><tr><td>Boolean</td><td>Stores only 0, 1, true, false.</td></tr><tr><td>Date</td><td>Stores date formats as DD/MM/YYYY and MM/DD/YYYY</td></tr><tr><td>Email</td><td>Stores email addresses.</td></tr><tr><td>Phone</td><td>Stores phone numbers.</td></tr><tr><td>Regex</td><td>Stores input based on your validation rule.</td></tr></tbody></table>

## 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, and click on the variable tag. You can then enter the fallback value.

<div align="left"><figure><img src="/files/jn9N5GKSiIV40PalnXkb" alt=""><figcaption></figcaption></figure></div>

## 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:

```
// 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#
```

## System variables offered

Here are the system variables offered by default:&#x20;

<table><thead><tr><th width="282">Variable</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>Name of the visitor</td></tr><tr><td>email</td><td>Email of the visitor</td></tr><tr><td>phone</td><td>Phone number of the visitor</td></tr><tr><td>ip_address</td><td>IP address of the visitor</td></tr><tr><td>city</td><td>City detected through the IP address of the visitor</td></tr><tr><td>state</td><td>State detected through the IP address of the visitor</td></tr><tr><td>zipcode</td><td>Zipcode detected through the IP address of the visitor</td></tr><tr><td>country</td><td>Country detected through the IP address of the visitor</td></tr><tr><td>timezone</td><td>Browser timezone of the visitor</td></tr><tr><td>os</td><td>System OS of the visitor</td></tr><tr><td>referrer_url</td><td>Referrer domain to the visitor.</td></tr><tr><td>unsubscribed_phone_numbers</td><td>Whether the phone number is unsubscribed from outbound messaging.</td></tr><tr><td>utm_source</td><td>Utm source </td></tr><tr><td>utm_medium</td><td>Utm medium </td></tr><tr><td>utm_campaign</td><td>Utm campaign </td></tr><tr><td>utm_content</td><td>Utm content </td></tr><tr><td>utm_term</td><td>Utm term </td></tr><tr><td>browser</td><td>Browser used during the chat</td></tr><tr><td>contact_id</td><td><br></td></tr><tr><td>bot</td><td>Name of the bot the visitor interacted with.</td></tr><tr><td>browser_language</td><td>Language set in the browser.</td></tr><tr><td>browser</td><td>Name of the browser.</td></tr><tr><td>channel</td><td>Name of the channel where the chat took place.</td></tr><tr><td>contact_created_by</td><td>Who created the contact.</td></tr><tr><td>conversation_url</td><td>Link to the conversation.</td></tr><tr><td>country_code</td><td>ISO country code of the country where the chat originated from.</td></tr><tr><td>created_at</td><td>Date when the chat was created.</td></tr><tr><td>gcal_selected_slot_day</td><td>Selected day when booking the meeting on Google Calendar.</td></tr><tr><td>gcal_selected_slot_time</td><td>Selected time when booking the meeting on Google Calendar.</td></tr><tr><td>timezone</td><td>Timezone of the device.<br></td></tr><tr><td>url</td><td>URL of the webpage where the user is interacting with the bot.</td></tr><tr><td>chat_history</td><td>Includes the transcript of the conversation so far.</td></tr></tbody></table>

## Best practices for variable management

* **Use descriptive names**: Choose variable names that clearly reflect the data they hold, such as "userEmail" or "orderTotal".
* **Document purposefully**: Write clear descriptions that explain the variable's role within your AI agent's workflow.
* **Maintain consistency**: Use a consistent naming convention for your variables to make them easily identifiable and manageable.
* **Regularly review and refine**: As your AI agent evolves, revisit your variables to see if they still serve their intended purpose or need adjustments.


---

# 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.wotnot.io/build/interface/variables.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.
