
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 starts a new order and issues its number to the client. Then the customer can come back and ask about the status of the order, simply by 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 work 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 an 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 about the status, the consultant will find out the order number from him, go to the second sheet on the plate, find the status by number and give it 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:
- How much do iPhones / iPads / MacBooks?
- I want to buy
- 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 table, 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 entering the bot script editor, the block palette of the first screen opens immediately. 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 examples of phrases and divide them into groups according to the subject of the request.

Where a user can ask something about a product, we indicate a link to our
$ item entity. For example,
“How much is $ item” . Since Aimylogic works on
machine learning algorithms , our bot will understand all the synonymous customer expressions and automatically store 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 client says
“How much do iPhones today?” Or
“Are there any MacBooks available?” , The bot should get data on the product from Google spreadsheets 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 this URL:
http://tools.aimylogic.com/api/googlesheet2json?sheet=1&id=
If this URL is opened in the browser, then you will see an array of JSON objects with fields, as in your table. And this can be used in the bot script. Instead of the
ID of the document, 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-el3dJFl4pBDjf717rfFWaTpB9qulkWw43TANow 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 the following parameters:

Paste the URL we received earlier. And on the
Response tab, create a variable called
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’s 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”, at least “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-plate, which 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
the Conditions 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 following 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 will show the customer the text

And add the 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 block that is created and add a text entry block.

On this screen, the bot will ask the question and save all user input to the
address variable. 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 recheck the availability, add a new order in the plate, enter VKontakte and notify 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 consultantSo that the bot could notify the consultant, you can use the
ifttt.com service, where you can make a
webhost and force it to
notify someone, for example, in the
Telegraph . In this way, you can create an applet that will send a notification via webhuk to the Telegram chat. In the bot, you just need to add another HTTP request to the webhook address. We wrote about how to do all this in
our help center .
Connect the bot to VKontakte
So, the first version is ready! Bot can check the 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 creating an order. 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-el3dJFl4pBDjf717rfFWaTpB9qulkWw43TAHere we simply replaced the sheet parameter with 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 answer 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 task 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” .
→ Site with test bot is
here→ Label with goods and orders -
here→ Full documentation on the Aimylogic designer and new tutorials can be found
here.