Skip to content

Variables and conditions

How RetroChat saves answers to variables, which built-in variables you can use, and every IF/ELSE rule a condition step can check.

Conditions let your chatbot branch:

  • send big budgets to sales;
  • skip questions you already know the answer to;
  • check whether anyone is online before handing off.

They work on variables.

Variables

Every question saves its answer to the variable you name. Pick short, lowercase names with underscores, such as topic, team_size or budget.

  • For quick-reply questions, the variable holds the label of the button the visitor pressed, for example Buying a bike.
  • name, email and phone are special. Answers saved to them also fill in the contact's profile in your inbox.

Built-in variables

RetroChat fills these in for you, so you can branch on them without asking:

Variable What it holds
agents_online true if someone on your team is online right now, otherwise false
office_open true during your office hours, otherwise false
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 known (for example from identity verification)

Conditions

A condition step has one or more rules and an else path:

  • Rules are checked from top to bottom. The first rule that matches sends the visitor to its step.
  • If no rule matches, the visitor goes to the else step.

The rules

Rule Matches when the variable… In a flow file
is equals the value (not case-sensitive) equals
is not doesn't equal the value not_equals
contains contains the value contains
doesn't contain doesn't contain the value not_contains
starts with starts with the value starts_with
is greater than is a number above the value gt
is less than is a number below the value lt
is set has any answer is_set
is empty has no answer yet is_empty

Examples

Send bigger teams to sales. After asking "How many people are on your team?" (saved to team_size):

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

Only promise a fast reply when someone can give one:

  • IF agents_online is true → "Connecting you now"
  • ELSE → "We're offline; leave your email and we'll reply first thing tomorrow"

Skip a question you already know:

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

Good to know

  • Number rules compare numbers, so make that question a Number question.
  • Keep rule values simple. is ignores upper and lower case, so yes matches Yes.
  • The builder warns you if a rule points nowhere, or if a step can't be reached.