Home · Help · Conditions and branches

Conditions and branches

The “Condition” block is the only place where a flow makes a decision without the customer's input: it looks at the contact's tags, variables, channel, and time, and routes the conversation to one of the branches. Buttons in a “Message” are a different mechanism: there, the person chooses. Below: what exactly “Condition” checks, which operators are available, in what order branches are evaluated, and the most common mistakes.

What you can check

CheckWhat is comparedTypical use
TagWhether the contact has the specified tag“paid,” “vip,” “newsletter,” “src:ads” — segmentation and access to branches
VariableThe value of a flow variableA number from “Data collection” (“area greater than 40”), an answer to an open question, the result of an “HTTP request”
ChannelWhere the customer is writing from: telegram, max, vk, webDifferent texts and buttons for VK (10-button limit) and the widget (files)
TimeCurrent hour, 0–23At night — “we’ll reply in the morning” instead of handing off to an operator
Day of the weekCurrent day, 0–6 (0 is Sunday)On weekends — a different text or a delayed follow-up

The hour and day of the week come from CHBT server time, not the customer’s time zone — the boundaries are easy to check in the test chat. You don’t need a “message text” check here: reactions to the customer’s words are set by the “Keywords” and “Any message” triggers, and an answer to an open question is saved to a variable by “Data collection” and then checked with “Condition.”

Comparison operators

A rule consists of a field, an operator and a value. In the interface, operators are shown as symbols and words:

  • = and ≠ (equals / does not equal) — exact string match; “Yes” and “yes” are different values, so for text answers, buttons with tags are more reliable.
  • contains / does not contain — a substring: the variable city contains “Mosc”.
  • >, <, ≥, ≤ — numeric comparison; the value must be a number (set “Input validation: Number” in “Data collection”), otherwise the comparison returns “no”.
  • regex — a case-insensitive regular expression: ^\+?7\d{10}$ checks the phone number in a variable.
  • in list — the value matches one of the comma-separated items: Moscow, Kazan, Ufa.
  • is set / is not set — whether the variable has a value: this is how you check whether the person already left a phone number, so you don’t ask twice.

For a tag, “is set” and “is not set” are enough — a tag is either present or not.

Branches, check order, and “otherwise”

The block has several branches and a required “otherwise” branch. Each branch is a set of rules, and within a branch the rules work as “and”: the branch matches only if all of them are met. Branches are checked from top to bottom, and the conversation goes to the first one that matches; if none matches, it goes to “otherwise”.

This leads to two practical rules:

  1. Specific above general. Put “has tag vip and has tag paid” above “has tag paid”, otherwise VIP customers will never reach their branch.
  2. “Or” means two branches with the same outcome. If a budget of “300–600” or “600+” should lead to a manager, create two branches with the same continuation; there's no “or” within a single branch.

Don't leave the “otherwise” branch empty: a customer who doesn't match any rule should get at least “Thanks, I've passed this on to the admin” and an “Operator” block, otherwise the conversation will stall with no reply. In “Steps” mode, you choose each branch's target block from a list; on the “Canvas” (Basic plan), branches are shown as arrows — more convenient when there are three or more.

Common errors

  • The variable isn’t saved. “Data collection” writes the answer to the contact card; for “Condition” to see it, turn on “save to variable” and enter a name. Learn more in the help article on variables.
  • A number is compared as text. “10” is greater than “9” only if both values are numbers; without a format check, a customer will type “ten” and the branch won’t fire.
  • The tag is added after the condition. The “Add a tag” action must come earlier in the branch than the block that checks the tag — in the same conversation or a previous one.
  • A branch leads nowhere. After a “Condition”, every branch must lead to a block; an empty output means the bot stays silent.

Similar in purpose but different in mechanics is the “Intent (AI)” trigger: it classifies the customer’s free-form text with a neural network and starts the flow if the text matches the described intent. It’s a trigger, not a block, and it’s available from the Basic plan along with the other AI features. Ready-made examples of conditions are in the “Quiz bot” (qualification by tags) and “Property finder” (numeric comparisons) templates. You can test the logic without a messenger using the “Check flow” button in the editor.

FAQ

Can I use “or” within one branch?
No, rules inside a branch work as “and.” For “or,” create two branches with the same continuation.

How do I check whether a customer has already left a phone number?
Save the phone number “to a variable” in “Data collection” and add a “Condition” with the “is set” operator on that variable; put the phone collection block in the “otherwise” branch.

Does the Condition check the customer's message text?
Not directly. A customer’s words are caught by the “Keywords” and “Any message” triggers; the answer to an open question is first saved to a variable with “Data collection”, then checked with “Condition”.

Do I need a paid plan for the “Condition” block?
No, the block is available on the Free plan in “Steps” mode. The visual “Canvas” editor starts with the Basic plan.

Create a bot for free