Chatbot
Chatbot
By:
Rayen Hamdi
Web/Mobile Application
Without them, I would never have made it. Thank you for all your sacrifices, love, and moral
                                           support
throughout my life.
I wish
   May this work be the fulfillment of your wishes so much alleged, and the fruit of your
                                     unfailing support.
the Lantern that lights my way and illuminates me with sweetness and love.
To my father,
As a sign of love, appreciation and gratitude for all the support and
To my sister and my brother, to whom I owe all the love, with all my wishes for
To my friends, to whom I wish success, for the friendship that has always
United.
                                                                         Rayen Hamdi
                                  Acknowledgment
       It is not possible to prepare a project report without the assistance and encouragement
of other people. This one is certainly no exception.
       First, we would like to thank the members of the jury for having honored us by agreeing
to judge our work.
       Second, we would like to thank the Higher Institute of Applied Sciences and Technology
of Kairouan and its teachers for helping and supporting us until the end.
       Next, we would like to thank Mr. Ouissem Ben fradj for giving his valuable time to
guide us during our graduation thesis. His advice carried us through all the stages of writing
our project.
       I hope that he can find in this work the expression of our deep gratitude and our high
esteem.
       To all those who have contributed directly or indirectly to the success of this project.
                                        Abstract
       Almost all communication of students with the university administration is performed
manually and it is a very time consuming procedure .The opportunity to communicate quickly
and efficiently is highly valued . However with many hundreds of students and the lack of
digitalization , quick and efficient administration tasks are not feasible in most cases . The
communication will require digitalization and many workers working together to get the tasks
faster to many students at the same time .
       The project aims to reduce the burden on workers of the administration, and the students
, by developing a convincing chatbot. A suitable algorithm must be devised to search through
the set of data and find a potential answer. The program then replies to the user providing the
answer to these questions at any time anywhere the person wants. a web and a mobile interface
is provided for students and an administration dashboard for the administrator.
                                           Resume
       Presque toutes les communications des étudiants avec l'administration de l'université
sont effectuées manuellement et c'est une procédure qui prend beaucoup de temps. La
possibilité de communiquer rapidement et efficacement est très appréciée. Cependant, avec
plusieurs centaines d'étudiants et le manque de numérisation, des tâches administratives rapides
et efficaces ne sont pas réalisables dans la plupart des cas. La communication nécessitera la
numérisation et de nombreux travailleurs travaillant ensemble pour fournir les tâches plus
rapidement à de nombreux étudiants en même temps.
   I.2.         Context
       Universities have faced an increasing number of administrative duties over time,
including those related to student admissions, and student grades, among others. Due to the
overwhelming number of these activities, university administrators now have a heavier
workload, which causes backlogs, delays, and mistakes. Additionally, many students have a
difficult time navigating the administrative procedures, which causes dissatisfaction and low
morale.
       Some institutions have used chatbot technology to address these issues by reducing
administrative procedures and enhancing the student experience. A chatbot is computer
software that mimics conversations with human users using artificial intelligence (AI) and
natural language processing (NLP). Universities can automate administrative duties with the
help of chatbots, freeing up administrators to concentrate on higher-level strategic initiatives
while enhancing the effectiveness and efficiency of administrative procedures.
       Although chatbot technology is still in its infancy, it has the power to revolutionize how
institutions run. Universities may develop more effective and efficient solutions that benefit all
stakeholders by automating administrative activities and enhancing the student experience. As
a result, chatbot usage in higher education is expected to increase over the next several years as
institutions work to streamline administrative procedures and adapt to students' changing
expectations.
                                                1
Chapter 1                                                                            Introduction
   I.3.         Motivation
       The absence of a chatbot at the University of ISSAT Kairouan made us think of a
solution to this problem so we made a survey to know the opinion of students in this context
according to the statistics; students think chatbots are a good addition to the university’s support
system.
               Natural Language Processing (NLP): The chatbot will use NLP to understand
                the user's intent and provide relevant responses.
               User Interface: To develop web and mobile user interfaces which aims to give
                the ability to potential students and students of the university to submit questions
                in a chatbot and get convincing replies.
                                                 2
Chapter 1                                                                          Introduction
   I.5.         Deliverables
      The deliverables for this project are as follows:
               A fully functional chatbot system that can interact with users through natural
                language
 User training materials to help users interact with the chatbot effectively.
                                                 3
Chapter 1                                                                        Introduction
Comments:
 Feasibility study:
Initial research on the project feasibility, including exploration of potential challenges and
obstacles that may arise throughout the project's development. We took 2 weeks to complete
this part.
        Gathering and organizing information necessary for the project, and reading articles.
We took 1 week for this part.
 Requirements specification:
Defining the project requirements and specifications, including the development of use cases
and functional requirements. We took 3 days for this part.
 Detailed study:
In-depth research and analysis of project details, including the development of technical
specifications and system architecture. We took 3 days for this part.
 Implementation:
Actual development and creation of project components. We took 2 months for this part.
-Preprocessing:
        We chose one of the preprocessing methods. it goes from the original text to the output
text in 3 steps; tokenization, removing stop words, and stemming.
-Model creation:
        Once the data is preprocessed, we created a machine learning model to classify user
intents and generate appropriate responses. We used Python and trained it on the preprocessed
data.
                                               4
Chapter 1                                                                            Introduction
       After the machine learning model is created, we worked on integrating the chatbot with
both the web application and the mobile application. This requires developing APIs for
communication between the chatbot and different platforms.
       After the integration of the chatbot, we built the web application using HTML, CSS,
and JavaScript. We designed the user interface for the web application and implemented the
chatbot's functionality using the machine learning model.
        We built the mobile application using Java Android mobile. We designed the user
interface for the mobile application and implemented the chatbot's functionality using the same
machine learning model as the web application.
        In this stage, we built an admin panel for managing the chatbot's interactions with users,
as well as accessing analytics and usage data. We used PHP to build the admin panel and
integrate it with the web and mobile applications. The admin panel allows university staff to
manage news, view unanswered questions, frequent 5 questions, statistics, and major students.
It also provides information on the availability of teachers.
 Project finalization:
Finalizing and testing the project, including the creation of a final project report and final
testing and quality assurance
I.7.1.1. Definition
                                                 5
Chapter 1                                                                           Introduction
working software. It focuses on accountability, teamwork, and iterative progress toward well-
defined goals.
       Scrum Framework usually deals with the fact that requirements are likely to change or
are mostly not known at the beginning of the project.
                Product Owner: The Product Owner is typically an expert in the domain and
                 carries the vision of the product to be developed.
                Scrum Master: The Scrum Master is responsible for mastering the Scrum
                 methodology and ensuring the smooth progress of the different sprints in the
                 release.
                Scrum Team: The Scrum Team consists of individuals who are responsible for
                 implementing the various client requirements.
       In the context of this project. Mr Ouissem Ben fradj is both the product owner and the
scrum master and we will form the members of the Scrum Team.
Sprint: Throughout the project's lifecycle, from the specification phase to production
deployment, the work is divided into sprints and releases. A sprint is an iteration that typically
                                                  6
Chapter 1                                                                             Introduction
lasts from 2 to 4 weeks. A release is a collection of sprints that provide better visibility into the
project's timeline.
Daily Scrum: This is a daily meeting that lasts a maximum of 15 minutes. It allows developers
to coordinate their ongoing tasks and discuss any challenges they may be facing. The Scrum
Master ensures that the meeting takes place at a fixed time. Each member takes turns answering
three questions:
Sprint Planning Meeting: The entire team gathers to decide on the features that will be included
in the next sprint and update the overall backlog.
Sprint Review Meetings (Demonstrations): During this meeting, each team member presents
their work completed during the sprint.
Retrospective Meetings: At the end of each sprint, the team reflects on what went well and what
could be improved. In this meeting, which lasts between 15 to 30 minutes, each team member
is invited to speak on their behalf, and a confidence vote is conducted to decide on the
improvements to be made.
       The product backlog is the list of expected features of a product. More precisely, beyond
the functional aspect, it contains all the items that will require work from the team. The items
are prioritized, allowing the order of implementation to be defined. The product backlog is the
responsibility of the Product Owner. Anyone can contribute to collecting items, but it is the
Product Owner who ultimately accepts them and defines the priorities.
                                                 7
Chapter 1                                                                            Introduction
        After breaking down our final project into tasks, we needed to group these tasks into
sprints. A sprint, although an incomplete part of the project, should be a deliverable that is
executable and reusable. Therefore, it is necessary to define the sprints in a way that respects
this rule. After grouping, we have identified 3 sprints to be completed:
Sprint 1 :
                                                    8
Chapter 1                                                                            Introduction
Sprint 2:
Sprint 3:
Sprint 4:
    Authentication (5 points)
    Use the chatbot with a web interface (4 points)
    Use the chatbot with a mobile interface (8 points)
   I.8.        Conclusion
This chapter allowed us to clarify the general context of the project. In the next chapter, we will
talk about artificial intelligence, neural networks, and chatbot.
                                                9
                   Chapter Ⅱ: State of the Art
   II.1.       Introduction:
       In this chapter, we will explore the state of the art. Artificial intelligence in the first place
including its types then neural networks in the second place and the chatbot in the third place
including its history, classification, types, options to build a chatbot, and existing chatbots in
the education sector.
       Artificial Intelligence (AI) is the set of theories and techniques used to enable a machine
to simulate human intelligence performance such as reasoning, natural language understanding,
and perception so that it can "think" like a human. Furthermore, an AI-enabled machine is
capable of solving a problem on its own even if it hasn't been specifically programmed to do
so. AI is already present in many application domains and continues to be improved day by
day.
       Weak artificial intelligence is the most commonly used today, and it is mostly integrated
into computer programs. It allows a program to perform a specific task, more or less complex,
using an algorithm. It is not capable of having cognitive connections similar to those of humans,
but it excels in the task for which it is programmed. This is the case, for example, for computers
capable of winning a game of chess thanks to their ability to reflect.
Machine learning:
                                                  10
Chapter 2                                                                         State of the Art
Deep learning:
         Deep learning is a type of artificial intelligence derived from machine learning where
the machine is able to learn by itself, unlike programming where it is content to execute
predetermined rules to the letter.
         Facial recognition: The eyes, the nose, the mouth, just as many characteristics that a DL
algorithm will learn to detect on a photo. It will first be a question of giving a certain number
of images to the algorithm, then with training; the algorithm will be able to detect a face on an
image.
                                                       11
Chapter 2                                                                        State of the Art
       A neural network is a type of computer algorithm modeled after the structure and
function of the human brain. It is designed to recognize patterns and relationships within data
and can be trained to make predictions, classify data, and perform other tasks.
       Neural networks consist of interconnected nodes (also called neurons) that process and
transmit information through a network of layers. Each layer extracts higher-level features from
the input data, allowing the neural network to learn and improve its performance over time. The
fully connected layer refers to the last hidden layer of a deep neural network. This layer contains
one neuron (node) for each possible output class. The weights (importance) of the connections
are learnable parameters, which will then be optimized during training.
       There are different deep learning algorithms, each with its own strengths and
weaknesses. Here are the most common algorithms:
       A Feedforward artificial neural network, as its name implies, is a type of neural network
where data travels in a single direction between input and output nodes. The data moves through
layers of nodes and does not cycle back through the same layers. Despite having numerous
layers and nodes, the unidirectional flow of data makes it relatively easy to understand
Feedforward neural networks. These models are primarily used for simple classification
problems and outperform traditional machine learning models but do not achieve the same level
of abstraction as deep learning models.
       A Perceptron, which is one of the earliest and simplest neuron models, is a binary
classifier that categorizes data into two different classes. As a linear model, it is an
uncomplicated example of an artificial neural network.
       In comparison, Multilayer Perceptron neural networks are more intricate and dense, with
the ability to include many hidden layers between the input and output layers. Each node on a
specific layer is connected to every node on the next layer, resulting in a fully connected
network, making it ideal for deep learning.
       Multilayer Perceptrons are used for complex tasks such as voice recognition and
advanced classification. Due to their depth and complexity, processing and maintaining, the
models can be resource and time-intensive.
                                                12
Chapter 2                                                                         State of the Art
   II.4.       Chatbots:
       To begin talking about chatbots we need to mention ChatGPT first which is the most
famous and powerful chatbot for now. An extraordinary chatbot that has transformed the way
we interact with technology. ChatGPT, powered by the state-of-the-art GPT-3.5 language
model, has proven to be an invaluable tool for countless individuals worldwide. Its intelligent
design allows for seamless and natural conversations, making it feel like talking to a real person.
People have found ChatGPT incredibly helpful in various domains, from answering complex
questions to assisting with daily tasks. Its versatility shines through its ability to communicate
in multiple languages, ensuring accessibility for users from diverse backgrounds. To know more
about chatbots we need to look at history.
       Alan Turing inspired the idea of a chatbot. In 1950, Turing proposed the Turing Test
and asked whether machines can think. Since then, conversational systems have attracted
extensive attention and become an important concept in artificial intelligence.
       The first publicly known chatbot was ELIZA. Joseph Weizenbaum developed ELIZA
in 1966 at the MIT Artificial Intelligence Laboratory. It simulates conversations based on
handcraft scripts that mimic a Rogerian psychotherapist. When a user chats with ELIZA, he or
she types some statements in natural language. ELIZA analyzes the input text and looks for the
presence of a keyword, and then generates responses according to a rule associated with the
keyword. While it can engage in conversations, its communication ability and knowledge scope
are limited. Below shows a typical conversation between ELIZA and a human.
                                                13
Chapter 2                                                                        State of the Art
       Other well-known early chatbots include PARRY (developed by Colby in 1975) and
ALICE. (Developed by Wallace in 2009). Similar to ELIZA, they simulate how a human would
behave in a text-based conversation using simple pattern-matching algorithms. PARRY is
considered an improvement of ELIZA as it has a personality and a better controlling structure.
The creation of ALICE was another step forward in the history of chatbots. It was the first
online chatbot and was awarded the best human-like system. ALICE pattern matches against
41,000 templates to generate responses, and in comparison, ELIZA contains only 200 keywords
and rules.
       In 2003, a project called CALO (Cognitive Assistant that Learns and Organizes), funded
by Defense Advanced Research Projects Agency (DARPA) and coordinated by SIR
International started. A five-year project aimed to create a cognitive assistant that can learn
from its experience and perform routine tasks for its users. The CALO project was very
important in the history of chatbots as it integrated many areas of artificial intelligence and it
helped software systems to better understand the intentions of humans. Moreover, it had many
spin-offs, most notably Apple Siri.
       Apple Siri, created in 2010, was the first virtual personal assistant. Other assistants such
as IBM Watson, Microsoft Cortana, Amazon Alexa, and Google Assistant followed it. The
virtual personal assistants were integrated into smartphones or smart speakers and could
understand human speech, respond via voice, and handle more advanced tasks. Unlike earlier
                                                   14
Chapter 2                                                                       State of the Art
systems, virtual personal assistants are connected to the internet and are thus able to generate
responses very quickly. However, misunderstandings happen very often as they cannot
understand colloquial language and cannot interpret the input within the dialogue context.
       Another chatbot worth our attention is Microsoft’s XiaoIce. It is a social chatbot, and it
demonstrates that conversational agents can not only conduct conversations and perform simple
tasks but also satisfy our need for sociability.
       More recently, there was another breakthrough in chatbot technology with the
advancement of open-domain chatbots. Google’s Meena and Facebook’s Blender are dialogue
systems that can chat about virtually anything and can achieve close-to-human-level
performance in many aspects.
       Chatbots can be classified based on different parameters, including the service provided,
the knowledge domain, the response generation method, the goal, the permission, and the
human-aid.
       Classification based on the service provided considers the sentimental proximity of the
chatbot to the user, the amount of intimate interaction that takes place, and the task the chatbot
is performing. Interpersonal chatbots provide services like booking services or searches in FAQ
without being a companion of the user. Intrapersonal chatbots live in the personal domain of
the user and are expected to understand the user as a human does. Inter-agent chatbots
communicate with other chatbots to accomplish a task.
       The knowledge domain refers to the knowledge the chatbots access or the amount of
data they are trained upon. Open-domain chatbots can respond to questions from any domain,
whereas closed-domain chatbots only know a particular domain.
       Classification based on the response generation method takes into account the method
of generating responses. A chatbot can be classified as a rule-based, retrieval-based, or
generative-based chatbot, and we will discuss this in more detail later in the paper.
       Classification based on the goals considers the primary goal a chatbot aims to achieve.
Information chatbots provide the user with specific information stored in a fixed source. Chat-
based or conversational chatbots are designed to hold a natural conversation with the user like
another human being would. Task-based chatbots perform a task based on the user’s requests
                                                   15
Chapter 2                                                                    State of the Art
       These types of chatbots are based on the classification above specifically the response
generation method category.
Rule-based chatbots:
                                                 16
      Chapter 2                                                                                State of the Art
Advantages Disadvantages
      They are easy to develop and implement.                          They can only respond to specific
      They can provide quick and accurate answers                       predefined queries, and cannot understand
       to common questions.                                              natural language.
      They can handle a large number of simple                         They are limited in their ability to handle
       queries simultaneously.                                           complex or nuanced conversations.
                                                                        They are prone to errors if the rules are not
                                                                         well defined or if they encounter an
                                                                         unexpected query.
Retrieval-based chatbots:
Advantages                                                    Disadvantages
                                                                       Limited to pre-existing responses, which
       Generate responses quickly. They rely on
                                                                        means they cannot generate new responses
        pre-existing responses that can be quickly
                                                                        or provide creative solutions
        retrieved from a database.
                                                                       May not be able to accurately understand
        Provide accurate responses to user queries,
                                                                        the nuances of user inputs, leading to
        as they use pre-existing responses that have
                                                                        inaccurate or irrelevant responses.
        been vetted and verified by experts.
                                                                       Can be less engaging and interactive
       Handle a large number of user queries at the
                                                                        compared to other types of chatbots.
        same time, making them scalable and
        efficient.
                                                         17
    Chapter 2                                                                              State of the Art
Generative chatbots:
             A generative chatbot is a type of chatbot that uses natural language generation (NLG)
    to generate responses to user inputs on the fly. Unlike retrieval-based chatbots, generative
    chatbots do not rely on pre-existing responses stored in a database. Instead, they use machine
    learning algorithms, deep learning neural networks, or other AI-based techniques to generate
    responses based on the context and intent of the user input.
Table 4 below represents the good and the bad things about generative chatbots
Advantages Disadvantages
      Can understand and process natural                          Can be more complex to develop and
       language inputs, allowing for more natural                   maintain compared to retrieval-based
       and human-like conversations.                                chatbots, as they require more advanced
      Can adapt to new inputs and learn from                       machine learning and natural language
       user interactions, allowing them to                          processing techniques.
       improve over time and provide more                          Require large datasets of conversational data
       accurate and relevant responses.                             for training, which can be resource-intensive
      Can generate new and creative responses,                     ad time-consuming to acquire and process.
       making them well-suited for tasks such as                   Can be difficult to interpret and debug, as
       content creation and personal assistants.                    the underlying machine learning algorithms
                                                                    may not be transparent or easily explainable.
Hybrid chatbots:
             Hybrid chatbots combine the functionalities of both rule-based and AI-based chatbots.
    These chatbots use rule-based systems for simple queries and AI-powered NLP for more
    complex queries
Table 5 below represents the good and the bad things about hybrid chatbots
                                                        18
    Chapter 2                                                                              State of the Art
Advantages                                                 Disadvantages
      They can provide a more personalized and                    They require more development time and
       interactive experience for users.                            resources compared to rule-based or AI-
      They can handle a wider range of queries                     based chatbots alone.
       and conversations.                                          They may not be able to handle all types of
      They can adapt to changing user needs and                    queries or conversations, leading to a
       preferences over time.                                       frustrating user experience.
      They can provide accurate and efficient                     They may require ongoing maintenance and
       responses while minimizing errors.                           updates to ensure optimal performance.
Contextual chatbot:
Table 6 below represents the good and the bad things about contextual chatbots
Advantages                                                 Disadvantages
                                                                   Building and training a contextual chatbot
      Understand the user's intent and context,
                                                                    can be more complex and time-consuming
       providing personalized and relevant
                                                                    than building a basic chatbot.
       responses, leading to a better user
       experience                                                  Developing a contextual chatbot can be
                                                        19
Chapter 2                                                                        State of the Art
Briefly and as mentioned before, humans interact with chatbots. There are two ways to interact
with a chatbot:
Text
         Chatbot analyzes the inputted text and matches the text with predefined data called
intents, which are categorized to manage the conversation. The user utterance is tagged with
one of these intents, even if what the user says stretches over two or more intents. Most chatbots
will take the intent with the highest score and take the conversation down that avenue.
Voice
         Some chatbots can interact and understand the voice of the user using a set of application
programming interfaces (APIs) that converts the recorded voice to the language and then
convert the voice to words of that language and then deal with the transformed text as mentioned
above.
From Scratch
         At first, we have to identify the opportunities for our chatbot and decide its field and
scope to achieve efficiency and accuracy. In addition, a precise understanding of customer
needs is required to solve operational challenges.
         Then the design of the bot comes to be a significant stage to decide the user engagement
with your app or website. Moreover, we can categorize chatbot interactions as structured and
unstructured interactions.
❏ Structured interactions are predictable, and responses can be easily designed based on
anticipated customer queries. This type of interaction resembles an FAQ section, providing
information on contact details, services, products, and more. It ensures users can quickly find
the information they need.
❏ Unstructured interaction involves freestyle plain text conversations where predicting queries
becomes challenging. This type of interaction requires the use of AI and Natural Language
Processing (NLP) analysis to decode the context of the text. NLP enables the chatbot to
understand and respond appropriately. Developing an effective chatbot for unstructured
interactions requires specialized chatbot developers with expertise in programming languages,
                                                20
Chapter 2                                                                      State of the Art
machine learning, and AI. Code-based frameworks like wit.ai and api.ai can be utilized for
building and managing such chatbots.
Using platforms
        Chatbot builder platforms like Chatfuel, Botsify, and Rasa offer an accessible option.
These platforms provide a user-friendly interface for creating chatbots without the need for
specialized developers. While they may not offer NLP-enabled chatbots capable of handling
unstructured data, they still offer valuable functionality and ease of use.
        Several chatbots in the education sector are designed to help students and teachers in
various ways. Here are some of the most notable examples:
Duolingo:
        Duolingo is a language-learning app that uses a chatbot to help users learn a new
language. The chatbot engages users in conversations to help them practice their speaking and
listening skills.
Quizlet:
        Quizlet is a study app that uses a chatbot to help users learn and memorize information.
The chatbot quizzes users on the information they are studying and provides feedback and
explanations to help them improve.
Gradescope:
Gradescope is an assessment tool that uses a chatbot to help teachers grade student work. The
chatbot can recognize handwriting and grade assignments based on pre-set criteria.
Edmentum:
        Edmentum is an online learning platform that uses a chatbot to help students with their
coursework. The chatbot can answer questions, provide feedback, and offer suggestions to help
students improve their performance.
    II.5.       Conclusion:
        Based on the state-of-the-art chapter on chatbots, it can be concluded that chatbots have
come a long way since their inception and have become increasingly popular in recent years.
                                                21
Chapter 2                                                                     State of the Art
With the advancements in artificial intelligence and natural language processing, chatbots have
become more sophisticated and capable of handling complex interactions with users.
       There are various types of chatbots available today, including rule-based, retrieval-
based, and generative chatbots, each with its strengths and limitations. Additionally, chatbots
can be integrated with various platforms and channels, including websites, messaging apps,
voice assistants, and more.
                                              22
                 Chapter Ⅲ: User Requirements
   III.1.       Introduction:
       The following chapter will be Chapter 3; User Requirements, which will contain
information on the project specification. Firstly, we will talk about the survey then the market
analysis and the technical feasibility, and finally functional and non-functional requirements.
       The chatbot must be a contextual and a retrieval chatbot at the same time as the plugins
worked on must retrieve the information and also there is a context for the user.
III.2.1. Survey:
       Several studies have been conducted studying user preferences concerning the
administration versus chatbot service. In particular, a recent survey assesses the image of
chatbots in the eyes of 120 students from ISSAT Kairouan University. It stems from the survey
the following observations:
               Students that know what chatbot means: 65% of students answered yes and 35%
                answered no
                                               23
Chapter 3                                                                        User requirement
               Students that think that chatbots can provide quicker and more efficient support
                to students than human support staff:51.7% of students agree, 33.3% of students
                strongly agree and 12.5% of students are neutral
               Students that think that chatbots can be programmed to provide helpful and
                informative responses: 52.5% of students agree,35.8% of students strongly agree
                and 10.8% are neutral
               Students that are concerned about the quality of support they receive from
                chatbots as compared to human support staff: 45.8% of students are concerned,
                20% are very concerned,22.5% are neutral and 9.2% are not concerned
                           It is clear that students are optimistic and welcome the idea which
                             will help them and facilitate things for them
               Students that prefer using a chatbot or talking to a human support staff member
                for receiving university support: 79.2% prefer using chatbot and human support
                together and 15.8% prefer chatbot only
               Students that think chatbots are a good addition to the university’s support
                system: 50.8% of students answered definitely,38.3% answered to some extent
                and 8.3 % are neutral
                           It is clear that students want to use chatbots but also do not want to
                             give up on human interaction in case there is a problem
       The chatbot industry is growing, and there is a demand for chatbots that can streamline
administrative tasks for students. The target market for this chatbot is students in higher
education institutions.
                                                 24
Chapter 3                                                                     User requirement
        As students working on our graduation project, we are excited to discuss the technical
feasibility of our endeavor to develop a contextual chatbot for administration tasks within the
given project time. We have carefully analyzed the requirements and resources available to us,
and we are confident that our project is feasible and can be successfully implemented.
        Firstly, we have the necessary technical skills and knowledge to undertake this project.
With our background in programming languages such as Python, PHP, and Java, we have a
solid foundation to develop the backend functionalities required for the chatbot and admin
panel, respectively.
        Considering the project's time frame, we have conducted a thorough assessment of the
tasks involved and allocated sufficient time for each stage, including data preprocessing, model
creation, backend development, and integration. We have taken into account potential
complexities and have factored in time for testing, debugging, and refining our solution to
ensure its reliability and effectiveness.
        To validate the feasibility of our project, we will continuously evaluate our progress
against the planned timeline. By conducting regular progress assessments, we can identify any
deviations or challenges early on and take appropriate measures to mitigate them. This proactive
approach ensures that we maintain momentum and deliver the project within the designated
time.
                                               25
Chapter 3                                                                      User requirement
our project timeline, conducting regular evaluations, and maintaining effective communication,
we are well-equipped to demonstrate the feasibility of our project and achieve our desired
outcomes within the given project time.
   III.3.      Requirements:
       III.3.1.          Functional requirements:
The chatbot must respond when a conversation is initiated. This requirement at its most basic
level is the core functionality of the bot. The bot must respond to the user when enters the
conversation. This sets the conversation up for the user and allows them to use the bot as they
desire. As this is a fundamental requirement for the application to work, it is considered a high
priority
The system must provide clear information about the administrative inscription
The system must provide clear information about the schedules of students
The system must provide clear information about the grades of students
The system must provide clear information about vacancies at the end and the beginning of the
scholar year
The system must provide clear information about how to get the students diploma and the
necessary documents to get it
The system must provide clear information about the student's account
The administrator must see the unanswered questions work on them and add them to the intent
       The Chatbot should reply to the user on time to keep the conversation flowing without
interruption. Users value their time greatly and if the response is not quick enough the user will
stop using the chatbot
                                               26
Chapter 3                                                                        User requirement
         The Chatbot must be consistent with its responses. It must behave consistently in a user-
acceptable manner when communicating with a user. The information relayed to the user must
be consistent with the dialog topic.
The system shall handle multiple user inputs, If two or more students are chatting with the bot,
none of the students has to wait too long to be answered by the system.
The system should have the appropriate data set. The correct data set is the basis for the chatbot,
when the data set is correct and tuned, the chatbot will be trained on it to give the best possible
result
         The main usability requirement is that the chatbot and website are user-friendly. The
chatbot, in its nature, is user-friendly since it is a simple chat interface. Everyone knows how a
chatbot works as it is simply like a conversation with his or her friends. The messages come in
on the main screen and there is a text box at the bottom to type in and a send button.
Users must feel comfortable in the conversation and feel in control. To guide the users through
the conversations, help messages should be in place to aid the user if they so happen to be stuck
or are unsure of what to do.
    III.4.      Conclusion
         The chatbot system will provide an intuitive and efficient way for users to interact with
a conversational interface. It will be built using modern technologies and architectural patterns
to provide reliability, scalability, and security. The system will be customizable to suit the needs
of the university and will provide a seamless experience for users.
                                                27
                                Chapter Ⅳ: Chatbot
   IV.1.       Introduction
       The following chapter is Chapter 4; we will delve into the details of the architecture of
the chatbot, the dataset, the machine-learning model, the plugins that have been integrated into
the chatbot, and its implementation.
Presentation Layer: The visible part of the application that allows to user to interact through a
graphical interface that will be through mobile and web. Indeed this layer sends requests to the
business layer and the user receives the result of the processing.
Business Logic: It’s the layer that controls the application control and performs the detailed
processing of the application logic, it’s the place where all the thinking happens, and it interacts
between the data layer and the presentation layer.
Data Access Layer: It’s where all the data and information of our application are stored
                                                    28
Chapter 4                                                                                    Chatbot
           Choosing the correct architecture depends on what type of domain the chatbot will have.
For example, you might ask a chatbot something and the chatbot replies to that. Maybe in mid-
conversation, you leave the conversation, only to pick the conversation up later. Based on the
type of chatbot you choose to build, the chatbot may or may not save the conversation history.
            Due to the varying nature of chatbot usage, the architecture will change to the unique
needs of the chatbot
The chatbot system consists of three main components: the backend, web interface, and mobile
application.
Backend: The backend is built using Python Flask and serves as the central hub for the chatbot
system. It receives incoming requests from the web and mobile components and uses natural
language processing (NLP) algorithms to process the user's intent and generate a response. The
backend also manages the system's database, which stores user data.
Web Interface: The web interface provides an interface for users to interact with the chatbot
system through a web browser. The web interface is built using HTML, CSS, and JavaScript
and is designed to be responsive and accessible across a variety of devices. Users can access
the web interface by visiting the university site and can use the chatbot to answer a variety of
questions related to administrative tasks, such as news, grades, and managing their account
details.
Mobile Application: The mobile application provides a native interface for users to interact
with the chatbot system on their mobile devices. The mobile application is built using the
Android platform and provides an intuitive and user-friendly interface for users to perform
administrative tasks on the go and use it to perform tasks.
           All three components are connected to a common database, which is managed by the
backend. The database stores user data and provides a centralized location for managing the
chatbot system's data. The architecture is designed to be modular and flexible, allowing new
components to be added as needed without affecting the system's core functionality.
                                                   29
Chapter 4                                                                               Chatbot
JSON: JSON (JavaScript Object Notation) is a lightweight data format that is commonly used
for exchanging data between web and mobile applications.
Example:
       A student may want to know information about the financial aid, so we create an
intention labeled with a tag called "Aide financiare".
       For each tag we create, we must specify patterns. This defines the different ways a user
can ask a question to our chatbot. For example, under the "Aide financiare" tag. a user can ask
for the financial aid in different ways such as "Quels types d'aide financière sont disponibles
?", "Comment puis-je demander une aide financière ?", "Quand vais-je recevoir ma bourse
d'aide financière ?".
       The chatbot utilizes these patterns as training data to develop an understanding of how
a user might inquire about the financial aid. This enables the chatbot to adapt and respond
effectively to a wide range of queries. By leveraging its contextual and retrieval capabilities,
the chatbot can retrieve and present the relevant financial aid information based on the user's
specific request, ensuring accurate and meaningful responses. This contextual and retrieval
approach empowers the chatbot to handle diverse queries and provide users with the
information they seek in a tailored and efficient manner.
       In the JSON file of intentions containing our different intentions, next to each tag and
intention pattern, there will be predefined responses. As a contextual and retrieval-based
chatbot, the chatbot doesn't try to generate text by understanding the question. Instead, it
leverages its retrieval capabilities to identify the context of the user's query and retrieves a
response accordingly. Knowing the labels gives us an idea of the type of question we're dealing
with, and once a label is identified, the corresponding response can be selected from the
examples of responses associated with each tag. This approach allows the chatbot to provide
                                               30
Chapter 4                                                                                   Chatbot
accurate and relevant responses to users, even if they don't use the exact queries our chatbot has
learned.
       The “context_filter” field in the JSON code refers to a condition that needs to be met
before the intent can be triggered. This can be useful when you want to make sure that the
chatbot only responds to certain intents in specific contexts.
       The context_set field, on the other hand, is used to set a context variable once the intent
is triggered. This can be useful in keeping track of what the user has been talking about, and to
help the chatbot understand the user's intentions in subsequent interactions.
       As an example, let's consider the intention labeled "Aide financiere" with the associated
patterns and responses. The tag "Aide financiere" represents a user's query about the financial
aid. The patterns associated with this tag are various ways a user can ask, such as "Quels types
d'aide financière sont disponibles ?", "Comment puis-je demander une aide financière ?",
"Quand vais-je recevoir ma bourse d'aide financière ?". These patterns serve as training data for
the chatbot to recognize the user's intent. Once the chatbot understands the user's intent, it
responds with the message " Voulez-vous un lien pour plus d'informations?".
       In this example, there is also a sub-intention labeled "Aide financiere-1", with the sole
pattern "oui". This represents a confirmation from the user that they would like to receive the
website link to access more information. The associated response is the actual website link to
the information about the financial aid. The "context_filter" attribute is set to "Aide financiere",
indicating that this sub-intention is only relevant within the context of the "Aide financiere"
intention. Finally, the "context_set" attribute is also set to "Aide financiere", indicating that the
chatbot should remember the "Aide financiere" intention for future interactions with the user
until the context is cleared.
                                                 31
Chapter 4                                                                                  Chatbot
Tokenization
       Text tokenization is the process of breaking down a piece of text into individual words,
phrases, or sentences, known as tokens. This step is essential for NLP (Natural Language
                                                    32
Chapter 4                                                                               Chatbot
Processing) applications as it enables the program to understand the structure of the text.
Tokenization can be done at different levels, such as word level or character level, depending
on the needs of the project. Once the text has been tokenized, it becomes easier to analyze and
manipulate it for various NLP tasks.
        The process of removing stop words in French is similar to other languages. Stop words
in French are words that are commonly used but do not carry much meaning in a sentence, such
as "le", "la", "Les", "et", "ou", "de", "du", "des", etc.
        To remove stop words in French, we would first need to obtain a list of commonly used
French stop words. There are various libraries in Python, such as NLTK and spaCy, that have
built-in stop-word lists for different languages, including French.
        Once we have obtained the list of French stop words, we can use it to remove the stop
words from your text data. This can be done by tokenizing the text, converting all the words to
lowercase to ensure consistency, and then removing any words that are on the stop word list.
Stemming:
        Stemming is the process of reducing a word to its base or root form, known as a stem.
For example, the stem of the word "running" is "run". Stemming can be useful in NLP
applications as it reduces the number of unique words in a corpus, making it easier to analyze
and manipulate the data. There are different algorithms for stemming, such as the Porter
stemming algorithm or the Snowball stemming algorithm, which use different rules to generate
stems from words.
        By implementing these preprocessing steps, we can ensure that our chatbot is better
equipped to handle administration tasks at the university by analyzing the user's text inputs and
extracting the relevant information required to carry out the tasks.
        We chose the feedforward neural network with three fully connected layers for our
contextual chatbot project after conducting a thorough review of the state of the art in neural
networks. We explored various neural network architectures such as convolutional neural
networks, recurrent neural networks, and hybrid models, but ultimately decided on a
feedforward neural network due to its simplicity, efficiency, and effectiveness in handling the
specific task of natural language processing.
                                                  33
Chapter 4                                                                                  Chatbot
       Additionally, we chose to use three fully connected layers because they provide a good
balance between complexity and performance. Having more than three layers could lead to
overfitting while having fewer layers could result in underfitting and poor accuracy. By using
three fully connected layers, we can extract relevant features from the input data and accurately
predict the appropriate response to a user's query, which is essential for a chatbot that deals with
administrative tasks in a university
       The first line resets the underlying TensorFlow graph, ensuring a clean slate for building
the neural network model.
       This section defines the architecture of the neural network using TFLearn and
TensorFlow. It creates an input layer, two hidden layers with 16 neurons each use the ReLU
activation function by default, and an output layer with softmax activation which produces a
probability distribution over the classes. Finally, we create a regression layer using
tflearn.regression() to specify the training objective and loss function for the network
       We define the model using tflearn.DNN() and pass the net architecture we built as the
argument. Additionally, we specify the directory 'tflearn_logs' for storing TensorBoard logs.
TensorBoard is a visualization tool provided by TensorFlow for monitoring and analyzing the
training process. The model is trained on the training data using the fit method, with a specified
number of epochs and batch size. The training progress is shown with metrics. The n_epoch
parameter determines the number of training epochs (iterations over the entire dataset). The
batch_size parameter specifies the number of training examples to be processed in each batch
during gradient descent. The show_metric=True argument enables the display of training
metrics, such as accuracy, during training.
                                                   34
Chapter 4                                                                               Chatbot
       After training is complete, we save the trained model to a file named 'model.tflearn'
using the save() method of the model.
       By building and training the neural network model, we aim to teach it to recognize
patterns in the input data and make accurate predictions. The training process involves adjusting
the weights and biases of the network using gradient descent optimization to minimize the
training loss. The trained model can then be saved and later loaded for making predictions or
further analysis.
The user sends a message and the message will be received by the system.
After loading the same imports, we’ll un-pickle our model and documents as well as reload our
intents file. Remember our chatbot framework is separate from our model build — you don’t
                                                   35
Chapter 4                                                                                     Chatbot
need to rebuild your model unless the intent patterns change. With several hundred intents and
thousands of patterns, the model could take several minutes to build.
       The given code snippet is focused on restoring the necessary data structures for a
chatbot. It starts by loading the saved training data from a file named "training_data" using the
pickle.load() function. This data is stored in binary format and is then assigned to the data
variable.
       Next, the code extracts specific components from the loaded data dictionary. These
components include a list of unique words (words) found in the training data, a list of unique
classes or intents (classes), input training patterns (train_x), and corresponding output labels or
classes (train_y).
       Additionally, the code reads a JSON file called "intents.json" that contains predefined
patterns and responses for the chatbot. The open() function is used to open the file with the
specified encoding ('utf-8'), and the json.load() function parses the JSON data from the file,
loading it into the intents variable.
       By restoring these data structures, you are retrieving the necessary information for
training and using the chatbot model. The words and classes provide the vocabulary and class
labels, while train_x and train_y contain the training examples and their corresponding labels.
The intents variable holds the predefined patterns and responses that the chatbot will use during
conversations.
                                                    36
Chapter 4                                                                               Chatbot
Next, we will load our saved TensorFlow (TFLearn framework) model. Notice you first need
to define the TensorFlow model structure just as we did in the previous section.
Pre-processing
We do the same text tokenization, removing stop words and stemming just like we did in the
section above
       Bag of words, also known as the vector space model, is one of the simplest approaches
to analyzing the input. We count the occurrences of each word but ignore the syntactic
information or word order information. This can be done by performing text normalization and
eliminating stop words, i.e. words that do not contribute to the meaning of the sentence. The
bag-of-words approach is limited when the meaning of the text is subject to linguistic
knowledge such as grammar or word order. For example, “Alice is taller than Bob” and “Bob
is taller than Alice” yield the same representation but their meanings are different.
classify(sentence): This function takes a sentence as input and performs the following steps:
                                                    37
Chapter 4                                                                                    Chatbot
The bow() function is called to obtain the bag of words representation for the sentence.
The model (model) is used to predict the probabilities of each class (intent) for the given bag
of words.
       To filter out predictions below a certain threshold, the code iterates over the results and
retains only those predictions that have a probability greater than the specified
ERROR_THRESHOLD. The filtered results are then sorted in descending order based on the
strength of the probability using a lambda function.
       The function returns a list of tuples, where each tuple contains an intent and its
corresponding probability. The intent is obtained by mapping the index of the result to its
respective class label using the classes array. Finally, the list of tuples is returned as the output,
providing the caller with the intents and their associated probabilities for the given sentence.
IV.5.3. Performance
       This test sheds light on both the strengths and limitations of the chatbot's current
capabilities. The fact that the chatbot achieved a success rate of 72% indicates that it possesses
a good understanding of common queries and can effectively generate appropriate answers for
the majority of user interactions. This is a positive outcome that demonstrates the chatbot's
ability to handle a significant portion of user inquiries successfully.
                                                 38
Chapter 4                                                                                Chatbot
       However, the 28% failure rate highlights the areas where the chatbot's performance can
be improved. These instances indicate gaps in the chatbot's knowledge base or its ability to
handle more complex or less common queries. This underscores the need for further
development and enhancement to increase the chatbot's overall performance and
responsiveness.
       When a user initiates a conversation with the chatbot, the context stack is initialized.
The stack acts as a memory to store userID as a key and assigns an empty value, but when the
user talks about a topic that contains the context_set. the context_set becomes the value of the
key It's important to note that each user can only have one active context at a time. This measure
is implemented to protect the system from DoS attacks.
       Additionally, the context_filter technique is utilized to refine the responses based on the
context stack. As the chatbot generates a response, it considers the current context and filters
the available information to provide a tailored and contextually appropriate answer.
       In summary, our chatbot's functionality relies on the concept of context and utilizes the
context stack, context_set, and context_filter techniques to ensure accurate and contextually
appropriate responses. This approach allows the chatbot to engage in meaningful and dynamic
conversations, providing users with a personalized and seamless interaction experience.
                                               39
Chapter 4                                                                                    Chatbot
Python: Python is a popular programming language that is widely used for building chatbots,
as it offers a wide range of libraries and tools for natural language processing, machine learning,
and web development.
Flask: Flask is a lightweight web framework for Python that is used for building web
applications and APIs.
Natural Language Toolkit (NLTK): NLTK is a popular Python library for natural language
processing, which provides tools and methods for tokenizing, parsing, and analyzing text data.
TFLearn: TFLearn is a high-level deep learning library built on top of TensorFlow. It provides
a simple and intuitive API for building and training deep neural networks.
NumPy: NumPy is a popular Python library for scientific computing. It provides tools for
working with large multi-dimensional arrays and matrices, as well as a wide range of
mathematical functions for numerical computing.
Pickle: Pickle is a Python library for object serialization. It allows you to convert Python
objects, such as dictionaries or lists, into a byte stream that can be stored in a file or transmitted
over a network. Pickle is commonly used for saving and loading machine learning models.
       The use cases describe how the system interacts with the users. They help us understand
the users' needs. The following Figure 17 illustrates the general use case diagram of our
application.
                                                 40
Chapter 4                                                                                  Chatbot
       Table 7 represents the actors table who are involved in the chatbot system.
                                            Table 7 : Actors table
We have 4 plugins in our chatbot we will explain every plugin one by one
IV.8.2. Availability :
This plugin will help the students know the availability of each teacher.
       The function checks if the user's message contains the word "disponibilite" or
"disponibilité". If it does, it uses regular expressions to extract the professor's name from the
message and queries the database for their availability. If the result is found, it is returned as a
response. Otherwise, a default response is returned.
                                                   41
Chapter 4                                                                                       Chatbot
        The user sends a request to the user interface, which passes it to the Flask backend. The
backend extracts the necessary information and retrieves the availability of teachers from the
database. If the availability exists, it is returned to the user interface. Otherwise, a list of teachers
is returned. The user interface displays the result to the user.
                                                     42
Chapter 4                                                                             Chatbot
IV.8.3. Vacation
This plugin will help the students know what days of vacation the university will agree on.
If the user's message matches specific keywords like "vacance", the chatbot retrieves
corresponding data from the database and formats it for the response.
                                                   43
Chapter 4                                                                              Chatbot
       The user sends a request to the user interface, which passes it to the Flask backend. The
Flask backend retrieves the vacation details from the database. Then the database returns the
vacation result to the flask and finally the backend returns the vacation result to the user
interface, which displays it to the user after making sure of the condition.
IV.8.4. News:
This plugin will help the students know the news of the university.
If the user's message matches specific keywords like "news", the chatbot retrieves
corresponding data from the database and formats it for the response.
                                                  44
Chapter 4                                                                              Chatbot
       The user sends a request to the user interface, which passes it to the Flask backend. The
Flask backend retrieves the news details from the database. Then the database returns the news
result to the flask and finally the backend returns the news result to the user interface, which
displays it to the user after making sure of the condition
                                                  45
Chapter 4                                                                              Chatbot
IV.8.5. Valedictorian
This plugin will help the students know the valedictorian every year
If the user's message matches specific keywords like "news", the chatbot retrieves
corresponding data from the database and formats it for the response.
       The user sends a request to the user interface, which passes it to the Flask backend. The
Flask backend retrieves the valedictorian details from the database. Then the database returns
                                                  46
Chapter 4                                                                               Chatbot
the valedictorian result to the flask and finally the backend returns the valedictorian result to
the user interface, which displays it to the user after making sure of the condition
   IV.9.       Conclusion
       This chapter was intended to present the data and prepare them. Then we demonstrated
the structure of a dataset that is used to realize the chatbot, so we declared and detailed the
importance of the pre-processing and their steps and we showed the architecture we are working
on as well as the technologies used and the design.
                                                   47
           Chapter Ⅴ: The front-end application
    V.1.         Introduction
       The front-end application of the chatbot consists of two systems: the web system and
the Android system. These systems provide users with a convenient and interactive interface to
interact with the chatbot's functionalities.
        In this introduction, we will discuss the use case diagram, ER diagram, sequence
diagram, and class diagram for each system, highlighting their key components and interactions
finally the graphical user interface and the implementation.
Figure 30 below represents the use case diagram of the Android system
                                                   48
Chapter 5                                                                     The front-end application
       In this scenario, the user interacts with the system through the MainActivity by sending
messages. Upon receiving a message, the MainActivity adds it to the chat list, forwards it to the
FlaskServer, and receives a response. The response is then displayed in the chat list. Error
handling is performed if needed. Additionally, the MainActivity manages the generation or
retrieval of a unique ID, creates a request queue, and updates the message list and view
accordingly. Informative dialogs are shown and dismissed as necessary.
                                                  49
Chapter 5                                                                      The front-end application
              The user graphical interface of the mobile system for our chatbot is the visually
appealing and intuitive interface through which users interact with the chatbot on their mobile
devices. It includes components such as input fields, buttons, and chat bubbles, allowing users
to input queries and receive responses. Designed for ease of use and clear communication, the
interface aims to provide a seamless and engaging user experience, ensuring effective
interaction with the chatbot and enhancing user satisfaction.
                                                  50
Chapter 5                                                                          The front-end application
Figure 33 below represents the screenshot of the first thing displayed in the application
                                                    51
Chapter 5                                                                 The front-end application
V.2.5.Implementation:
                                             52
Chapter 5                                                                        The front-end application
       This code defines a simple class that represents a chat message and its sender. It
encapsulates the data related to a message and provides methods to access and modify that data.
This class can be utilized in a chatbot application or any other system that involves message
handling.
Figure 37 below represents the pseudocode of the XML code of the activity_main
       This XML code sets up a user interface for a chat application. It includes a
RecyclerView to display the chats and a layout at the bottom with an EditText for entering
messages and an ImageButton for sending them.
                                                  53
Chapter 5                                                                        The front-end application
       This XML code provides essential information about the application, including
permissions, activity configuration, and application-wide settings. It also specifies the main
activity and its launcher configuration.
                                                   54
Chapter 5                                                                 The front-end application
       This code sets up the necessary variables to handle the chat functionality in the main
activity. It initializes references to the required widgets and creates objects for the request
queue, ArrayList, and adapter
Figure 40 below represents the use case diagram of the web system
       The user opens the web application and clicks on the chatbox button to initiate a
conversation. The chatbox toggles within the web application, allowing the user to send a
message. The message is forwarded from the chatbox to the web application, which relays it to
the Flask server. The Flask server processes the message, formulates a response, and sends it
back to the web application. The web application then relays the response to the chatbox, which
displays it to the user. The user has the option to close the chatbox or, eventually, close the web
application to conclude the interaction.
                                                  55
Chapter 5                                                                    The front-end application
       The web system's user graphical interface serves as the visually appealing and intuitive
platform through which users interact with the chatbot. It incorporates various elements such
as input fields, buttons, and chat bubbles to facilitate user queries and responses. The interface
is designed with a focus on user-friendliness, enabling effortless navigation and effective
                                                  56
Chapter 5                                                                   The front-end application
communication. With its seamless and engaging design, the interface enhances user satisfaction
by ensuring an efficient and enjoyable interaction with the chatbot. Through a combination of
user-centric design principles and clear communication, the web system's interface aims to
provide a positive user experience that meets the needs and expectations of users.
       Figure 43 below represents a screenshot of what is displayed in the chatbox before any
message
                                                 57
Chapter 5                                                                   The front-end application
Figure 44 below represents a screenshot of the first message displayed in the chatbox
V.3.4.The implementation
HTML
       Figure 46 and Figure 47 are HTML code that represents the structure and layout of the
chatbot interface in our project. This code is responsible for rendering the chatbox and
providing a user-friendly environment for interacting with the chatbot.
                                                  58
Chapter 5                                                                The front-end application
       The body of the document contains a <div> with the class "container" to encapsulate
the chatbox. Within this container, there is a <div> with the class "chatbox" representing the
chatbox itself.
       The <script> tags at the bottom of the document include the necessary JavaScript code
to handle the functionality of the chatbox, such as sending and receiving messages. The {{
url_for() }} and {{ request.script_root }} syntax indicates that the script is dynamically
referencing static files and routes within the application.
                                                 59
Chapter 5                                                                      The front-end application
JavaScript
       The JavaScript code represents the functionality of the chatbox in our project. It defines
a class called Chatbox and initializes it with various properties and methods to handle user
interactions and message handling.
        As it is shown in Figure 48. In the constructor, the args object is created to store
references to HTML elements such as the open button, chatbox, and send button. The state
property is set to false to indicate that the chatbox is initially closed. The messages array is used
to store the conversation history.
                                                   60
Chapter 5                                                                     The front-end application
       The display method sets up event listeners for the open button, send button, and enter
key press. When the open button is clicked, it toggles the state of the chatbox, either showing
or hiding it. The send button click and enter key press trigger the onSendButton method to
handle sending the user's message.
       The toggleState method updates the state of the chatbox and adds or removes the
"chatbox--active" class to show or hide the chatbox accordingly.
       As it is shown in Figure 49. The onSendButton method handles sending the user's
message. It retrieves the input text, checks if it's empty, and constructs a message object with
the user's name and message. The message object is then added to the messages array. It also
retrieves the user's ID from a cookie or generates a new one if it doesn't exist.
                                                  61
Chapter 5                                                                      The front-end application
       As it is shown in Figure 50. The message and user ID are sent to the server using the
Fetch API, and the response is processed. The response message is constructed with the
chatbot's name and decoded answer. The response message object is added to the messages
array, and the chatbox UI is updated. Finally, the input text field is cleared.
       As it is shown in Figure 51. The updateChatText method generates the HTML markup
for displaying the chat messages based on the messages array. The messages are iterated over
                                                   62
Chapter 5                                                             The front-end application
in reverse order, and based on the sender's name, the appropriate CSS class is applied to format
the message. The generated HTML is then inserted into the chatbox's messages container.
       At the end of the script, an instance of the Chatbox class is created, and the display
method is called to set up the chatbox functionality on the page.
   V.4.        Conclusion
       This chapter provides valuable insights into the front-end application, discussing both
the Android and web systems. It covers various aspects such as use case diagrams, sequence
diagrams, graphical user interfaces, and implementations for each system. By exploring these
details, the chapter establishes the foundation for an effective and user-friendly chatbot front
end.
                                              63
     Chapter Ⅵ: The administration dashboard
   VI.1.       Introduction:
       The administration dashboard is a crucial component of our university chatbot system,
providing administrators with the tools they need to manage and monitor the chatbot's
performance and data. As part of our report on the chatbot, this chapter will provide an overview
of the administration dashboard's features and capabilities.
       We will start with the ER diagram then the usage statistics and end up with the new
features extraction.
                                                64
Chapter 6                                                                 The administration Dashboard
       Figure 56 below represents the vacation interface. The administrator could add a new
vacation edit or delete. This interface represents all the vacations of the academic year
The other interfaces which are news, valedictorian, and availability are similar in the
functionality of the vacation plugin. The administrator could add edit, and delete.
                                                   65
Chapter 6                                                                 The administration Dashboard
       Figure 57 below represents the interface of all the questions the chatbot did not
understand .they are displayed in this table so that the administrator could read and work on
adding the things that are unanswered in the intent JSON file
   VI.5.       Conclusion
       In conclusion, this chapter provides a comprehensive overview of the administration
dashboard's features and capabilities. It highlights the ER diagram, usage statistics, and the role
of the dashboard in managing the chatbot's performance. By presenting these details, the chapter
emphasizes the importance of the administration dashboard in streamlining chatbot
management and enhancing its functionality.
                                                   66
       Chapter Ⅶ: Conclusion and future work
   VII.1. Conclusion
       In conclusion, our chatbot project has successfully developed a system that utilizes
artificial intelligence to handle administrative tasks at the university. The project consists of
three main aspects: the web interface, the mobile interface, and the administration dashboard.
It is important to note that there is one flask backend that connects the web and mobile
interfaces, making it easy for users to switch between platforms seamlessly. The web interface
provides a platform for students to interact with the chatbot and access information about
university services, while the mobile interface offers convenient access to the chatbot on the
go. The administration dashboard, on the other hand, enables university administrators to
manage the chatbot data, and access analytics. Our chatbot system offers several benefits,
including reducing the workload of administrative staff, providing quick and efficient responses
to user queries, and improving communication and engagement with students. By utilizing
artificial intelligence, the system ensures that responses are accurate and consistent and that the
chatbot can handle a wide range of queries.
                                                67
Chapter 7                                                             Conclusion and future work
       Factors such as speed and compatibility should also be considered. Advanced natural
language processing techniques help identify possible answers. Anaphora parsing helps detect
when a user links to a previous question or answer, which requires chatbot storage.
Techniques such as statistical parsing and sentence structure analysis improve sentence
comprehension and response quality.
                                                68
                                          References
[1] https://towardsdatascience.com/how-to-build-a-basic-chatbot-from-scratch-
[2] https://chatbotsmagazine.com/contextual-chat-bots-with-tensorflow-
[3] https://www.spiceworks.com/tech/artificial-intelligence/articles/what-is-chatbot/
[4] https://www.seldon.io/neural-network-models-explained
[5] https://sourcedexter.com/tensorflow-text-classification-python/
[6] http://tflearn.org/
[7] https://www.deeplearning.ai/resources/natural-language-processing/
[8] https://codeinstitute.net/global/blog/php-in-html/
[9] https://developer.mozilla.org/
[10] https://www.youtube.com/watch?v=dRzisSkSGbc&ab_channel=LearnVern
[11] https://developer.android.com/reference/android/widget/TextView/
69