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

Kinds of variables:

* **System variable** - Created by default by WotNot. Contains things like city, country, os etc.
* **Contact variable** - Stores the value in the variable for recurring conversations. Usually used for collecting names, email etc.
* **Conversation variable** - Stores the value in the variable for that conversation only. <br>

## **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="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2FLUcCi0Hq1GmfL7UI1gTN%2FCleanShot%202025-07-26%20at%2012.06.56.png?alt=media&#x26;token=a60b069c-08ba-410f-8e17-c552c987bca4" 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="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2FiM81LO1LLi62npodpRvb%2FCleanShot%202025-07-26%20at%2012.09.00.png?alt=media&#x26;token=7a88d7b3-20a2-4aed-908d-7e6592635bc6" 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="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2Fs8OLf8KnFiuMrSzT9t0k%2FCleanShot%202025-07-26%20at%2012.10.24.png?alt=media&#x26;token=5a5eb9db-514a-4612-b9b2-9ee7d0bf538b" 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="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2FRYL3CKm5hBjmJng9deAW%2FCleanShot%202025-07-26%20at%2012.09.57.png?alt=media&#x26;token=7e98a553-b018-4d59-a7f8-ec2db4ae81b0" 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="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2FbSkSdj9cm4fDn5ALqscq%2FCleanShot%202025-07-26%20at%2012.11.15.png?alt=media&#x26;token=bb1b71c8-58b5-43e0-af69-4b42c7a7ad5a" 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="https://360969599-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsrMxU8nO3RjusUiYuXBB%2Fuploads%2FNI55JH0I4ihcimZoUpjc%2FCleanShot%202025-07-28%20at%2018.05.06.png?alt=media&#x26;token=10d3eef9-a8ee-4333-8a22-c1789811064c" 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.
