Simple cart v0.2

Dilyara Updated by Dilyara

Sometimes we want to let users choose multiple items and then ask, for example, how many units of each selected item they want to add. Here we want to show you a very simple way to achieve it!

  1. Import the brick into your bot

There are 2 ways to open theย Bricks explorerย menu:

  • Drag and drop the arrow and choose the optionย Bricksย when building your flow.
  • ย Click on theย Bricks iconย on the left side of the Bot Builder:

The Brick is called Simple cart v0.2:

  1. Enter the brick

  1. In the first Buttons block, you can set different categories of items that you have:
  1. We're using the second Buttons block with Multiple choice option enabled and we're saving the user's answer in the variable @sandwiches:

  1. We need to create the variables @sandwich1_cost, @sandwich2_cost, @sandwich3_cost in the Number format and set the value to 0.

We will use these variables later in Formulas blocks to calculate the cost of each item.

  1. We use the Conditions block to check which options the user has selected. Note that you will need as many Conditions block as the number of options in the Buttons block.

We check if the variable @sandwiches contains the first option, which is "Sandwich 1".

It's very important to insert the name of the item in exactly the same way as it appears in the Buttons block.

There are two possible outputs:

- If the condition is NOT true, as you can see, the red line is connected to the next Conditions block to check if the variable @sandwiches contains the second option, which is "Sandwich 2".

- If the condition is true, this means that the user has selected this option, so we will follow the green line that leads to the Question: Number block.

  1. In the Question: Number block we're asking for the number of the selected item and saving the user's answer in the variable @sandwich1_amount.
  1. With the next Set a variable block we're setting the price of the first item ("Sandwich 1").

Make sure to create the variable @sandwich1_price in the Number format.

  1. Now that we have the amount and the price, we can calculate the cost of the item, and for that we will use Formulas block.

Where the formula is:

  1. From this point, the Formulas block is connected to the second Conditions block and exactly the same process is repeated for each available option.

Just confirm that you've created all the variables in the corresponding format and set the corresponding price to the items.

  1. Now that we've checked every option and we have the cost of each selected item, we can calculate the total cost.

We will use Formulas block, where we will sum up the cost of each item:

Where the formula is:


In this Formulas block, we're including all the variables where we calculated the cost of items.

That's why at the beginning of the flow we've set the value of the variables @sandwich1_cost, @sandwich2_cost and @sandwich3_cost to 0, so even if the user hasn't chosen any option, the formula will still work.

That's it! You can show the final result to the user:

You can just copy the flow and apply it to another category, but making sure that you've changed the name of every single variable.

How did we do?

Bricks Workarounds (ready to use)

How to set the flow according to Open/Closed Business Hours