Variables and custom fields in chatbots
Variables let your bot remember answers and personalise messages, for example by greeting a customer by name.
- Plan
- Depends on your plan · Which plan do I need?
- Who can use this
- Account owner, Manager
Variables let your bot remember answers and personalise messages, for example by greeting a customer by name.
Variables let your bot remember answers and personalise messages, for example "Thanks, {{name}}!". Besides the variables your bot collects, it can read built-in contact and ad details, your contacts' custom fields, and workspace-wide global values.
In the builder (Sidebar → Chatbot → open a bot). Use a variable anywhere text is allowed by typing {{variableName}}. The Static Variables and Custom Fields switches are in the builder header.
In a later message, type {{variableName}}.
Type the variable name, for example {{STAT_NAME}}.
Read a field with {{CF_<field>}}.
These need Static Variables on. Each is empty when unknown.
| Variable | Holds |
|---|---|
STAT_NAME, STAT_PHONE, STAT_EMAIL | The contact's name, phone and email |
STAT_WHATSAPP_USER_ID | The WhatsApp user ID of a customer who uses a WhatsApp username (their phone is then empty); empty for everyone else. See Customers with a WhatsApp username |
STAT_CONV_ID, STAT_CHANNEL_ID, STAT_CHANNEL_TYPE | The conversation id, channel id and channel type |
STAT_ASSIGNED_STAFF_NAME, STAT_ASSIGNED_STAFF_ID | Who the conversation is assigned to |
STAT_MESSAGE_TYPE, STAT_MESSAGE_MEDIA_URL | The kind of the latest message and its file link |
STAT_IS_FOLLOWER, STAT_FOLLOWER_COUNT, STAT_MESSAGE_SOURCE, STAT_COMMENT_ID, STAT_SOURCE_MEDIA_ID, STAT_SOURCE_MEDIA_TYPE, STAT_SOURCE_URL | Instagram and Messenger details |
When a customer starts the chat from a Click-to-WhatsApp, Instagram or Messenger ad, these hold the ad they came from last:
| Variable | Holds |
|---|---|
STAT_AD_ID | The ad id (a post id when it was a boosted post) |
STAT_AD_NAME | The ad's name when known, otherwise its headline |
STAT_AD_HEADLINE, STAT_AD_BODY | The ad's headline and text |
STAT_AD_SOURCE_TYPE | ad, or post for a boosted post |
STAT_AD_SOURCE_URL | The ad or post link |
STAT_AD_MEDIA_TYPE, STAT_AD_MEDIA_URL | image or video, and its link (the link can expire) |
STAT_AD_WELCOME_TEXT | The greeting the ad showed |
STAT_AD_CLICKED_AT | When they clicked (UTC) |
STAT_AD_CHANNEL | facebook, instagram or other |
STAT_ADSET_NAME, STAT_CAMPAIGN_ID, STAT_CAMPAIGN_NAME, STAT_AD_OBJECTIVE | Filled only when your Meta Ads account is connected |
Tip: add a Condition "STAT_AD_ID is set" at the start to give ad visitors their own welcome.
A global variable holds one value for the whole workspace, such as an API key or a store URL. Use it as {{GL_name}}. A bot reads global variables only when its global-variables setting is on, and it is off for new bots.
The panel and the builder have no screen for global variables and no switch for that setting. Use the Copilot: it lists, creates and changes global variables, and switches the setting on for a bot.
No plan limit on variables. A Set block can also calculate: numbers, text joins, comparisons and simple formulas such as {{party}} * 150.
42), which becomes a number. A leading zero (007) or a phone number with + stays text.{{STAT_ANYTHING}} is not a wildcard.Do it with Copilot
Do it with Copilot
Do it with Copilot
Do it with Copilot
| What you see | Why | What to do |
|---|---|---|
| "Static variables (STAT_...) are used but the "Static variables" toggle is off — they will render as empty text." | Switch off. | Turn on Static Variables. |
| "Custom fields (CF_...) are used but the "Custom fields" toggle is off — they will render as empty text." | Switch off. | Turn on Custom Fields. |
| "A Custom Field block is used but the "Custom Fields" toggle is off — the field will not be updated." | Switch off. | Turn on Custom Fields. |
"Variable '{{name}}' is used but never defined or collected — it will render as empty text." | Typo or never set. | Create it, collect it, or fix the spelling. |
STAT_CAMPAIGN_NAME is always empty | Meta Ads not connected. | Connect it under Settings → Meta Ads. |