Lesson 8: Create a chatbot calculator & Track order status

Estimated reading time: 15 minutes

After shopping online, your customers need to check the clothing order status. In the previous lessons, you have created a chatbot for "Monoco Shop" to help customers order clothing items, today's lesson will show you how to extend the chatbot's functionality to bring better shopping experiences to your customers.

In this article, you will learn how to:

  • Use Variable to calculate the BMI to help your customers find the suitable clothing size

  • Use powerful Scripting Block to support your customers to track their clothing order status

Note: You will need a little bit of technical background for this lesson to use Scripting Block.

Create a chatbot calculator

Set Variables

In this lesson, you will learn how to make BMI calculations to help your customers find the exact clothing size when shopping online through Monoco Shop chatbot. It is possible to perform basic mathematical calculations in your bot just using Variables.

Find out how to make calculations for "Monoco Shop" by setting Variables as shown below:

1. Create a block to ask your customers information related to weight and height

Enable Expect User Response. Please keep in mind that you must set up the answer format is Number in Response Validation, so your customers will enter the correct format. After that, you can do the same with Height and BMI.

2. Go to Data panel and create a Variable.

Create the Variable as "Weight", "Height" and "BMI", don't forget to choose a Variable in the format of Number for Data Type. Keep in mind that the initial value will be altered as you build the calculation in your bot.

Perform basic calculations

After creating a Variable, now you will learn how to perform a calculation for Monoco Shop chatbot. Follow these steps below:

1. Drag and drop action Update Variables and configure this action. Then do the same steps for Height and BMI.

2. Insert operators to perform calculations (add, subtract, multiply, divide) to calculate BMI.

3. To show the final result on your bot, don’t forget to insert the Variable you have created/ altered in a new block, like in a Text Block to display the BMI of your customers.

Great job! In case you want to filter the conditions to make suggestions for clothes size to each customer, use connector conditions.

And filter based on the conditions as you expect

Test result

After following these steps above, check out a bot flow performing these calculations:

Great! Now you can test on Preview to see the result of the BMI calculation.

For more information, please visit Variable System

Track order status

After buying the clothes at Monoco Shop, your customers might want to check order status. In this part, you will learn how to use a powerful tool as Scripting Block to support your customers.

To use scripting block, it requires you some technical background. In this lesson, in order to track order status, you can use:

  • Run Script to generate the order code
  • Scripting to execute complex code to get data from Google Sheet

Before starting, you need to prepare a Google Sheet (or it can be any service of data storage). Please find this Track Order Status Google Sheet.

Generate order code

Follow step-by-step instructions to generate an order code:

1. Drag and drop Run Script into the flow.

2. Click on Open Code Editor.

3. View the code as shown below. Please check out the code at Generate code.

4. Test on Preview.

Get data from Google Sheet

After generating the code, now you can use this code to check order status after shopping online. In the previous step, you have prepared a Google Sheet.

Now, if your customers want to track their order status, you can use Scripting Block to execute complex code to get data from Google Sheet. Follow these steps as shown below:

1. Drag and drop Scripting Block into the Flow Editor.

2. Do programming directly within this Scripting Block. Click on "Open Code Editor" to view the code for tracking order status. Please check out the code at Checking order status code.

3. Test on Preview.

For more information, please visit Scripting and JSON Formats.

Preview chatbot

Congratulations! This is the end of Mini-Course, let's review the chatbot flow for "Monoco Fashion Shop" as shown below, please keep in mind that everything you have learned in these lessons can be applied in any business:

Thank you so much for your participation in our Mini-Course with BotStar and for being a part of the chatbot community. I truly hope that you enjoy this course and it helps you become a better chatbot creator. If you want to communicate and interact with other platform users, please join our BotStar Chatbot Community.

I hope you can give me an honest review after this course and please let me know if there are any ways I can do to improve this course to make it become a better Mini-Course for chatbot creator like you.

Wish you all the best! 🎉


Did you find it helpful?   Yes   No