Rasa Chatbot
Rasa Chatbot
Project report submitted in partial fulfillment of the requirement for the degree of
Bachelor of Technology
In
By
Nandini Ahuja
(181252)
to
I hereby declare that the work presented in this report entitled “ RASA-CHATBOT ” in partial fulfillment of the
requirements for the award of the degree of Bachelor of Technology in Computer Science and
Engineering/Information Technology submitted in the department of Computer Science & Engineering and Information
Technology, Jaypee University of Information Technology Waknaghat is an authentic record of my own work carried out
over a period from February 2022 to May 2022 under the supervision of Dr. Ravindara Bhatt (Assistant Professor) ,
Department of Computer Science and Information Technology).
The matter embodied in the report has not been submitted for the award of any other degree or diploma.
Nandini Ahuja
(181252)
This is to certify that the above statement made by the candidate is true to the best of my knowledge.
I would like to thank and express my gratitude to my Project supervisor Dr. Ravindara Bhatt for the
opportunity that he provided me with this wonderful project “RASA-CHATBOT”. The outcome would not
be possible without his guidance. This project taught me many new things and helped me to strengthen my
concepts of Machine Learning, AI. Next, I would like to express my special thanks to the Lab Assistant for
cordially contacting me and helping me in finishing this project within the specified time.
Lastly, I would like to thank my friends and parents for their help and support.
1) Abstract ..............................................................................................................6
2) Chapter 1-Introduction
1.1 Introduction .................................................................................................. 9
1.2 Problem Statement ........................................................................................13
1.3 Methodology ..................................................................................................14
1.3.1 Chatbot .................................................................................................. 15
1.3.2 Rasa ....................................................................................................... 18
1.3.3 Flask ...................................................................................................... 19
1.3.4 Chat Widget .......................................................................................... 19
1.4 Organization ...................................................................................................20
6) Chapter 5-Conclusions
5.1 Conclusion .......................................................................................................... 42
5.2 Future Work ................................................................................................................. 43
7) References ................................................................................................................. 44
LIST OF FIGURES
1.1 INTRODUCTION
Figure 1- Chatbot
A chatbot is a computer program that simulates human conversations or chat through AI. Artificial
Intelligence (AI) increasingly Integrates our daily lives with the creation and analysis of intelligent
software and hardware, called intelligent agents. Intelligent agents can do a variety of tasks ranging
7
sophisticated operations. A chatbots a typical example of an AI system and one of the most elementary
gram, which responds like a smart entity when conversed with through text or voice and understands
one or more human languages by Natural Language Processing (NLP).In the lexicon, a chatbot is
defined as “A computer program designed to simulate con-versation with human users, especially over
the Internet”. Chatbots are also known as smart bots, interactive agents, digital assistants, or artificial
conversation entities. Chatbots can mimic human conversation and entertain users but they are not
built only for this. They are useful in applications such as education, information retrieval, business,
and e-commerce. They became so popular because there are many advantages of chatbots for users
and developers too. Most implementations are platform-independent and instantly available to users
without needed installations. Contact to the chatbot is spread through a user’s social graph without
leaving the messaging app the chatbot lives in, which provides and guarantees the user’s identity.
Moreover, payment services are integrated into the messaging system and can be used safely and
reliably and a notification system re-engages inactive users. Chatbots are integrated with group
conversations or shared just like any other contact, while multiple conversations can be carried
forward in parallel. Knowledge in the use of one chatbot is easily transferred to the usage of other
chatbots, and there are limited data requirements. Communication reliability, fast and uncomplicated
development iterations, lack of version fragmentation, and limited design efforts for the interface are
8
How to set-up the environment
In ubunntu 18.04, these are steps to be followwed to setup the project env
Since the release of Rasa 1.0, the training of the NLU models became a lot easier with the new CLI. Train
the model by running:
9
Training the dialogue model
The biggest change in how Rasa Core model works is that custom action 'actions' now needs to run on a
separate server. That server has to be configured in a 'endpoints.yml' file. This is how to train and run the
dialogue management model:
10
Step 2: Run the Actions Server
rasa run actions
Step 4: Run the HTTP server for running website for chatbot.
The chatbot UI is provided in index.html forked from another repo is also placed for individual
learnings into chatbot frontend.
11
1.2 PROBLEMSTATEMENT
The coronavirus outbreak has serious consequences for the community around the world. People are
concerned and have many questions. The World Health Organization provides answers to the most
commonly asked questions about coronavirus on their website. However, you may need to take a moment to
find the right answer to your question. It is important that people are well aware of current trends. In this
way we can effectively reduce the spread of bulk. A chatbot can totally help with this.
12
1.3 METHODOLOGY
Software development methologies are te methods to manage project development. Many methodological
models are available. However , developer or users must know what to use and what not in every situation.
But keep in mind tht the project efficiency and know how to manage problems and avoid it maximum
times., by following this it also helps with our project goal and scope. To create a project, you need to
understand the needs of your stakeholders. A methodology is a system that includes the steps of
13
Four Phases of Spiral Model are:
1. Planning:
The stage where requirements are stored and risk management is assessed. During the section, we
discuss the title of the project with the project manager. Needs and risks were managed after litigation
2. Risk Analysis:
This is the phase in which risks and alternative solutions are identified. At the end of this phase, a
3. Engineering:
4. Evaluation:
In this, we perform software evaluation which is done after the system is shown and we test whether
our system meets the expectations and requirements. But if in case an error occurs, we can report the
14
1.3.1 Chatbot
Chatbot seems to have a great promise to provide us with fast and easy support that answers
directly to their following questions. The most common aim for chatbot users is to considered to
be more and more productive, while other aim for entertainment, social features, and interaction
with new features. However, to measure the motives mentioned above, a chatbot should be
constructed in such a way that it acts as a way, a game, and a buddy at the same time. Reduction
in customer service costs and the ability to handle multiple users at a given point of time which
will be some of the reasons why chatbots are so popular with business groups. Chatbots are no
longer seen as frinds or a source of help, and their method of communication draws them closer
to users as buddies.
Pattern matching is predicted in response respontftuse blocks. The line is entered, and the
result is generated according to the user input. The main drawback of this method is that the
results are predictable, repetitive, and unaffordable. Also, it usually have no storage for past
15
Natural Language Processing (NLP), an area of artificial intelligence, explores the
and use of human language is gathered to develop techniques that will make computers
understand and manipulate natural expressions to perform desired tasks. Most NLP techniques
Natural Language Understanding (NLU) is at the core of any NLP task. It is a technique to
implement natural user interfaces such as a chatbot. NLU aims to extract context and meanings
from natural language user inputs, which may be unstructured and respond appropriately
according to user intention. It identifies user intent and extracts domain-specific entities. More
specifically, an intent represents a map-ping between what a user says and what action should be
taken by the chatbot. Actions correspond to the steps the chatbot will take when specific intents
are triggered by user inputs and may have parameters for specifying detailed information about it
[28]. Intent detection is typically formulated as sentence classification in which single or multiple
16
1.3.2 RASA
understanding (NLU). Rasa provides a framework for developing AI chatbots that uses
natural language understanding (NLU). It also allows the user to train the model and
• Rasa stack is open source, ML framework for automated text and voice-based
conversations.
• Transparent, which means we know exactly what is happening under the hood
• It's one of the most effective and time efficient tool to build complex chatbots in
minutes.
17
1.3.3 Flask
Applications that use the Flask framework include Pinterest and LinkedIn.
It is a small and light weight Python web frame work that provides useful tools and
features that make creating web applications in Python easier. It gives developers
flexibility and is a more accessible framework for new developers since you can build a
web application quickly using only a single Python file.
A chat widget is a window on your website that allows visitors to have a conversation
with a sales or service rep in real-time. It usually pops-up in the bottom right corner of a
web page and prompts visitors to chat with a representative of the business. While most
chat widgets today are manned by live chat agents, chatbots are quickly becoming the
18
preferred choice for companies that need to scale their chat capabilities or offer 24/7
support.
Although it’s most commonly found on websites, alive chat widget can also be
integrated into social media pages and mobile apps.
Morethanhalfofallcustomerssaidtheypreferredtochatonlinewithacompanyinstead of using
other options such as email, phone support or social media. This is because unlike
otherchannels,chatwidgetsallowvisitorstoreachouttoacompanyatthetimetheyhave a
question, and get an immediate response.
1.4 ORGANIZATION
19
CHAPTER 2
LITERATURE SURVEY
1. AresearchpaperwaspublishedintheIFIPInternationalConferenceonArtificialIntelligenceApplications and
Innovations in May 2020 An Overview of Chatbot Technology. The authors of the Paper were Eleni
Adampoulou, Lefterismoussiades.
2. AresearchpaperwaspublishedinIJCRTnamedAnAnalyticalStudyandReviewofopenSourceChatbot
framework, RASA in June, 2020. The authors of the articles Manoj Joshi , Rakesh KumarSharma.
3. An article was in Hindawi named A Chatbot System. The author of the article are FilippoGandino.
20
2.2 PYTHON
2.2.1 Introduction
Python was founded by Guido van Rossum at Centrum Wiskunde& Informatica (CWI) within Europe
21
Python 3.9.2 and 3.8.8 have security issues with all versions of Python, which may cause remote code
22
2.3 WORKFLOW
2.4 Neo4j
2.4.1 Neo4j is the open-source Graph Database that is developed using Java technology. It is
highly scalable and schema-free (NoSQL). Unlike traditional databases which store data
in rows, columns, and tables, it has a completely flexible structure. Therefore, it saves
23
The architecture is for traversal of nodes and relationships, optimal management, and storage
Each node contains direct pointers to all the nodes that are connected by relationships.
2.4.2 Graph databases - A graph database is a database used to model the data in the form
of a graph. Here, the nodes of a graph depict the entities while the relationships depict the
2.4.3 Why graph database? - Nowadays, most of the data exists in the form of the
relationship between different objects, and more often, the relationship between the data
is more valuable than the data itself. Other databases even more recent node SQL types,
don't save relationships directly, they usually do a search through a separate data
structure called "index" which is expensive and makes the database slower, whereas
graph databases store relationships and connections as first-class entities. Also can easily
retrieve (traverse) connected data faster by indexing starting point and then just chasing
24
Cypher is a powerful declarative query language. It uses ASCII-art syntax.
It is easy to learn and can be used to create and retrieve relations between data without using
2.4.5 Use CASES:- To detect frauds, enhance AI, manage supply, unify silos, and many
more.
2.5 LIBRARIES
2.5.1 NumPy
NumPy means Numeric Python, a Python package for computing and process multidimensional and one-
dimensional array components. Travis Oliphant created the NumPy package in 2005 as well as the
25
This is a Python extension module written primarily in C. It has various functions that enable high-speed
numerical calculations. NumPy provides a variety of high performance data structures that implement
multidimensional arrays and matrices. These DS are used for optimal calculations on mathematics.
2.5.2 Pandas
PandasisdefinedinPythonasanopensourcelibrarythathaspowerfulinformationmanipulation.Thename of this
library comes from the term panel information, which implies economic science composed of two-
informationanalysisneedsaheapofprocesseslikez,python,pandasoon.However,Ilikepandasasaresult of their
Pandas are made on the NumPy package. In different words, NumPy is needed for the panda to figure.
Before pandas were introduced, Python was prepared for information however had restricted support for
information analysis. that is wherever pandas came in, increasing the potential for information analysis. no
matter the supply of the information, you'll perform the 5 key steps needed to method and analyze the
26
CHAPTER 3
SYSTEM DEVELOPMENT
27
3.1.2 Cases on date
28
3.2 REAL-TIME PROJECT
3.2.1 ADAMBOT - Adam AI chat server that will handle user queries and answer them accordingly.
Adam chat server handles the user queries using rasa, deep learning model and transformer
model. To process the request there are two services running on Chat Server and AI server.
Chat Server will be exposed to the outworld and will accepts the user requests. Out of the box it
User request will go through the Rasa model, and if Rasa does not predict the intent with good
confidence, same request will be processed through AI server that is trained on other 120
intents.
If deep learning model fails then response will be generated through the transformer model.
Project is built using Fast API server. Apis will be exposed to communicate with the server and
29
3.2.1.1 Rasa Model
We will be using rasa as python library and a model will be there to predict the intents.
User request will be served with Rasa model, if rasa predicts it correctly with more than
And if the query is an answer of previous opened slot, and as we are calculating the
confidence for each query then for slot answers like email of user can have low confidence.
For such cases we will avoid processing the request usin AI Server and will return the Rasa
response only.
Otherwise if low confidence or intent is out_of_scope then request will be processed using AI
server.
AI Server will handle the user query if Rasa model fails to predict the intent (that is if
*out_of_scope* is detected or the predicted confidence is lower than the set threshold value).
AI server will process the request using deep learning model that is trained with 120 intents
30
(different user queries) with the help of elmo and deep learning techniques.
If deep learning model fails to predict the intent corerctly then the request will be handled by
transformer model.
This is trained with all the user data, based on learnings it can generate the answer
Before passing the request to transformer model, toxicity of the question will be checked to
avoid the toxic answers. If request is not toxic then transformer model will process the user
question and will generate the manual answer. The answer will be checked for toxicity, if
31
3.2.1.4 Project Development
33
Figure 10 – AI Server
34
3.2.2 ADAM-ABSA
This is an application for handling 3 DL models: Detect Emotions, Intentions and Sentiment in a user
written Text.
Processes all the models for the provided text return combined response for all the model
Detects user's intention from the text. It basically processes given query against intention model
- clientId
- senderId
- messageId: messageid is requested from user but if request is sent from extention, a unique
msgID is generated.
Response:- Predicts text intention, confidence, start index and end index.
35
3.2.2.2 Emotion Model
- clientId
- senderId
- messageId: messageid is requested from user but if request is sent from extention, a
Response:- Predicts emotion name, confidence, start index and end index.
- Statement Model : Checks whether the given text is a statement type and of what nature ( Positive,
Negative, Neutral)
- Question Model : Checks whether the given text is a question type and of what nature ( Positive,
Negative,Neutral)
36
3.2.2.4 PROJECT DEVELOPMENT
37
Figure 16- Intention model code
38
Figure 18 – Predicted sentiments
39
3.3 HARDWARE AND SOFTWAREREQUIREMENTS:
Hardware Requirements
Software Requirements
3.4 CONCEPTSREQUIREMENTS
• Artificial Intelligence
• Chatbot
• Rasa
• Flask
• Chat Widget
• NumPy
• Pandas
40
CHAPTER-4
PERFORMANCE ANALYSIS
Figure 5- Process
44
CHAPTER-5
CONCLUSIONS
5.1 CONCLUSION
However, there is one solution primed to satisfy the modern customer, and that is a chatbot. With a
chatbot, your organization can easily offer high-quality support and conflict resolution any time of day,
According to Microsoft, 90% of consumers expect an online portal for customer service. As a significant
aspect of business evolution, the need for AI-powered chatbots will only continue torise. Now is the
time to deploy a chatbot solution so that your company doesn’t get left behind.
44
5.2 FUTURESCOPE
The bot still needs a lot of training data. We can integrate RASA-X for the same purpose which is not yet added
into this project. Rasa X is a toolset that layers on top of Rasa Open Source, making it easier to review
conversations, identify next steps in development, and create new training data to improve far beyond the first
44
REFERENCES
• https://www.researchgate.net/publication/340534832_An_Intelligent_Chatbot_System_Based_on_E
ntity_Extraction_Using_RASA_NLU_and_Neural_Network
• https://ijsrcseit.com/paper/CSEIT218331.pdf
• https://arxiv.org/abs/1712.05181
• https://github.com/G-Slient/rasa-covid19-chatbot
• https://www.youtube.com/channel/UCJ0V6493mLvqdiVwOKWBODQ
• For Frontend-Ui code:https://github.com/JiteshGaikwad/Chatbot-Widget
• https://stackoverflow.com
44