# Field Variable

{% hint style="info" %}
Before the detailed introduction of each step, let's take a look at what is **field(variable)**. It might take you a moment but this is essential to know more about the system. Field, aka variable, is a container to hold a value.
{% endhint %}

| Classification                                                               | Description                                                               |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| System Field                                                                 | Created by the system with pre-defined variable names and types.          |
| Custom Field                                                                 | Defined by the user, allowing for customized variable names and types.    |
| Bot Field                                                                    | Shared across the whole bot, accessible globally within the bot.          |
| User Field                                                                   | Unique to each user, meaning each user has their own set of these fields. |
| **text**, **number**, **boolean**, **date**, **datetime** and **JSON** field | see variable type section                                                 |

## User Field

User field belongs to users. For example, each user has their own name and email address. So "name" and "email" are user fields.

## Bot Field

Bot field belongs to the bot. For example, a restaurant bot holds an address and contact number of the restaurant. So "restaurant\_address" and "restaurant\_contact" should be created as bot fields. Because you don't want to manage different addresses or contacts of your restaurant for every user.

## System Field

System field is created by the system with pre-defined variable name and variable type. There are system bot field and system user field:

Some system fields only exist in the specific channel.

| Field Name       | Field Type | Variable Type | Description                          |
| ---------------- | ---------- | ------------- | ------------------------------------ |
| User Ns          | user field | text          | user identification in               |
| User Id\*        | user field | text          | user identification from the channel |
| First Name       | user field | text          | profile info                         |
| User Name        | user field | text          | profile info                         |
| Phone            | user field | text          | profile info                         |
| Subscribed       | user field | datetime      | subscribed time                      |
| Last Text Input  | user field | text          | user's last input                    |
| Last Interaction | user field | datetime      | last action time                     |

{% hint style="info" %}
If the channel doesn't support timezone in user's profile, or, the channel supports but the user don't have a timezone value, workspace timezone will be used instead.
{% endhint %}

## User Id in Different Channels

| Channel   | Meaning                           | Example Value                        |
| --------- | --------------------------------- | ------------------------------------ |
| WhatsApp  | User's phone number without **+** | 60123456789                          |
| Facebook  | Unique Id in your Facebook page   | 6123456789101112                     |
| Instagram | Unique Id in your Instagram bot   | 612345678910111213                   |
| Telegram  | Unique Id in your Telegram bot    | 1234567891                           |
| WeChat    | Unique Id in your WeChat account  | oNzS3wpEjnA3tXmOcNxpqtAnBwWg         |
| SMS       | User's phone number               | +60123456789                         |
| Google    | Conversation Id from Google       | 8095938e-90cf-4347-ab94-9224308672b0 |
| Line      | Unique Id in your Line bot        | Ub02c77c69c59c5be5597d58ce2701ebe    |

{% hint style="info" %}
The unique id from the channel is only unique in your Facebook page, Telegram bot or WeChat account, not the unique id in the whole Facebook, etc.
{% endhint %}

## Variable Type

There are 6 types of variable:

| Type         | Storage                              | Example                      | Operations Supported                                                      |
| ------------ | ------------------------------------ | ---------------------------- | ------------------------------------------------------------------------- |
| Text         | letters, words, sentences...         | Lewis                        | cutting, change case, encode, decode...                                   |
| Number       | numbers                              | 12345                        | + - x ÷, mod, power, log, root, round...                                  |
| Boolean      | either "1" or "0", for true or false | 1                            | assign                                                                    |
| Date         | date                                 | 2025-01-14                   | format, add months/weeks/days                                             |
| DateTime     | date and time                        | 2025-01-01T12:00:00+10:00    | format, add months/weeks/days/hours/minutes                               |
| JSON (array) | a series of variables                | {"name":"Lewis", "age":"21"} | load, get, update, remove, count, sum, average, sort, shuffle, reverse... |

## Boolean Value

When these values stored in the field, the boolean return **false**, otherwise it goes **true**:

* null
* empty
* 'false'
* false
* 'no'
* 0
