Daniil Ekzarian
Dec 4, 2018 · 4 min read

Last week I took part in an internal Hackathon with our team. We made a chatbot assistant, that helps solve your everyday tasks. I want to share some of our experiences with RASA — an NLU framework we used to create our chatbot.

Photo by Dominik Scythe on Unsplash

Nowadays a new category of interfaces arise. You can see how voice assistant are rising in popularity among all generations (13% of all households in the United States owned a smart speaker in 2017, per OC&C Strategy Consultants, that number is predicted to rise to 55% by 2022). In a few years Alexa or Google Home devices will perhaps be in every house.

Communication with computers using natural language is the most convenient way for humans. Imagine a world where you don’t have to learn how to talk with your computer — instead, your computer learns how to understand what you’re saying.

Another big problem is knowledge sharing. No person could know everything, but your computer could at least try to. If we’ll give the knowledge to computers, they could help us to be even more productive. You may spend your time doing your job instead of searching for some knowledge, going through wiki pages and tons of documentation or looking for people, who know the answer.

So the goal of the Hackathon for our team was to create a chatbot intended to help with everyday tasks.

The core of the chatbot is the RASA framework. RASA is an open source framework made to build conversational UIs which can recognise natural languages.

There’re few major terms in RASA. First one is an intent, RASA needs to know what the user wants, so it should recognise their intent. Intent types can range from a simple greeting to multi-parameter requests. Following examples are contained in the domain.yml file of the RASA project.

Then we have entities. We should establish a communication with our chatbot, so he has to know specific terms we use in our speech. Examples are the user or team name, requested command, etc.

And we have slots, which are a representation of a chatbot’s memory. They contain what he knows at this moment. It’s all the data he’s already extracted from our conversation.

And actions, of course, the chatbot should do something, so these represent what he can do. It could be a simple text answer or an action which runs a request to 3rd party and responds with data from the server.

Templates are the simplest part of domain file. Templates describe the answers which the bot could use to respond with. Answers can be a plain text, an image or a button. utter_ask_team template demonstrates how to use buttons with a specified payload.

Let’s take a closer look at the payload section.

payload: '/wiki_help{"team": "Team1"}'
1 2

First part indicates that wiki_help intent will be triggered on a button click. Second part sets the slot “team” with a value of “Team1”.

One of the training phases is teaching our chatbot to recognise our intents. To do that we feed a lot of different phrase examples.

As you could see, they can be plain phrases or contain some labeled entities, so the chatbot can also learn how to extract entities.

For example,

Please [start](command) the service please.

‘start’ is recognised as command and will be put to a corresponding slot.

Now, what should we do with the user’s intents? If I’m greeting him, what should I answer? What if he already knows my name? What if some information was known prior to conversation? All these cases are handled by stories. Those contain conversation flows and are then fed to the chatbot model.

Example shows two conversation flows; first is triggered if a wiki_help intent was triggered with the team slot being filled, second is triggered if the slot is still empty. Notice that the slot could be filled either before the intent, or extracted from the same message.

Last part was to run some chat to test all the work we’ve made. RocketChat integration worked well for us. Note that you should load the latest version of packages, because the documentation offers to use packages that are no longer compatible with RocketChat python library.

To use the script, simply feed in your bot’s username/password and URL point of RocketChat server instance.

Reflash Programming Adventures

My adventures with programming

Daniil Ekzarian

Written by

Software engineer 👨‍💻 Functional programming disciple

Reflash Programming Adventures

My adventures with programming

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade