Elasticsearch, DialogFlow, Botkit the three musketeers of developing a Chatbot.

0
97


OrderStack

Chatbots are now becoming a growing trend with all tech giants rolling out AI assistants like Google Assistant and Siri and many more like them, even startups are coming up with creative solutions for creating chatbots with just a simple ‘drag and drop’ similar to building websites using WordPress or WIX.

Me being a coder find in more in my control to create chatbots or websites through code as it gives me a lot of customizability and modularity over any system which I develop.

The startup I work at OrderStack, my best friend and I are working on developing a platform for restaurants, and we call it the OrderStack platform of which the chatbot is a part of. The chatbot we developed is for targeting customers on the Messenger Platform of Facebook, which skipped our major concern of a chat interface helping us to focus on the features of the chatbot.

Initially, you could order through what we called a ‘button flow’ or assisted flow, the button flow consisted of carousels and buttons used to display information to the user on Messenger which was provided by the Facebook Graph API. But the Graph API was a bit of a tedious task as the Facebook SDK in NodeJS was easy to handle sessions with multiple users and being an ‘API’ most of the HTTP request code was unreadable. (yes I mainly code in NodeJS sorry for the late mention).

This tedious task/obstacle led us to find.
Musketeer #3 -“Botkit”

Botkit or Botkit.ai is an open-source tool for building chatbots on multiple platforms like Slack, Messenger, etc. This library has all the abstracted functionality of the Graph API with a simple session and message management and means to code flow for the users by enabling ‘event-based’ handlers for all types of messages and situations. For example, getting control when the user clicks a button in the Messenger Chat or writes a keyword accordingly, an event gets triggered. Developing chatbots using such event-based libraries is the easiest way to understand and create flow for the user.

With Botkit in place we had achieved a seamless button flow for ordering food with categories and food items displayed using carousels and maintaining ‘orders’ of each user separately, all was well until we found the need of integrating a way for users to order by just typing in his/her order and picking up dish names from the messages directly. There was a simple solution to all of this, and it was ‘Natural Language Processing’ to make the system understand what the user is ordering. We went through many NLP clients like wit.ai, luis.ai, and many more.

Finally, after researching for NLP clients we found.
Musketeer #2 — “DialogFlow

It is a Google-backed cloud API for conversational interfaces powered by Google’s machine learning and Cloud Platform. It allows connecting with users on your website, mobile app, the Google Assistant, Amazon Alexa, Facebook Messenger, and other popular platforms and devices.

It has three major things ‘agents’, ‘intents,’ and ‘entities’. Agents are nothing but Natural Language Understanding modules the can be used by a system using their SDK like where we use it in our chatbot alongside Botkit.

The next comes ‘Intents’, they are nothing but the mapping between what the user says through a message, and it informs the system about what action is to be taken. For example, we created an intent called ‘OrderFood’ we gave training phrases like “I want <- certain_dish_name ->” or “I would like to have a <- certain_dish_name ->” and the agent got trained accordingly for this intent and it helped us catch similar phrases when written by the user on our chatbot.

And the last part ‘Entities’ are a powerful tool used for extracting parameters from natural language inputs. The intent had phrases we trained the DialogFlow agent to find out what could be a dish name in a given sentence or phrase which helped us retrieve the dish name when the appropriate intent would match. So the response we would get from DialogFlow after feeding it the user’s input was which intent had been matched and what dish name is found in the phrase. This, in turn, helped in achieving Ordering by just typing in the order.

The next comes ‘Intents’, they are nothing but the mapping between what the user says through a message, and it informs the system about what action is to be taken. For example, we created an intent called ‘OrderFood’ we gave training phrases like “I want <- certain_dish_name ->” or “I would like to have a <- certain_dish_name ->” and the agent got trained accordingly for this intent and it helped us catch similar phrases when written by the user on our chatbot.

And the last part ‘Entities’ are powerful tools used for extracting parameters from natural language inputs. The intent had phrases we trained the DialogFlow agent to find out what could be a dish name in a given sentence or phrase which helped us retrieve the dish name when the appropriate intent would match. So the response we would get from DialogFlow after feeding it the user’s input was which intent had been matched and what dish name is found in the phrase. This, in turn, helped in achieving Ordering by just typing in the order.

The dish name extraction from the phrase or sentence written from the user-led to another problem, what if the user doesn’t type in the dish name correctly or makes a spelling mistake or orders a dish that is not served by the restaurant. Dialogflow just returned the string or the gibberish string which it thought was the dish name.

This led us to find another musketeer which could tackle this simple problem and with that we introduce.

Musketeer #1- “Elasticsearch

Elasticsearch is a search engine based on Lucene (an open-source retrieval software library by Apache) it has a distributed multitenant-capable full-text search engine with an HTTP web interface.

Now you might have the question of how does a text-based search engine helps us. Here the wildcard is we connected our database with all the menu and dish names in it with elasticsearch. Now elasticsearch helped us in querying the database using ‘gibberish’ or ‘misspelled’ dish names which we retrieved from dialogflow and returned us a match using fuzzy matching and a score on how close it is a dish name to the input dish name. This helped us sort out misspelled dish names and dish names which were not available faster as elasticsearch gave speedy query results.

This, in turn, helped us complete the 2 significant parts of our chatbot the ‘button flow’ and ‘NLP flow’ of ordering and the development time that it took was reduced because we had had help from the three musketeers which guided us to achieve developing a chatbot for our OrderStack Platform and deploying it faster and efficiently.

This, in turn, helped us complete the 2 significant parts of our chatbot the ‘button flow’ and ‘NLP flow’ of ordering and the development time that it took was reduced because we had had help from the three musketeers which guided us to achieve developing a chatbot for our OrderStack Platform and deploying it faster and efficiently.

This is our opinion when I say these are the three musketeers of chatbot development which go hand in hand and complement each other perfectly. We might incline more towards these three because we have used these for a long time now without any hiccups and we think they make a perfect trio for developing a chatbot. Thanks for reading, have a nice day. Keep Coding!



Read More

LEAVE A REPLY

Please enter your comment!
Please enter your name here