For the complete documentation index, see llms.txt. This page is also available as Markdown.

4. Steer the conversation with Conditions

In the previous lesson, you learned how to get user input and re-use it as variables. Let's see now how the conversation can be steered in different directions based on variables.

Apart from being re-used inside the conversation itself, variables can help the bot steer the conversation in different directions, by using Condition blocks.

What we will build in lesson 4.

Step 8: Check a variable in a Condition block

Our Bee bot now asks if the user is new, then asks the user information.

We would like Bee to give a slightly different answer depending on if the user is new or returning. To do so, we’ll need a Condition block that checks a {userType} variable.

The Condition block type.

Get variables under button clicks

We’ll save a {userType} variable under button click of the Check user type block. This variable can have either the value returning or new.

To save a variable under a button click:

  1. Open the Check user type block.

  2. Under the first I’m new button, click on + Add a variable and create the variable userType.

Create a variable under a button click.
  1. Add the value new.

  2. For the second button, do the same with the value returning.

Make your Go-to buttons capture variables.
  1. Save your changes.

Now, when a user clicks on one of these buttons, the system will remember the {userType} variable. Let's utilize this variable within a Condition block.

Add a Condition block

We aim to create a Condition block that evaluates the {userType} variable and provides a different response based on its value.

To add a Condition block:

  1. Open the Next block block.

  2. Go to its Settings.

  3. Change its Type to Condition.

Change a block dialog type from its Settings.
  1. You’ll get a warning message. Click Yes, change type.

  2. Under Bot dialog name, change the block name to Route userType.

Change a block name from its Settings.
  1. Go back to its configuration, and click on the + to add your first condition.

  2. Fill in the block as follows, using the equal case insensitive operator:

    • If {userType} = new,

      • then Go to Send email new user. You can create this new block directly from the text field.

    • Else if {userType} = returning,

      • then Go to Send email returning user. You can create this new block directly from the text field.

    • Else:

      • Go to Error occurred.

Your window should look like this:

Fill your Condition block with conditions.
  1. Save your changes.

Your canvas looks a bit messy now, and that’s totally normal. Let’s organize it a bit:

Organize your flow

To re-organize your flow when it looks messy, click on the Auto-layout button at the bottom-right corner of your canvas.

What we created should look like this now:

What your canvas should look like at this point.

Lesson 4 recap

Congratulations! In this lesson, you’ve learned how to:

Coming next

Coming next, we’ll see how to connect your bot to 3rd party providers so that you leverage your bot’s functionalities.

5. Empower your bot with Actions

💬 Feedback

Last updated

Was this helpful?