Skip to content

Steps

Switch

Route the chat on one value, such as a status or an answer, with one path per case.

What it does#

Switch looks at one value and sends the chat down the path of the first case that matches. If nothing matches, the chat follows Default. Nothing is sent to the customer.

It's the tidy alternative to a Filter with many groups that all check the same thing: order status is paid / shipped / delivered / cancelled, language is he / en / ru, score is above 80 / above 50.

The Switch step

Set up a Switch#

  1. 1

    Drag Switch onto the canvas

    It's under Tools in the step list. Connect the step before it.

  2. 2

    Choose the value

    Under Value, write what to route on, for example #status (from your system) or lower(trim(@answer)). It's an expression.

  3. 3

    Decide about case

    Tick Ignore upper / lower case so Paid and paid count as the same.

  4. 4

    Add the cases

    Under Cases, each case is Equals (type the value, for example paid) or Condition (an expression about value, for example value > 100). Click Add case for more, up to 30. Use the arrows to reorder.

  5. 5

    Connect the outputs

    On the canvas, each case has its own connection, plus Default. Connect them all, Default included.

How cases match#

  • Cases are checked top to bottom. The first match decides where the chat goes.
  • Equals compares numbers as numbers (2 matches 2.0) and text exactly, ignoring spaces at the ends. With Ignore upper / lower case ticked, case doesn't matter.
  • Condition is true or false, and value is the Switch value: value > 100, contains(value, "vip"), value in ["he", "iw"].
  • If the Value can't be computed, the chat follows Default and you get an alert. If one case can't be computed, that case is skipped and you get an alert.

Example#

A store's system starts the chat with a Catch Hook that sends status. The bot replies differently for each status:

CaseTypeGoes to
paidEqualsWe're preparing your order
shippedEqualsTracking link message
deliveredEqualsHow was it? feedback question
contains(value, "cancel")ConditionRefund details
DefaultTalk to a person

Value: #status, with Ignore upper / lower case ticked. A status of Shipped follows the second case. cancelled_by_user matches the Condition case. An unknown status like on_hold goes to Default.

Before publishing, open Test expression on a Condition case, fill in Switch value to test with, and click Run.

Common mistakes#

  • A broad case above a specific one. value > 50 above value > 80 catches everything over 50 first. Put the narrowest case on top.
  • Quotes in an Equals case. Type paid, not "paid": an Equals case is plain text. Quotes are only for expressions.
  • Default not connected. Customers whose value matches nothing get stuck. Connect Default, for example to a Talk to a person step.
  • Routing on a free-text answer. Customers type in many ways. Ask with Buttons or a List first, or normalize the answer: lower(trim(@answer)).