Creating a live chatbot for your website (Part 1): Setting up Rasa chatbot locally on your system | by Obianuju Okafor | Apr, 2021
Hello! This is the first part of a 3-part series involving creating and deploying a chatbot for your business or personal website using Docker and Heroku. The conversational AI platform I would be using is Rasa. Rasa is an open source machine learning framework that helps you create chatbots; it also happens to be my favorite chatbot platform for several reasons, such as it being open sourced, widely used and well documented.
In this post, I will be talking about how to setup Rasa locally on your computer. Although my OS is Windows, this entire process can be replicated for any system.
- Download Anaconda Prompt from here.
- Download Microsoft build tools here.
- Create a directory on your system where your would like to store your Rasa project.
Once all of that has been done, open the Anaconda Prompt application and ‘cd’ into the directory you created, mine is called ‘Rasa Project’.
Then run the following commands in Anaconda Prompt:
- Create a virtual environment using the command below.
conda create -n rasavirtualenv python=3.6
2. Activate your environment using the command
conda activate rasavirtualenv
3. Install Ujson
conda install ujson==1.35
4. Install Tensorflow
conda install tensorflow
5. Install Rasa Open Source.
pip install rasa
6. Create a new rasa project in your project directory
1. Chatbot Trends Report 2021
2. 4 DO’s and 3 DON’Ts for Training a Chatbot NLP Model
3. Concierge Bot: Handle Multiple Chatbots from One Chat Screen
4. An expert system: Conversational AI Vs Chatbots
Looking at the last part of the screen above, when asked to enter path you would like to create project, enter the period sign (.), this signifies that you would like to create project in the current directory. When asked if you would like to train model, you can either choose ‘y’ or ‘n’.
After the command above finishes executing and the new project has been created, you will be asked if you would like to speak with the chatbot in the terminal. If you answer yes, a dialogue will begin between you and the newly created chatbot.
Now that the project has been created, if you check your project directory, you will see that several files have been added to it. I will quickly discuss 3 files that I feel you need to understand their content; the file domain.yml in the main directory, and the files nlu.yml and stories.yml in the data folder.
The nlu.yml file is where all the training data is stored. The training data are sample messages that users can send to your chatbot. In this file, the messages are categorized according to intent. An excerpt from the file can be seen below. As you can see, intent : greet has several examples e.g. ‘hi’, ‘hello’, ‘hey’ etc. Intent: goodbye has examples ‘bye’, ‘goodbye’, ‘cu’ etc.
- intent: greet
— hello there
— good morning
— good evening
— hey there
— let’s go
— hey dude
— good afternoon
— Hi there- intent: goodbye
— good afternoon
— good by
— cee you later
— good night
— have a nice day
— see you around
— bye bye
— see you later
The domain.yml file defines the scope of your project. It contains salient information about your project, such as intents, entities, slots, actions, and most especially, the sample responses that the bot should send back to the user when it receives a message. Similar to nlu.yml, bot responses are categorized according to intent. For example, the response: utter_greet is sent whenever the bot wants to send back a greeting to the user. This is shown in the code segment below.
use_entities: trueentities: 
— text: Hey! How are you?
— text: Hi! How are you doing today?
— image: https://i.imgur.com/nGF1K8f.jpg
text: ‘Here is something to cheer you up:’
— text: Did that help you?
— text: Great, carry on!
— text: Bye
— text: I am a bot, powered by Rasa.actions: 
The stories.yml file brings the user’s messages and bot responses together. It creates a storyline or a plot of the several interactions that can occur between the bot and the user. It specifies what response the chatbot should give based on the intent of the message sent by the user. This helps teach the chatbot what to do in different scenarios. For example, looking at the code segment below, if the chatbot receives a message with intent ‘greet’, it has to perform the action which sends the response ‘utter_greet’ back to the user.
stories:- story: happy path
— intent: greet
— action: utter_greet
— intent: mood_great
— action: utter_happy
At this point your chatbot is only able to handle very basic and generic conversation. In order to fit your personal or business needs you need to make some changes to the default chatbot. You can do this by modifying the content of the nlu.yml, story.yml, domain.yml files mentioned above using a text editor. However, the best way to make these changes is through the platform Rasa X.
In the next part of this three part series, I will be talking about how to modify, train and test your chatbot using Rasa X. You can find the post here!
If you like this post, HIT Buy me a coffee! Thanks for reading.
Your contribution will encourage me to create more content like this.
Credit: Source link