Skip to content

Chatbots

Chatbot Variables: Personalize Flows With Saved Answers

How chatbot variables work in a no-code flow: naming them, choosing answer types, and seven practical ways to personalize and route conversations with saved answers.

By the RetroChat team · 7 min read

Chatbot variables are named slots where a chatbot stores information: a visitor's answer to a question (like team_size or email), or a value the chat tool fills in for you (like whether anyone on your team is online). Once a value is stored, the bot can use it anywhere later in the conversation: in messages ("Thanks, {{name}}"), in IF/ELSE conditions that pick the next step, and to skip questions it already knows the answer to. Variables are what turn a fixed script into a conversation that responds to the person in front of it.

This guide explains the kinds of variables, how to name them, and seven practical ways to use them.

What a chatbot variable is

Think of each variable as a labeled box. A question puts something in the box; later steps read what's inside.

Bot asks Answer type Saved to Example value
"What brings you here?" Buttons topic Pricing
"How many people are on your team?" Number team_size 12
"What's your name?" Text name Sam
"Where should we send the details?" Email email sam@example.com

The bot can now say "Thanks, Sam" and send a team of 12 down a different path from a team of 2, without asking anything twice.

The three kinds of variables

1. Answers you collect. Every question saves its answer to a variable you name. These are the backbone of any decision-based flow.

2. Contact fields. Some variables are special because they describe the person. In RetroChat, answers saved to name, email or phone also fill in the contact's profile in your inbox, so your team sees them.

3. Built-in variables. The chat tool fills these in without asking the visitor. In RetroChat they are:

Variable What it holds
agents_online true if someone on your team is online right now
office_open true during your office hours
returning_visitor true if this visitor has chatted with you before
page_url The page the visitor started the chat on
country The visitor's approximate country, as a two-letter code such as US or DE
name, email, phone Filled in if already known, for example for signed-in users

Built-in variables are often the most useful, because they let the bot adapt without adding a single question.

Name variables so future you understands them

Six months from now, someone will edit this flow. Make it easy for them:

  • Short, lowercase, underscores: team_size, not How many people Q3.
  • One meaning per variable. Give each question its own variable, so you always know what a value means.
  • Describe the content, not the step: budget rather than question_4.
  • Reuse the standard names (name, email, phone) when you're collecting those details, so they reach the contact profile.

Pick the answer type that fits the variable

The answer type decides what ends up in the box, and what you can do with it later.

  • Buttons save the label of the button pressed. Great for exact matches.
  • Number saves a number you can compare with "greater than" or "less than."
  • Email checks the format before saving, which keeps typos out of your follow-up list.
  • Phone saves a number to call or text back from your own phone.
  • Text saves whatever was typed. Useful for detail you'll read, but hard to branch on.

Seven ways to use variables

1. Personalize messages

Insert any saved answer into a message with double curly brackets:

Thanks, {{name}}! For a team of {{team_size}}, most people start with our Team plan.

Use this sparingly. One or two personal touches feel attentive; every message repeating the name feels automated.

2. Confirm details back

Repeating key details prevents mistakes and reassures the visitor:

Got it. We'll send your quote to {{email}} by tomorrow morning.

If the email is wrong, the visitor can say so before they leave.

3. Skip questions you already know

If a signed-in visitor's email is already known, don't ask again:

  • IF email is set → go straight to the next topic
  • ELSE → ask for the email

4. Route by the page they're on

A visitor who opens chat on your pricing page probably has a different question from one on a help article:

  • IF page_url contains /pricing → "Questions about plans? I can help you pick one."
  • ELSE → your standard greeting

5. Welcome returning visitors differently

  • IF returning_visitor is true → "Welcome back! Are you following up on something?"
  • ELSE → the full introduction

6. Only promise what you can deliver

Check who's around before you promise a quick reply:

  • IF agents_online is true → "Connecting you with the team now."
  • ELSE → "We're offline right now. Leave your email and we'll reply first thing."

office_open works the same way for messages tied to your opening hours.

7. Route by size, budget or urgency

Number variables make thresholds easy:

  • IF team_size is greater than 20 → hand off to sales
  • ELSE → show self-serve options

Our chatbot decision tree guide shows how these branches fit into a whole flow, and the lead qualification chatbot guide covers which thresholds are worth setting.

Common variable mistakes

Mistake What goes wrong Fix
Renaming a button but not the condition The condition no longer matches the saved label Update conditions whenever you edit button labels
Using a variable before it's set That part of the message comes out blank Ask first, or check "is set" before using it
Comparing text answers as numbers "Greater than" can't work on "about twelve" Make it a Number question
Branching on free text with "contains" People spell things in unexpected ways Use buttons when you need reliable branching
Vague names like answer1 Nobody can maintain the flow later Name by meaning: budget, timeline

A small worked example

Here's a short flow that uses five variables and skips the email question when the email is already known:

  1. Condition: IF returning_visitor is true → "Welcome back!" ELSE → "Hi! I'm the [Company] assistant."
  2. Question (buttons), saved to topic: Pricing / Support / Something else
  3. Condition: IF topic is "Support" → step 5 (support skips the sizing question).
  4. Question (number), saved to team_size: "How many people would use it?"
  5. Condition: IF email is set → step 6. ELSE → Question (email), saved to email.
  6. Condition: IF agents_online is true → Hand off ("Connecting you with the team now.") ELSE → End ("Thanks! We'll reply to {{email}} first thing.")

Every path passes the email check in step 5, so {{email}} is always set by the time the final message uses it. That's the habit to build: never insert a variable unless every route to that message sets it.

How to do this in RetroChat

In RetroChat's no-code builder, every question step saves its answer to the variable you name, and any message can use it as {{variable}}. Condition steps check rules from top to bottom: is, is not, contains, doesn't contain, starts with, is greater than, is less than, is set and is empty, with an else path when nothing matches. The is rule ignores upper and lower case, so yes matches Yes. The full list, with examples, is in Variables and conditions.

When a person takes over, everything the bot collected is shown next to the chat and saved on the contact's profile. Flows, including their variables and rules, can be exported and imported as JSON files, which is handy for backups and for reusing a flow on another website. See Import and export flows, which includes a working sample flow.

Start with two variables

You don't need a complex setup. Add an agents_online check before your hand-off and an email is set check before you ask for an email, and your bot will already feel smarter. Try it in a free 14-day RetroChat trial, no credit card required.

Frequently asked questions

What are variables in a chatbot?

They're named places where the chatbot stores information, such as a visitor's answers or values the tool fills in automatically. The bot uses them to personalize messages, choose the next step and avoid asking the same question twice.

What is a built-in chatbot variable?

It's a value the chat tool provides without asking the visitor, such as whether your team is online, whether you're within office hours, which page the visitor is on, or whether they've chatted before. Built-in variables let a flow adapt with no extra questions.

How do I use a variable in a chatbot message?

In most no-code builders, including RetroChat, you put the variable name in double curly brackets, for example "Thanks, {{name}}!" The bot replaces it with the visitor's saved answer when it sends the message.

Why isn't my chatbot condition matching?

Common causes are a button label that changed after the condition was written, comparing a text answer with a number rule, or checking a variable that hasn't been set yet. Test each path with the builder's test mode after any edit.