Chatbots is a term in information technology that is getting more and more popular lately. There is a lot of talking about it, but what chatbots are? What possibilities do they offer? How do they work and how complicated is creating a chatbot?

I will try to answer these questions by using an example of AutomatedCheckin, which we are building in SoftwareHut to automate the process of check-in.

Why are chatbots such a significant opportunity?

Let’s start from the beginning – what is a chatbot? Typically it’s a service which is implementing specific communication rules or artificial intelligence to create as natural as possible interaction with a user through text or voice messages. Today such services are often integrated with the most popular internet communicators. We use Facebook Messenger every day to talk with our acquaintances and family, and such services as Skype or Slack for communication with associates or business partners. Because of that, the interaction based on short messages is natural and straightforward to us.

And if that’s so, why not to use well-known to us communication channels as an interface for our application? Thinking logically, we should build our application in a way in which they will be available to as big as a possible group of people and using the most popular communicators allows that.

Undoubtedly, one of the benefits of chatbots is the fact that user doesn’t have to learn how to use complicated interface and to register or log in anywhere. But from the software developer’s perspective, they can deliver such solutions much faster than in a case of traditional applications.

How do chatbots work?

We can highlight two main types of chatbots – the first one is based on a set of rules defined by a programmer, and the other one uses artificial intelligence to detect user’s intentions and collect essential data.

Chatbots based on a set of rules:

  • Communication is based on a defined group of commands, and user needs to enter them correctly to be understood by a programme
  • When answering, user needs to limit himself to single words or to choose one or many options from those given
  • Fixed conversation scenario
  • Bot is as intelligent as it was programmed

Chatbots using artificial intelligence:

  • We don’t have to use commands; we can write naturally, by using even use complex sentences. Bot should classify our statement accurately and assign a correct intention to it
  • Bot can learn, so the more we use it, the better it will be in understanding us

Those are two basic types of bots. I will show you by the example of our AutomatedCheckin that it is possible to connect them to realise established conversation scenarios.

Microsoft Cognitive Services – LUIS

Won’t it be too complicated, if we want to use artificial intelligence to create our bot? Do we have to program and teach our neural networks on our own? Fortunately not! Undoubtedly, an understanding of such issues as machine learning will help us in creating our intelligent bot, but we don’t have to be specialists in that area.

Many companies offer features of artificial intelligence in the form of internet services. Microsoft made a great example of such an organisation by sharing a group of services using artificial intelligence under the name of Project Oxford in 2015. Nowadays it’s called Cognitive Services.

One of those services is a LUIS (Language Understanding Intelligence Service), which allows for classification of text data. It’s beneficial in programming chatbots. That service is available to everyone. All you need to do is to visit www.luis.ai and log in using your Microsoft account. After that, you will see an empty list of applications and a few options to choose from.

cognitive-services-apps

The first step in creating new bot is to build a new application. After clicking “New App” button, we will see a simple form with a few fields to fill.

new-app-button

To create a new application, we need to give its name and a language in which a user will communicate with a bot. We can choose from a dozen or so languages, and a list is continually being updated. Now it’s a time to go to the configuration of the brand-new application, where we can choose from a few options.

travelbot-dashboard

We will begin from the “Intents” tab. It contains a collection of basic objects designed to classify statements given by a user. Most often, an intention defines a particular, single action. In a case of our  AutomatedCheckin, a few intentions are determined, e.g. online check-in and cancellation or modification of reservation. Let’s try to add a new intention in response to user’s clamour to check-in online. To do that, enter “Intents” tab and click “Add intent” button. Then you should enter a name.

In the next step, we have to define what sample statements may a user use in case of a willingness to check-in online. A collection of that statements will automatically become a training collection for a neural network, which will allow for classification. Of course, the more sample sentences we enter, the better our algorithm become.

ulterances

Reading intentions is a crucial feature, but by using Cognitive Services, we can achieve much more. Searching sentences entered by a user for essential data like a reservation number would be very helpful. And it’s what “entities” are for. Service allows for recognition of different kinds of elements in sentences like numbers, emails, URL addresses or geographic data. We can also define own elements.

In a case of our bot, searching for a reservation number needed for an online check-in will be helpful. To achieve that effect, we need to go to “entities” tab in the main menu and create a new entity. Let’s call it ReservationNumber. Now we need to indicate in which places algorithm has to look for a reservation number. So let’s return to “intents” menu and in sample sentences, let’s mark spots, in which a user potentially may give his reservation number.

reservation-number

To increase a possibility of correct recognition of an intention, there is an option to define a list of keywords and regular expression, which will be used in a process of classification. In our case, we can define a pattern of a reservation number. Passenger Name Record (PNR) is usually a 6-digit (sometimes 5-digit) code, which uses big letters and digits, and it’s being applied by every airline. We can define that information, helpful for our algorithm in a form of regular expression, by going to a “Features” tab in the main menu.

add-pattern

The last step is to train algorithm on the grounds of data, which we defined previously. So let’s enter “Train & Test” tab in the main menu, and click “Train Application” button. After training, we can test our application. All we have to do is to enter any sentence in a text field, in which we will define, what we want to execute. We don’t have to use the same sentences as from a test collection. On the screen below, we can see that for a text “i want to checkin online for my reservation number awd148”, algorithm matched an intention correctly.

interactive-testing

Now, our service is ready. We can use it after entering the unique address, generated especially for our application after publishing it in “Publish app” tab. We can refer to the application by entering a text to proceed in a parameter. In response, we will receive an object in JSON format. For a sample request above, a response from a service looks like that:

Read Part 2 about programming this bot here.

Fresh software development tips delivered straight to your inbox

Subscribe to our monthly newsletter with useful information about building valuable software products.
Don't worry, we value your privacy and won't spam you with any bussines enquiries!

mariusz_dobrowolski

Software Developer

Programmer and new technologies enthusiast, who will not shun from any programming language. Professionally, for five years connected with the .NET platform. Seeker of innovative and creative solutions.

Multiple finalist of nationwide IT competitions, therein a two-time winner of the world’s largest technology contest for students - ImagineCup.