If you are reading this, chances are high you have spoken to a bot.
Yup, you who is reading this. You. Have. Spoken. To. A. Bot.
Before you go all Terminator on us and close this window and scroll away to another chatbot story that you found interesting out there on Google, bear with us.
Chatbots are those interesting little guys who occupy a corner of your screen, usually the bottom right (don’t look, we don’t have a chatbot, yet) and help you with a question that you need an answer to.
Questions like:
The chatbot may have some trouble with the last question. Moving on.
Chatbots represent a form of marketing called Conversational marketing, which has been around for as long as we can all remember.
When you used to walk into a store maybe a decade ago and ask a salesperson about the right kind of vacuum cleaner for your house, that was Conversational marketing.
Ever picked up a phone and spoken to a company rep who explained to you why the “Toastmaster 5000” will solve all your breakfast problems? Yup, that’s conversational marketing too.
Chatbots are just taking those conversations to a whole another level. And they seem to be working too. This Gartner report says that 85% of all customer interactions will be managed without humans as soon as 2021.
Add to this other interesting Chatbot statistics such as:
We now know chatbots are cool, and that they can lead us to some serious moolah, but we need to brush up on a few basics before we get down and dirty building one.
Chatbots are cool. You get it. But should you actually invest your time and money in building a chatbot, and, if yes, what framework should you choose?
To answer these questions, we turn to Master Shifu from Kung Fu Panda, who said something along the lines of
Figure out what problem you and your website are trying to solve, and if a chatbot will help the customer in his user journey.
Start by asking yourself these simple questions:
If your answer is YES to most of the questions above, a chatbot is a must for your business.
We will now look at the structure of a chatbot, telling you important definitions that you need to learn if you wish to move past the “Chatbot- Noob” stage.
A chatbot usually consists of 3 components: A messaging platform, a Natural Language Processing Engine, and a Database.
We won’t get into the nitty-gritty details here, since we can’t wait to show you how we built a Chatbot using Rasa, but here is a graphic we found online that will give you a better idea.
Now you need to remember three key chatbot terms before we move further
The intent of the user would be book_flight.
Hre the entities would be: from_city: Los Angeles
to_city: New York
Think of stories as to how you would like the conversation to flow. Different responses you give to the chatbot will have different replies. You are telling the chatbot the various combinations that are possible in the conversation.
Think of it as teaching sentence formation to a seven-year-old You need to train the chatbot on all the possible responses a user can give.
Once you have mastered these basics, you are now ready to build a chatbot on your own. Let us see how that pans out:
Step 1: First, we’ll install python 3.
Step 2: Create and activate the virtual environment using the below commands.
Step 3: Install Rasa open-source with the below command. If you are facing any issues, you can explore the documentation.
Once the packages installation is done, let’s create the project directory.
mkdir v-assistant
cd v-assistant
Simple so far? Now things get a bit more interesting.
Create the new project with rasa init-no-prompt command.
Once the project is created, you will see below logs in the terminal.
The rasa initcommand creates all the files that a Rasa project needs and trains a simple bot on some sample data.
You can play around with this data to get the hang of things. Remember training a seven-year-old that we mentioned earlier? Follow the same principle.
This creates the following files:
Let’s interact with the sample bot to see if the execute rasa shell command from the terminal is working.
As you can see, we can interact with the sample data.
Now let’s see how we can make the bot more interactive, for which we need… drumroll…stories!
We have told you what stories are before, but we are going a bit technical here for people with some coding background who like big technical words.
A story is a representation of a conversation between a user and an AI assistant, converted into a specific format where user inputs are expressed as corresponding intents and entities ( where necessary ), while the responses of an assistant are expressed as corresponding action names.
We’ll first add intent, then it’s the corresponding action, and finally, we’ll train our bot to do what we asked it to do. Hell Yeah!
Let’s say we want a chatbot to speak a name when the user asks the name of our chatbot. So we’ll add intent for that in the intent.md file.
Here ‘##intent’ defines the intent e.g.- ##intent:welcome, ##intent:name. Also, we have to register the intent in our domain.yml file in the intents section, as shown below.
After the intent, we’ll define the action for that intent in the same file under the responses section.
Now that you have defined the action, we have to register that action in the same domain file under the actions section.
After adding the appropriate action and intent, we’ll define the story in stories.md file.
Now, as our NLU data and stories are ready, it is time to train the bot.
We can do this with rasa traincommand in the terminal.
After execution run the command rasa shellfor interaction.
As you can see, the bot will utter its name when the user asks for it. The action which we have added is utterance action, which starts with utter_ and sends a specific message to the user.
Rasa has provided more information about the action here-
This way, you can add N number of intents, actions and make more user stories.
We still need to build the dialogues and stories with some custom actions, entities, and slots so that bot can respond to the messages.
As a bonus point, we can integrate it with different channels and web applications.
I would recommend going through each section step by step and reading the Rasa Documentation to understand it better.
This is just grazing the surface of building Chatbots, and if you want to go deep, we would recommend you to compare frameworks like Rasa in this post and choose one that you like.
Once you pick a framework, the world is your chatbot’s oyster, and you can program it to help out any customer that comes to your site, except maybe the shoddy character with a dead body that we mentioned in the beginning.
You can also take your chatbots to the next level by asking your chatbot to send meaningful data to a third party API and then perform an action in that system.
For instance, you can connect your chatbot to Salesforce and ask your visitor for his basic information like name and email. If the person has interacted with your business before, you can provide him a personalized user journey by doing away with the initial questions. The possibilities are limitless!!
Now that you know why chatbots are important and how to build a chatbot using Rasa, we feel it is time to pick up that lightsaber, young Skywalker. If, at any point, you feel stuck or want to build a bot for your business, send us a shoutout here at SoluteLabs.
Have a product idea?
Talk to our experts to see how you can turn it
into an engaging, sustainable digital product.