Create a bot on Aimylogic to automate an online store

  • Tutorial


About the automation of communication with customers today does not write just lazy. But how to start using it in practice is rarely talked about.

We at Just AI understand that automation is a trend, and we know how it can help your small and large business. And today we decided to write a fascinating tutorial about how using Google tables and the Aimylogic bot designer you can easily and without programming automate the first line of communication with your customers to get real benefits from this, and not just create another useless chat bot.

Ready template


We have prepared a bot template in our Aimylogic designer , so that you can create it in one click and study its work in practice. It is called “Online Orders” and is located in the Templates section of the main page in your Aimylogic account.



Further in the article we talk about the process of its creation.

Online store operation scheme


Consider a typical online store. A client visits the site or a group of VKontakte. In an online chat, find out from a consultant the availability and prices of goods. And, if everything suits, writes the delivery address. The consultant initiates a new order and issues its number to the client. Then the customer can return and ask about the status of the order, simply specifying its number.

If there are many clients, consultants may not have time to respond to typical requests. And this is bad for business - the customer will simply go to another store. If you hire more consultants, these are extra costs.

Google spreadsheets as a database


In our case, we will store the database of goods and a list of orders in plates on Google Drive , and our bot will be able to receive information from it and automatically issue it to the client.


Of course, you can use any other tool instead of tables, but in this tutorial we have chosen this option as the most simple and visual, and at the same time - applicable in practice. Many small online stores run on Excel, without the use of additional CMS.

Now, when receiving a question from a client, the consultant simply enters the tablet, looks at the availability of the product and the price and gives the answer to the chat. If the client wants to order, the consultant asks for the delivery address, goes to the second sheet in the table and adds a new line of this type.



When the client then asks for status, the consultant finds out the order number from him, goes to the second sheet in the plate, finds the status by number and issues to the client.
We are now automating these processes with you.

We classify customer requests


Before we start designing a bot in Aimylogic, let's decide what our clients are writing in a chat with consultants.

Most people in the chat ask:

  1. How much do iPhones / iPads / MacBooks?
  2. I want to buy
  3. And where is my order?

From this we see that our bot should be able to operate with the names of our products, and not always written the same way as in our table. For example, “ai background”, not “iphone”.

Creating a bot on Aimylogic


Creating a bot in Aimylogic is similar to creating a site in any site builder. Only with the exception that we are designing not a static site, but a dynamic dialogue with the client.



The bot in Aimylogic is a sequence of screens on which the bot navigates with the help of connectors (arrows, which connect cards with blocks). And the block is the actual action that the bot performs on each screen. You can branch , process user requests , make HTTP calls, and so on.

Create a database of goods


Our bot must understand when customers ask him about prices and availability of goods from our database. And he should understand both the English iphone and the Russian spelling, taking into account the morphology. Aimylogic is able to - called Entities . In the menu, click on Entities , create an entity item and hammer in the names of products with synonyms.



Here it is important one thing - that the name in the column Essence coincides with what is written in our tablet . Then see why.

We publish a table of goods


In order for a bot to know availability and prices, as well as order statuses, it’s necessary that Google spreadsheets be published. Then we “feed” her bot in a special way.

To publish a Google spreadsheet, open the menu File - Publish to Web (File - Publish to the web). A window will open in which you just need to click on the Publish button .



Anything more is not necessary. We return to the editor of the bot Aimylogic.

Construct a dialogue


Now, in fact, we will create a dialogue dialogue with the client so that the bot can answer questions about the current price of the product, report its availability, ask for the delivery address, and report the order status by its number.

As mentioned earlier, a bot in Aimylogic is a sequence of screens. When you enter the script editor bot immediately opens a palette of blocks of the first screen. On the first screen we place a block of phrases that the bot expects from the user. Click on the Phrases, a window opens in which you need to specify sample phrases and break them into groups according to the subject of the request.



Where the user can ask something about the product, specify a link to our $ item entity . For example, “How much is $ item” . Since Aimylogic works onmachine learning algorithms , our bot will understand all the synonymous customer expressions and automatically save the product identifier in the $ item variable.

It is also necessary to tick the “Global block” in order for the bot to respond to the specified phrases on all screens.

We read data from Google tables


Next comes the fun part. When a customer says “How much do iPhones today?” Or “Are there any MacBooks available?” , The bot should get the product data from Google tables and tell the customer if they are available and what is the price today.

Aimylogic bots can make HTTP requests directly along the script using the HTTP request block . But in order to work with data conveniently, it is necessary that the service on that side returns simple JSON , and not a table.

To do this, you can use the following URL: If you open such a URL in a browser, you will see an array of JSON objects with fields like in your table. And this can be used in the bot script. Instead of document id

http://tools.aimylogic.com/api/googlesheet2json?sheet=1&id=идентификатордокумента

you just need to substitute the identifier of your Google table. To find it, open your google-table in your browser and look in the address bar.



This sequence of characters is the identifier. The result should be a URL like this:

http://tools.aimylogic.com/api/googlesheet2json?sheet=1&id=1ydRCih3-el3dJFl4pBDjf717rfFWaTpB9qulkWw43TA

Now that we have turned the table into JSON, we can teach the bot to work with it. Click on the group of phrases on the first screen (for example, on “how much $ item” costs ) - a second screen will be created. On it, add an HTTP request block with these parameters:



Paste the URL we received earlier. And on the Response tab, create a variable named device. This is, in fact, the variable where the bot saves the product data that it pulls out from the table. As the value of the variable, specify a simple Javascript code.

_.findWhere($httpResponse, {"name": $item})

Here we teach the bot to pull an object from the server response ( $ httpResponse ), whose name field matches what the client asked for. Aimylogic out of the box works with the underscorejs library , so we use its findWhere function to pull the right product into one line.

Available, want to buy?


Now the bot has pulled the product data into the $ device variable at the user's request. Moreover, the client can write at least “iPads”, even “iPhones” - the bot will understand everything. Now you need to teach the bot to tell the customer whether this product is in stock, announce its price and offer to order.

Each product has an instock field , which is either true or not. This is the same tick in the google-tablet that the consultant removes when this product is not available. Therefore, the bot should look at this box and, if it is true, offer to buy, and if not, then say that such product is temporarily out of stock.

Click on Completed Successfully in a block with an HTTP request. This will create the next bot screen to which you need to add a block.. Using this block in Aimylogic, you can arrange the branching of the dialogue, depending on various conditions.



Each condition is essentially a Javascript expression that is either true or false. If true, then the branch of the dialogue that comes from this condition will work. If not, the bot will proceed to check the next condition and so on. If no condition is true, then the else branch will be executed.



On the screen with the $ device.instock branch (goods in stock), we show the client the text



And add a block Phrases



Ask for shipping address


If the client says something like “Yes”, the bot must ask where to deliver the order. Click on the group of “yes” phrases in the created block and add a block. Entering Text



On this screen, the bot will ask a question and save all user input into the variable address . After that, you need to thank the client and send an alert to the consultant that someone wants to buy an iphone. The consultant will double-check availability, will get a new order in the plate, go to VKontakte and inform the customer of the order number in a personal message.

Click on Transition after entering $ address and add a Text block.



How to notify a consultant
Чтобы бот мог оповестить консультанта, можно использовать сервис ifttt.com, на котором можно сделать вебхук и заставить его нотифицировать кого-то, например, в Телеграме. Таким образом можно создать аплет, который по вебхуку будет посылать нотификацию в чат Телеграма. В боте нужно будет просто добавить еще один HTTP запрос к адресу вебхука. О том, как все это сделать, мы написали в нашем справочном центре.

Connect the bot to VKontakte


So, the first version is ready! Bot can check availability and take orders. You can test in the Aimylogic editor interface, after which you need to connect the bot to the VKontakte group. This is done simply . The VK widget can also be placed on the site so that visitors to your site can immediately write to the bot in the chat window.

After this, the bot will start doing what we have created for it - it will relieve the main load in chat rooms , bringing to the consultant only customers who are ready to buy our goods.

Check order status


A branch with status checking is essentially no different from a branch with order creation. Since we store our orders on the second sheet in the table, the HTTP bot request to the table will be slightly different:

http://tools.aimylogic.com/api/googlesheet2json?sheet=2&id=1ydRCih3-el3dJFl4pBDjf717rfFWaTpB9qulkWw43TA

we are in the way we are, we are in the way we are, we are in the way we are, we are, we are, we are, we are in the order, and we’ve saved them in the table. 2 (second sheet). Well, the response processing also looks a little different:

_.findWhere($httpResponse, {"order": $number})

Here we are looking for an order, the number of which coincides with the one that the client indicated in the previous step of the scenario in the Enter Number box.



Eventually


You can still use Google tables as a database for storing products and orders, and the bot created on Aimylogic can use it to respond to requests from our customers in the VKontakte group and on the website.

Entities in Aimylogic allow the bot to understand the names of the products, taking into account the morphology. The HTTP request block is a great way to integrate a bot with anything that can produce JSON (or XML). A service tools.aimylogic.com just allowed to turn the table on Google Drive into an array of JSON objects.

Automation in our example solves a very specific problem and, most importantly, does not lead to the fact that customers leave the site where the bot is trying to completely replace the person, but in the end can not do anything. Here automation, on the contrary, helps to make business more efficient.

In this article, we looked at how to integrate with regular Google tables. But now we are working on integrating Aimylogic with existing CMS systems for e-commerce and in the future we will add new templates for online stores.

We remind you that you can create a finished bot on aimylogic.com in one click from a template called “Online orders” .

→ A site with a test bot is here
→ A plate with goods and orders is here
→ Full documentation on the Aimylogic designer and new tutorials can be found here

Also popular now: