How to create Chatbot using RASA
Now a day every company switch in online and make their website and for providing best customer service from their products and they also want to avalable 24/7 for customer support .but the cost of day night support is very high so reduce the cost of company and provide 24/7hours customer respond use chatbot.
basiclly chatbot a robot who answer customer question beside on your bot training dataset.
so we have many option to create a chartbot using using some open source project of chatbot such as alexa,ibm watson,rasa and etc.
What is chatbot?
Why are chatbots important? Chatbot applications AI chatbot: Which chatbot application is right for you?
Recently, new tools designed to simplify the interaction between humans and computers have hit the market: Chatbots or Virtual Assistants. In banking, chatbots and virtual assistants are some of the industry’s newest tools designed to simplify the interaction between humans and computers.
What exactly is a chatbot?
A chatbot is an artificial intelligence (AI) software that can simulate a conversation (or a chat) with a user in natural language through messaging applications, websites, mobile apps or through the telephone.
Why are chatbots important?
A chatbot is often described as one of the most advanced and promising expressions of interaction between humans and machines. However, from a technological point of view, a chatbot only represents the natural evolution of a Question Answering system leveraging Natural Language Processing (NLP). Formulating responses to questions in natural language is one of the most typical Examples of Natural Language Processing applied in various enterprises’ end-use applications.
in this blog learn how to create a chatbot using rasa framework, and how to connect with our website or online server.and how to connect with different socialmedia platform.
What is RASA?
Rasa is an open source machine learning framework for building AI assistants and chatbots. Mostly you don’t need any programming language experience to work in Rasa. Although there is something called “Rasa Action Server” where you need to write code in Python, that mainly used to trigger External actions like Calling Google API or REST API etc.
Rasa has two main modules:
- Rasa NLU for understanding user messages
- Rasa Core for holding conversations and deciding what to do next
Note — Now Rasa NLU and Rasa Core source code are merged together.
where to download
Build better voice apps. Get more articles & interviews from voice technology experts at voicetechpodcast.com
Install Rasa
Ubuntu 16+, Mac OS and Windows 10 (Visual C++ Build tool)
Create a new virtual environment
Install Rasa Open Source
conda create -n rasa-app python=3.6
conda env list
conda activate rasa-app
pip3 install rasa
This page explains the basics of building an assistant with Rasa and shows the structure of a Rasa project. You can test it out right here without installing anything.
implimantation
- 1. Create a New Project
- 2. View Your NLU Training Data
- 3. Define Your Model Configuration
- 4. Write Your First Stories
- 5. Define a Domain
- 6. Train a Model
- 7. Test Your Assistant
- 8. Talk to Your Assistant
In this tutorial, you will build a simple, friendly assistant
The first step is to create a new Rasa project. To do this, run:
rasa init --no-prompt
The rasa init
command creates all the files that a Rasa project needs and trains a simple bot on some sample data. If you leave out the --no-prompt
flag you will be asked some questions about how you want your project to be set up.
This creates the following files:
__init__.py →
an empty file that helps python find your actions
actions.py →
code for your custom actions
config.yml
‘*’ →configuration of your NLU and Core models
credentials.yml →
details for connecting to other services
data/nlu.md
‘*’ →your NLU training data
data/stories.md
‘*’ →your stories
domain.yml
‘*’ →your assistant’s domain
endpoints.yml →
details for connecting to channels like fb messenger
models/<timestamp>.tar.gz →
your initial model
The most important files are marked with a ‘*’. You will learn about all of these in this tutorial.
2. View Your NLU Training Data
The first piece of a Rasa assistant is an NLU model. NLU stands for Natural Language Understanding, which means turning user messages into structured data. To do this with Rasa, you provide training examples that show how Rasa should understand user messages, and then train a model by showing it those examples.
Run the code cell below to see the NLU training data created by the rasa init
command:
cat data/nlu.md
run
The lines starting with ##
define the names of your intents
, which are groups of messages with the same meaning. Rasa’s job will be to predict the correct intent when your users send new, unseen messages to your assistant. You can find all the details of the data format in Training Data Format.
3. Define Your Model Configuration
The configuration file defines the NLU and Core components that your model will use. In this example, your NLU model will use the supervised_embeddings
pipeline. You can learn about the different NLU pipelines here.
Let’s take a look at your model configuration file.
cat config.yml
The language
and pipeline
keys specify how the NLU model should be built. The policies
key defines the policies that the Core model will use.
4. Write Your First Stories
At this stage, you will teach your assistant how to respond to your messages. This is called dialogue management, and is handled by your Core model.
Core models learn from real conversational data in the form of training “stories”. A story is a real conversation between a user and an assistant. Lines with intents and entities reflect the user’s input and action names show what the assistant should do in response.
Below is an example of a simple conversation. The user says hello, and the assistant says hello back. This is how it looks as a story:
## story1
* greet
- utter_greet
You can see the full details in Stories.
Lines that start with -
are actions taken by the assistant. In this tutorial, all of our actions are messages sent back to the user, like utter_greet
, but in general, an action can do anything, including calling an API and interacting with the outside world.
Run the command below to view the example stories inside the file data/stories.md
:
cat data/stories.md
5. Define a Domain
The next thing we need to do is define a Domain. The domain defines the universe your assistant lives in: what user inputs it should expect to get, what actions it should be able to predict, how to respond, and what information to store. The domain for our assistant is saved in a file called domain.yml
:
cat domain.yml
So what do the different parts mean?
intents →
things you expect users to say
actions
→things your assistant can do and say
responses
→response strings for the things your assistant can say
How does this fit together? Rasa Core’s job is to choose the right action to execute at each step of the conversation. In this case, our actions simply send a message to the user. These simple utterance actions are the actions
in the domain that start with utter_
. The assistant will respond with a message based on a response from the responses
section. See Custom Actions to build actions that do more than just send a message.
6. Train a Model
Anytime we add new NLU or Core data, or update the domain or configuration, we need to re-train a neural network on our example stories and NLU data. To do this, run the command below. This command will call the Rasa Core and NLU train functions and store the trained model into the models/
directory. The command will automatically only retrain the different model parts if something has changed in their data or configuration.
rasa trainecho "Finished training."
The rasa train
command will look for both NLU and Core data and will train a combined model.
7. Test Your Assistant
After you train a model, you always want to check that your assistant still behaves as you expect. In Rasa Open Source, you use end-to-end tests defined in your tests/
directory to run through test conversations that ensure both NLU and Core make correct predictions.
rasa testecho "Finished running tests."
See Testing Your Assistant to learn more about how to evaluate your model as you improve it.
8. Talk to Your Assistant
Congratulations! 🚀 You just built an assistant powered entirely by machine learning.
The next step is to try it out! If you’re following this tutorial on your local machine, start talking to your assistant by running:
rasa shell
How to build Custom Frontend for Chatbot
You can build a Chatbot GUI using HTML5 and CSS3.
<html>
<head>
<meta charset="UTF-8">
<title>Hello World</title>
</head>
<body>
<h1>Hello World!</h1>
<--// this is chatbot design which is use in your website --><div id="webchat"/>
<script src="https://storage.googleapis.com/mrbot-cdn/webchat-latest.js"></script>
<--// Or you can replace latest with a specific version -->
<script>
WebChat.default.init({
selector: "#webchat",
customData: {"language": "en"}, // arbitrary custom data. Stay minimal as this will be added to the socket
socketUrl: "http://localhost:5005",
socketPath: "/socket.io/",
title: "shahil chatbot",
subtitle: "first robot",
})
</script>
//########################################
</body>
</html>
As we are heading towards building production-grade Rasa Chatbot setup, the first thing we can simply use the following command to start Rasa.
rasa run
concluaion
So we know the importance of chatbot and now we create the own chatbot in easyway with help of RASA project.
you can add the HTML code and script in your own running website and use it.you can also find code in github