0% found this document useful (0 votes)
11 views83 pages

Chatbot

The document discusses developing a chatbot application to help students complete academic tasks. It will summarize tasks between students and the university administration to reduce workload. The application will include a web and mobile interface for students and an administration dashboard. It will use artificial intelligence techniques like neural networks to understand questions and provide answers by searching a database. The project aims to digitize communication and make administrative tasks more efficient.

Uploaded by

yt6469340
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views83 pages

Chatbot

The document discusses developing a chatbot application to help students complete academic tasks. It will summarize tasks between students and the university administration to reduce workload. The application will include a web and mobile interface for students and an administration dashboard. It will use artificial intelligence techniques like neural networks to understand questions and provide answers by searching a database. The project aims to digitize communication and make administrative tasks more efficient.

Uploaded by

yt6469340
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 83

University of Kairouan

Ministry of Higher Education and The Higher Institute of Applied


Scientific Research Sciences and Technology of
Kairouan

GRADUATION PROJECT N°6

In order to obtain the

License’s degree in computer systems engineering

By:

Mohamed Yosri Selmi

Rayen Hamdi

Web/Mobile Application

Chatbot for academic tasks

Presented in: 21 June


In front of the jury:

Mr. Sofiene Khalfallah President

Ms. Wided Ben Abid Examiner

Mr. Ouissem Ben Fradj Supervisor

Academic year: 2022 – 2023


Dedication
I dedicate this work and my deep gratitude and appreciation,

To my dear parents, who constituted the first school of my existence.

Without them, I would never have made it. Thank you for all your sacrifices, love, and moral
support

throughout my life.

To my sister who I love so much, who never ceased to encourage me,

I wish

you a life full of happiness, success, and love.

May this work be the fulfillment of your wishes so much alleged, and the fruit of your
unfailing support.

To all the family,

Thanks for always being there for me.

Med Yosri Selmi


Dedication
To my mother,

My reason for being, my reason for living,

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

the sacrifices he made for me.

To my sister and my brother, to whom I owe all the love, with all my wishes for

see success in their lives.

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.

Le projet vise à alléger la charge des travailleurs de l'administration, et des étudiants, en


développant un chatbot convaincant. Un algorithme approprié doit être conçu pour rechercher
dans l'ensemble de données et trouver une réponse potentielle. Le programme répond ensuite à
l'utilisateur en fournissant la réponse à ces questions à tout moment, où que ce soit. une interface
web et mobile est mise à disposition des étudiants et un tableau de bord d'administration pour
l'administrateur
Content list

Chapter Ⅰ: Introduction ............................................................................................................................ 1


I.1. Introduction ............................................................................................................................. 1
I.2. Context .................................................................................................................................... 1
I.3. Motivation ............................................................................................................................... 2
I.4. Aims and objectives ................................................................................................................ 2
I.5. Deliverables ............................................................................................................................. 3
I.6. Gantt chart ............................................................................................................................... 3
I.7. Detailed methodology ............................................................................................................. 5
I.7.1. Scrum method.................................................................................................................. 5
I.7.1.1. Definition................................................................................................................. 5
I.7.1.2. Team roles ............................................................................................................... 6
I.7.1.3. Organization Events ................................................................................................ 6
I.7.1.4. Product Backlog ...................................................................................................... 7
I.7.1.5. Sprint Plan ............................................................................................................... 8
I.8. Conclusion ............................................................................................................................... 9
Chapter Ⅱ: State of the Art ................................................................................................................. 10
II.1. Introduction: .......................................................................................................................... 10
II.2. Artificial intelligence:............................................................................................................ 10
II.2.1. Definition....................................................................................................................... 10
II.2.2. The different types of artificial intelligence: ................................................................. 10
II.2.2.1. Weak artificial intelligence:................................................................................... 10
II.2.2.2. Strong artificial intelligence .................................................................................. 10
II.3. Neural network: ..................................................................................................................... 11
II.3.1. Definition....................................................................................................................... 11
II.3.2. Types of neural network algorithms: ............................................................................. 12
II.4. Chatbots:................................................................................................................................ 13
II.4.1. Overview of Chatbots: ................................................................................................... 13
II.4.1.1. The Rise of Chatbots: ............................................................................................ 13
II.4.1.2. Classification of chatbots: ..................................................................................... 15
II.4.2. Types of chatbots:.......................................................................................................... 16
II.4.3. Different ways for chatbots to work: ............................................................................. 19
II.4.4. Options to build a chatbot: ............................................................................................ 20
II.4.5. Existing chatbots in the education sector: ..................................................................... 21
II.5. Conclusion:............................................................................................................................ 21
Chapter Ⅲ: User Requirements ............................................................................................................ 23
III.1. Introduction: ...................................................................................................................... 23
III.2. Project specification: ......................................................................................................... 23
III.2.1. Survey:....................................................................................................................... 23
III.2.2. Market Analysis: ....................................................................................................... 24
III.2.3. Technical Feasibility: ................................................................................................ 25
III.3. Requirements: .................................................................................................................... 26
III.3.1. Functional requirements: ........................................................................................... 26
III.3.2. Non-functional requirements: .................................................................................... 26
III.3.2.1. Performance/Response time requirement.............................................................. 26
III.3.2.2. Security requirements............................................................................................ 26
III.3.2.3. Reliability requirement.......................................................................................... 27
III.3.2.4. Maintainability requirement .................................................................................. 27
III.3.2.5. Usability requirements .......................................................................................... 27
III.4. Conclusion ......................................................................................................................... 27
Chapter Ⅳ: Chatbot............................................................................................................................... 28
IV.1. Introduction ....................................................................................................................... 28
IV.2. Logical architecture: .......................................................................................................... 28
IV.3. System architecture: .......................................................................................................... 29
IV.4. The Dataset ........................................................................................................................ 30
IV.5. The machine learning model ............................................................................................. 32
IV.5.1. The creation of the model .......................................................................................... 32
IV.5.2. The use of the model ................................................................................................. 35
IV.5.3. Performance............................................................................................................... 38
IV.6. How the contextual chatbot work: ..................................................................................... 39
IV.7. Selection of technologies:.................................................................................................. 39
IV.8. Chatbot plugins: ................................................................................................................ 40
IV.8.1. Use case diagram of the chatbot ................................................................................ 40
IV.8.2. Availability : .............................................................................................................. 41
IV.8.2.1. The function .......................................................................................................... 41
IV.8.2.2. The sequence diagram........................................................................................... 42
IV.8.2.3. The ER diagram .................................................................................................... 43
IV.8.3. Vacation..................................................................................................................... 43
IV.8.3.1. The function .......................................................................................................... 43
IV.8.3.2. The sequence diagram........................................................................................... 43
IV.8.3.3. The ER diagram .................................................................................................... 44
IV.8.4. News: ......................................................................................................................... 44
IV.8.4.1. The function .......................................................................................................... 44
IV.8.4.2. The sequence diagram........................................................................................... 45
IV.8.4.3. The ER diagram .................................................................................................... 46
IV.8.5. Valedictorian ............................................................................................................. 46
IV.8.5.1. The function .......................................................................................................... 46
IV.8.5.2. The sequence diagram........................................................................................... 46
IV.8.5.3. The ER diagram .................................................................................................... 47
IV.9. Conclusion ......................................................................................................................... 47
Chapter Ⅴ: The front-end application.................................................................................................... 48
V.1. Introduction ........................................................................................................................... 48
V.2. Android system: .................................................................................................................... 48
V.2.1. The UML use case Diagram: ......................................................................................... 48
V.2.2. The UML class diagram ................................................................................................ 48
V.2.3. The Sequence diagram .................................................................................................. 49
V.2.4. Graphical User Interface: .............................................................................................. 50
V.2.5. Implementation:............................................................................................................. 52
V.3. Web system ........................................................................................................................... 55
V.3.1. The UML use case Diagram .......................................................................................... 55
V.3.2. The Sequence diagram .................................................................................................. 55
V.3.3. Graphical User Interface................................................................................................ 56
V.3.4. The implementation ....................................................................................................... 58
V.4. Conclusion ............................................................................................................................. 63
Chapter Ⅵ: The administration dashboard............................................................................................ 64
VI.1. Introduction: ...................................................................................................................... 64
VI.2. The ER diagram:................................................................................................................ 64
VI.3. Usage statistics: ................................................................................................................. 65
VI.4. New features extraction ..................................................................................................... 65
VI.5. Conclusion ......................................................................................................................... 66
Chapter Ⅶ: Conclusion and future work............................................................................................... 67
VII.1. Conclusion ......................................................................................................................... 67
VII.2. Overall strengths................................................................................................................ 67
VII.3. Overall weaknesses ........................................................................................................... 67
VII.4. Future works ...................................................................................................................... 68
Figures list

Figure 1 : Tasks chart ........................................................................................................................... 3


Figure 2 : Gantt chart ........................................................................................................................... 3
Figure 3 : SCRUM process ................................................................................................................... 6
Figure 4 : The organization of the different disciplines ................................................................... 11
Figure 5: The chatbot of ELIZA ........................................................................................................ 14
Figure 6 : Classification of chatbots................................................................................................... 16
Figure 7 : Logical architecture figure ................................................................................................ 28
Figure 8: Pseudocode of an intent example ....................................................................................... 32
Figure 9: The steps for the creation of the model ............................................................................. 32
Figure 10 : Pseudocode of building the neural network .................................................................. 34
Figure 11 : Pseudocode of starting the training ............................................................................... 34
Figure 12 : Steps for the use of the model ......................................................................................... 35
Figure 13: Pseudocode of the loading of the model .......................................................................... 36
Figure 14 : Pseudocode of loading and saving the TensorFlow model ........................................... 36
Figure 15: The use of the same neural network................................................................................ 37
Figure 16 : Pseudocode of the classify function ................................................................................ 37
Figure 17 : Use case diagram of the chatbot ..................................................................................... 41
Figure 18: Pseudocode of the availability plugin .............................................................................. 42
Figure 19: Sequence diagram of the availability plugin .................................................................. 42
Figure 20 : The ER diagram of the availability plugin .................................................................... 43
Figure 21 : Pseudocode of the vacation plugin ................................................................................. 43
Figure 22 : Sequence diagram of the vacation plugin ...................................................................... 44
Figure 23 : ER diagram of the vacation plugin ................................................................................ 44
Figure 24: Pseudocode of the news plugin ........................................................................................ 45
Figure 25 : Sequence diagram of the news plugin ............................................................................ 45
Figure 26 : ER diagram of the news plugin ...................................................................................... 46
Figure 27: Pseudocode of the valedictorian plugin........................................................................... 46
Figure 28 : Sequence diagram of the valedictorian plugin .............................................................. 47
Figure 29 : ER diagram of the valedictorian plugin ........................................................................ 47
Figure 30: Use case diagram of the Android system ........................................................................ 48
Figure 31: Class diagram of the Android system ............................................................................. 49
Figure 32: Sequence diagram of the Android system ...................................................................... 50
Figure 33: Screenshot of the first thing displayed in the application ............................................. 51
Figure 34: Screenshot of the first message sent ................................................................................ 51
Figure 35: Screenshot of a conversation ............................................................................................ 52
Figure 36 : Pseudocode of MessageModal class................................................................................ 52
Figure 37: Pseudocode of the activity_main.xml file ........................................................................ 53
Figure 38:Pseudocode of the AndroidManifest.xml file................................................................... 54
Figure 39: Pseudocode of the MainActivity class and variables ..................................................... 54
Figure 40: Use case of the web system ............................................................................................... 55
Figure 41: Sequence diagram of the web system .............................................................................. 56
Figure 42: Screenshot of the closed chatbox ..................................................................................... 57
Figure 43: Screenshot of the opened chatbox ................................................................................... 57
Figure 44: Screenshot of the first message ........................................................................................ 58
Figure 45: Screenshot of a conversation ............................................................................................ 58
Figure 46: Pseudocode of the HTML file .......................................................................................... 59
Figure 47: The rest of the HTML pseudocode .................................................................................. 60
Figure 48: Pseudocode of the JavaScript file1 .................................................................................. 60
Figure 49: Pseudocode of the JavaScript file2 .................................................................................. 61
Figure 50: Pseudocode of the JavaScript file3 .................................................................................. 62
Figure 51: Pseudocode of the JavaScript file4 .................................................................................. 62
Figure 52: Admin ER diagram........................................................................................................... 64
Figure 53 : Users ER diagram ............................................................................................................ 64
Figure 54 : Unanswered ER diagram ................................................................................................ 64
Figure 55: Screenshot of the 5 frequent asks .................................................................................... 65
Figure 56: Screenshot of the vacation interface................................................................................ 65
Figure 57: Screenshot of the unanswered questions interface ........................................................ 66
Tables list

Table 1: Product backlog ...................................................................................................................... 8


Table 2: Advantages and disadvantages of rule-based chatbots ..................................................... 17
Table 3: Advantages and disadvantages of retrieval-based chatbots ............................................. 17
Table 4: Advantages and disadvantages of generative Chatbots .................................................... 18
Table 5: Advantages and disadvantages of hybrid chatbots ........................................................... 19
Table 6: Advantages and disadvantages of contextual chatbots ..................................................... 19
Table 7 : Actors table .......................................................................................................................... 41
Abbreviation list

NLP: natural language processing

AI: artificial intelligence

API: Application Programming Interface

DL: Deep learning

NLTK: Natural Language Toolkit

NLG: Natural language generation

ReLU: rectified linear unit

UTF: UCS (Unicode) Transformation Format


Chapter Ⅰ: Introduction
I.1. Introduction
This chapter presents the starting point for writing the report. First, we present the
context of the project, the motivation, the aim, and the objectives. Then the deliverables.
Afterward, the Gantt chart. Finally, we end up this chapter with the detailed methodology.

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.

Students can communicate with chatbots by using web browsers or smartphone


applications. Chatbots can be linked to current university systems. A variety of services can be
offered by chatbots, including answering frequently asked questions, offering individualized
support, and informing students of approaching deadlines. Chatbots can also gather
information, giving colleges the ability to see trends and make informed choices.

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.

The development of a contextual chatbot that deals with administration tasks in a


university has the potential to streamline administrative processes, reduce waiting times for
student inquiries, and provide quick and easy access to important information such as admission
requirements, news, teacher availability and financial aid, and others. By using machine
learning and natural language processing techniques, the chatbot can learn from user
interactions and improve its performance over time, making it an invaluable tool for universities
seeking to improve the overall student experience.

I.4. Aims and objectives


This project aims to contribute to the solution of the problem of direct communication
between students and the university.

The main objectives of the project are as follows:

 Database: To develop a database where all the relevant information about


questions, answers, and keywords will be stored. The knowledge base will be
updated regularly to ensure accuracy and relevance.

 Algorithm: To develop a keyword matching algorithm and a string distance


comparison algorithm and combine them to retrieve the best possible answer.

 Natural Language Processing (NLP): The chatbot will use NLP to understand
the user's intent and provide relevant responses.

 Machine Learning: The chatbot will utilize machine-learning algorithms to


continuously improve its performance and accuracy.

 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

 Admin Panel: An admin panel will be provided to allow an administrator to


manage the chatbot system. The admin panel will include features.

I.5. Deliverables
The deliverables for this project are as follows:

 A fully functional chatbot system that can interact with users through natural
language

 A web-based administration interface to manage the chatbot's responses and


settings.

 Documentation detailing the system's architecture, design, and implementation.

 Testing results showing the chatbot's accuracy and relevance.

 User training materials to help users interact with the chatbot effectively.

I.6. Gantt chart

Figure 1 : Tasks chart

Figure 2 : Gantt chart

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.

-Precision of the approaches to be used:

Discussion of various approaches and methods to be used, including consideration of


their potential advantages and disadvantages. We took 1 week for this part.

-Information planning and collecting:

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.

-Integration of the chatbot:

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.

-The web application:

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.

-The mobile application:

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.

-The admin panel:

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. Detailed methodology


In this section, we will explain the Scrum Method to elaborate on the application. this
section contains the definition, the team roles, organization events, the product backlog, and the
sprint plan.

I.7.1. Scrum method

I.7.1.1. Definition

Scrum in Agile is a process that allows software development teams to focus on


delivering business values in the shortest time by rapidly and repeatedly inspecting actual

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.

Figure 3 : SCRUM process

I.7.1.2. Team roles

The SCRUM methodology involves three main roles:

 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.

I.7.1.3. Organization Events

The SCRUM methodology defines the following key events:

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:

What did I do yesterday?

What will I do today?

What difficulties am I facing?

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.

I.7.1.4. Product Backlog

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.

Table 1 represents our product backlog.

7
Chapter 1 Introduction

Table 1: Product backlog

As I wish points priority

Administrator To create a machine learning model for user intent 8 High


classification

Administrator To perform text preprocessing for chatbot input 5 High

Administrator To train the machine learning model on 6 High


preprocessed data

Administrator Authentication 5 High

Administrator To integrate the chatbot with the mobile application 6 High

To integrate the chatbot with the web application

Administrator Manage the news 4 Medium

Administrator Manage the availability 4 Medium

Administrator Manage the valedictorian 4 Medium

Administrator Manage the unanswered questions 4 Medium

Administrator Access the statistics of the most 5 frequent 5 Medium


questions

Administrator Analyze chatbot performance 5 Medium

User To use the chatbot with a web interface 4 High

User To use the chatbot with a mobile interface 8 High

I.7.1.5. Sprint Plan

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 :

 Create a machine learning model for user intent classification (8 points)

8
Chapter 1 Introduction

 Perform text preprocessing for chatbot input (5 points)


 Train the machine learning model on preprocessed data (6 points)

Sprint 2:

 Integrate the chatbot with the mobile application (6 points)


 Integrate the chatbot with the web application (6 points)
 Manage the news (4 points)
 Manage the availability (4 points)

Sprint 3:

 Manage the valedictorian (4 points)


 Manage the unanswered questions (4 points)
 Access the statistics of the most 5 frequent questions (5 points)
 Analyze chatbot performance (5 points)

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.

II.2. Artificial intelligence:


II.2.1. Definition

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.

II.2.2. The different types of artificial intelligence:

II.2.2.1. Weak artificial intelligence:

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.

II.2.2.2. Strong artificial intelligence

Strong artificial intelligence aims to enable machines to imitate human cognitive,


sensory, and motor behaviors.

Machine learning:

10
Chapter 2 State of the Art

"Machine learning", or "apprentissage automatique" in French, is a computer


programming technique that uses statistical probabilities to give computers the ability to learn
by themselves without explicit programming.

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.

Finally, we can represent the different fields of study as nested as follows:

Figure 4 : The organization of the different disciplines

Deep Learning applications:

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.

Natural language processing: Natural language processing is another application of DL.


Its goal is to extract the meaning of words, or even sentences, in order to analyze feelings. The
algorithm will for example, understand what is said in a Google review, or will communicate
with people via chatbots. The automatic reading and analysis of texts is also one of the fields
of application of DL with Topic Modeling: such text addresses such subject.

II.3. Neural network:


II.3.1. Definition

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.

II.3.2. Types of neural network algorithms:

There are different deep learning algorithms, each with its own strengths and
weaknesses. Here are the most common algorithms:

Feedforward artificial neural networks:

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.

Perceptron and Multilayer Perceptron neural networks:

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.

II.4.1. Overview of Chatbots:

II.4.1.1. The Rise of Chatbots:

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.

Figure 5 is an example of the interface of the conversation with ELIZA;

13
Chapter 2 State of the Art

Figure 5: The chatbot of ELIZA

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 2001, the development of SmarterChild marked an important advancement in chatbot


technology. SmarterChild was available through messenger applications and was able to assist
people with simple tasks using information retrieved from databases.

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.

II.4.1.2. Classification of chatbots:

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

Chatbots can also be classified according to the permissions provided by the


development platforms. Open-source platforms make their code available so that developers
have control over most aspects of implementation. Closed platforms are of proprietary code and
are typically offered by large companies.

Finally, depending on the human-aid, chatbots can be classified into human-mediated


or fully autonomous chatbots. A human-mediated chatbot uses human computation in at least
one of six components. Fully automated chatbots are fast in processing information while
human computation provides flexibility and can help fill the gaps caused by the limitations of
algorithms.

Figure 6 below summarizes the classification criteria we discussed above

Figure 6 : Classification of chatbots

II.4.2. Types of chatbots:

These types of chatbots are based on the classification above specifically the response
generation method category.

Rule-based chatbots:

Rule-based chatbots, also known as decision-tree chatbots, rely on a predefined set of


rules and a fixed flow of conversation. These chatbots are programmed to respond to specific
keywords and phrases in a certain way. They follow a predetermined script that determines the
conversation flow. Table 2 represents the good and the bad things about rule-based chatbots

16
Chapter 2 State of the Art

Table 2: Advantages and disadvantages of rule-based chatbots

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:

A retrieval-based chatbot is a type of chatbot that uses pre-existing responses from a


database to generate responses to user inputs. These pre-existing responses can be in the form
of pre-defined text templates or frequently asked questions (FAQs) that are stored in a
knowledge base.

Retrieval-based chatbots use natural language processing (NLP) techniques to analyze


the user's input and match it with the most appropriate response from the database. The chatbot
then retrieves and presents the response to the user. Table 3 represents the good and the bad
things about retrieval-based chatbots

Table 3: Advantages and disadvantages of 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

Table 4: Advantages and disadvantages of 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

Table 5: Advantages and disadvantages of hybrid chatbots

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:

A contextual chatbot is an artificial intelligence-based software application that can


understand and interpret the context of a conversation with a user and provide relevant
responses based on that context. It can remember past interactions with the user and use that
information to improve the quality of the conversation. Contextual chatbots use natural
language processing and machine learning techniques to understand the user's intent and
provide appropriate responses.

Table 6 below represents the good and the bad things about contextual chatbots

Table 6: Advantages and disadvantages of 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

 Engage users in more meaningful more expensive than building a basic


chatbot, requiring more resources and
conversations, improving customer
expertise.
satisfaction and loyalty.
 Contextual chatbots may have limited scope
 Learn from previous interactions, and
in terms of the range of topics they can
adapt their responses to each user,
cover, and may not be able to handle all
increasing their accuracy and reducing
types of user requests.
errors.

II.4.3. Different ways for chatbots to work:

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.

II.4.4. Options to build a chatbot:

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.

II.4.5. Existing chatbots in the education sector:

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.

III.2. Project specification:


The chatbot aims to assist students with administrative tasks such as checking their class
schedules, getting information about campus events, and others.

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

 Students using chatbot before: 49.2% of students answered no and 50.8% of


students answered yes

 It is clear that most students of ISSAT Kairouan know what chatbot


means and half of them used it before

 The frequency of communication with the university’s administration: 42.5% of


students answered rarely, 16,7% of students answered weekly, 15% of students
said never,13.3 % of students said monthly, and 12.5% of students said daily

 Students rating their experiences communicating with the university’s


administration: half of the students answered with neutral, 25.8% of students
were positive, 12.5% of students were negative

23
Chapter 3 User requirement

 Students that experienced a delay in receiving support from the university:


53.3% answered yes while 46.7% answered no

 It is clear that students still depend on the university administration


even if half of them are not satisfied with the delay that always
happens

 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

 Students that think chatbots can enhance the overall university


experience:55.8% agree, 26.7% strongly agree and 15.8% are neutral

 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

III.2.2. Market Analysis:

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

III.2.3. Technical Feasibility:

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.

Furthermore, the availability of resources such as research papers, online


documentation, and academic support from our faculty members enhances the feasibility of our
project. We have access to a wide range of literature and guidance, enabling us to stay updated
with the latest advancements in the field and address any technical challenges that may arise.

In terms of project management, we are committed to following a structured approach.


By breaking down the project into manageable tasks and setting realistic milestones, we can
effectively track our progress and ensure that we stay on schedule. Regular communication and
collaboration between us will enable us to address any obstacles promptly and make necessary
adjustments along the way.

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.

In conclusion, we are confident in the technical feasibility of our graduation project.


With our skills, access to resources, and a well-structured plan, we have a strong foundation to
develop a functional and intelligent contextual chatbot for administration tasks. By adhering to

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 system must provide clear information about the orientation

The administrator must manage the plugins.

The administrator must see the unanswered questions work on them and add them to the intent

III.3.2. Non-functional requirements:

III.3.2.1. Performance/Response time requirement

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

III.3.2.2. Security requirements

The administrative system should be protected from unauthorized access.

26
Chapter 3 User requirement

The database should be protected from attacks and unauthorized access.

The interface should be protected from attacks.

III.3.2.3. Reliability 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.

III.3.2.4. Maintainability requirement

The chatbots must be able to be updated

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 system should have Data Training

III.3.2.5. Usability requirements

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.

IV.2. Logical architecture:


The classic architecture is the three-tier architecture as described in Figure 7. The
advantages of using this type of model are that the functionality is distributed across three
independent systems and also that any of the tiers can be replaced or upgraded independently
if the requirements or the technology change

Figure 7 : Logical architecture figure

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

IV.3. System architecture:


Chatbot architecture is the spine of the chatbot. The type of architecture for your chatbot
depends on various factors like use-case, domain, chatbot type, etc. However, the basic
conversation flow remains the same

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

IV.4. The Dataset


The developer is asked to provide data, typically written by hand: the training examples.
We have set up a JSON file, called "intents", which defines certain intentions that may occur
during interactions with our chatbot. To do this, we first need to create a set of tags in which
user queries can be classified.

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".

Tags and patterns:

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.

Responses related to patterns:

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 and the context set:

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

Figure 8: Pseudocode of an intent example

IV.5. The machine learning model


When it comes to talking about the machine learning model we have to talk about the
creation and the use of it that we did this through two files; the creation of the model is built in
the model.py file and the use of the model is made in the response.py. we will talk first about
the steps to this creation and after we will talk about the steps of the use

IV.5.1. The creation of the model

Figure 9: The steps for the creation of the model

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.

Removing Stop Words:

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.

Building a neural network:

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

Figure 10 : Pseudocode of building the neural network

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

Figure 11 : Pseudocode of starting the training

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.

IV.5.2. The use of the model

Figure 12 : Steps for the use of the model

Retrieving user input

The user sends a message and the message will be received by the system.

Loading of the model

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.

Figure 13: Pseudocode of the loading of the model

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.

Figure 14 : Pseudocode of loading and saving the TensorFlow model

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.

Figure 15: The use of the same neural network

Pre-processing

We do the same text tokenization, removing stop words and stemming just like we did in the
section above

Bag of words (BoW)

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.

Figure 16 : Pseudocode of the classify function

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.

Predicted probabilities below the defined ERROR_THRESHOLD are filtered out.


The remaining results are sorted in descending order of probability.
The function returns a list of intent-probability tuples.

The classify function:

classify(sentence) takes a sentence as input and generates probabilities using a pre-


trained model. The model predicts the probabilities based on the bag-of-words (BoW)
representation of the sentence. The results are obtained by applying the model's predict()
function on the BoW representation of the input sentence.

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

Performance is a crucial aspect of any chatbot system, as it directly impacts user


satisfaction and the overall effectiveness of the solution. To assess the performance of our
chatbot, a test was conducted wherein 25 messages from users were presented to the chatbot.
The results of this test revealed that the chatbot successfully provided responses to 18 of the
messages, which accounts for a success rate of 72%. However, it failed to understand and
generate appropriate answers for the remaining 7 messages, indicating a failure rate of 28%.

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.

IV.6. How the contextual chatbot work:


The functionality of our contextual chatbot revolves around leveraging the concept of
context to provide accurate and relevant responses to user queries. By maintaining a context
stack and utilizing context_set and context_filter techniques, our chatbot ensures a cohesive
and intelligent conversation flow.

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.

By employing context_set and context_filter techniques, our chatbot can provide


intelligent, context-aware responses that enhance the overall user experience. The utilization of
the context stack enables the chatbot to maintain a coherent and continuous conversation, taking
into account the user's previous queries and providing relevant information based on the context
at hand.

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.

IV.7. Selection of technologies:


Several technologies and libraries were investigated for the development of this project
and the following were identified as the ones to be used for creating the system

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.

TensorFlow: TensorFlow is an open-source machine learning library developed by Google. It


is used to build and train various types of machine learning models, including deep learning
models, and is designed to be scalable and efficient.

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.

IV.8. Chatbot plugins:


IV.8.1. Use case diagram of the chatbot

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

Figure 17 : Use case diagram of the 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 :

IV.8.2.1. The function

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.

The following Figure 18 is a pseudocode of this function

41
Chapter 4 Chatbot

Figure 18: Pseudocode of the availability plugin

IV.8.2.2. The sequence diagram

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.

The following Figure 19 is the sequence diagram of the availability plugin

Figure 19: Sequence diagram of the availability plugin

42
Chapter 4 Chatbot

IV.8.2.3. The ER diagram

An Entity-Relationship (ER) diagram is a visual representation of the entities. The


following Figure 20 is the ER diagram of the availability plugin

Figure 20 : The ER diagram of the availability plugin

IV.8.3. Vacation

IV.8.3.1. The function

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.

The following Figure 21 is a pseudocode of this function

Figure 21 : Pseudocode of the vacation plugin

IV.8.3.2. The sequence diagram

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.

The following Figure 22 is the sequence diagram of the vacation plugin

Figure 22 : Sequence diagram of the vacation plugin


IV.8.3.3. The ER diagram

The following Figure 23 is the ER diagram of the vacation plugin

Figure 23 : ER diagram of the vacation plugin

IV.8.4. News:

IV.8.4.1. The function

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.

The following Figure 24 is a pseudocode of this function

44
Chapter 4 Chatbot

Figure 24: Pseudocode of the news plugin

IV.8.4.2. The sequence diagram.

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

The following Figure 25 is the sequence diagram of the news plugin

Figure 25 : Sequence diagram of the news plugin

45
Chapter 4 Chatbot

IV.8.4.3. The ER diagram

The following Figure 26 is the ER diagram of the news plugin

Figure 26 : ER diagram of the news plugin

IV.8.5. Valedictorian

IV.8.5.1. The function

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 following Figure 27 is a pseudocode of this function

Figure 27: Pseudocode of the valedictorian plugin

IV.8.5.2. The sequence diagram

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

The following Figure 28 is the sequence diagram of the valedictorian plugin

Figure 28 : Sequence diagram of the valedictorian plugin


IV.8.5.3. The ER diagram

The following Figure 29 is the ER diagram of the valedictorian plugin

Figure 29 : ER diagram of the valedictorian plugin

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.

V.2. Android system:


The Android system of the chatbot front-end application is designed to provide a
mobile-friendly interface, allowing users to interact with the chatbot on their Android devices.
It leverages the capabilities of the Android platform to deliver a seamless and intuitive user
experience.

V.2.1.The UML use case Diagram:

Figure 30 below represents the use case diagram of the Android system

Figure 30: Use case diagram of the Android system

V.2.2. The UML class diagram

Figure 31 below represents the class diagram of the Android system

48
Chapter 5 The front-end application

Figure 31: Class diagram of the Android system

V.2.3.The Sequence diagram

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.

Figure 32 below represents the sequence diagram of the Android system

49
Chapter 5 The front-end application

Figure 32: Sequence diagram of the Android system

V.2.4.Graphical User Interface:

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

Figure 33: Screenshot of the first thing displayed in the application

Figure 34 below represents the screenshot of the first message

Figure 34: Screenshot of the first message sent

Figure 35 below represents a screenshot of a conversation.

51
Chapter 5 The front-end application

Figure 35: Screenshot of a conversation

V.2.5.Implementation:

Figure 36 below represents the pseudocode of the MessageModel class

Figure 36 : Pseudocode of MessageModal class

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

Figure 37: Pseudocode of the activity_main.xml file

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.

Figure 38 below represents the pseudocode of the XML AndroidManifest file

53
Chapter 5 The front-end application

Figure 38:Pseudocode of the AndroidManifest.xml file

This is the AndroidManifest.xml file, which is an important configuration file for an


Android application. It provides essential information about the application to the Android
operating system

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.

Figure 39 below represents the MainActivity class of the Android system

Figure 39: Pseudocode of the MainActivity class and variables

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

V.3. Web system


The web system of the chatbot front-end application is designed to be accessible through
web browsers, allowing users to interact with the chatbot from their desktop or mobile devices.
It provides a user-friendly interface and seamless communication with the chatbot's backend
services.

V.3.1.The UML use case Diagram

Figure 40 below represents the use case diagram of the web system

Figure 40: Use case of the web system

V.3.2.The Sequence diagram

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.

Figure 41 below represents the sequence diagram of the web system

55
Chapter 5 The front-end application

Figure 41: Sequence diagram of the web system

V.3.3.Graphical User Interface

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 42 below represents a screenshot of the chatbox when it is closed

Figure 42: Screenshot of the closed chatbox

Figure 43 below represents a screenshot of what is displayed in the chatbox before any
message

Figure 43: Screenshot of the opened chatbox

57
Chapter 5 The front-end application

Figure 44 below represents a screenshot of the first message displayed in the chatbox

Figure 44: Screenshot of the first message

Figure 45 below represents a screenshot of a conversation

Figure 45: Screenshot of a conversation

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 chatbox consists of two main sections: "chatbox__support" and "chatbox__button".


The "chatbox__support" section contains the header, messages, and footer of the chatbox. The
header includes an image and text introducing the chatbot, while the messages section displays
the conversation history. The footer contains an input field for the user to type their message
and a send button.

The "chatbox__button" section represents a minimized version of the chatbox, displayed


as a button. Clicking on this button expands the chatbox to its full size, allowing the user to
interact with the chatbot.

Figure 46: Pseudocode of the HTML file

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

Figure 47: The rest of the HTML pseudocode

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.

Figure 48: Pseudocode of the JavaScript file1

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.

Figure 49: Pseudocode of the JavaScript file2

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

Figure 50: Pseudocode of the JavaScript file3

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.

Figure 51: Pseudocode of the JavaScript file4

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.

VI.2. The ER diagram:


The following Figure 52, Figure 53, and Figure 54 represent the entities used in the
dashboard administration system

Figure 52: Admin ER diagram

Figure 53 : Users ER diagram

Figure 54 : Unanswered ER diagram

64
Chapter 6 The administration Dashboard

VI.3. Usage statistics:


Figure 55 below represents the interface of the most five frequent questions. It is a chart
that is changing, it will help the administrator know what questions have to work on more.

Figure 55: Screenshot of the 5 frequent asks

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

Figure 56: Screenshot of the vacation interface

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.

VI.4. New features extraction

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

In this case, the administrator could only delete

Figure 57: Screenshot of the unanswered questions interface

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.

VII.2. Overall strengths


 Increased Efficiency: The chatbot can automate routine administrative tasks, such as
vacation calendar, News about the university, and valedictorian. This reduces the need
for manual processing and allows students to access information quickly and
conveniently.
 24/7 Availability: Unlike human administrators, the chatbot can operate round-the-
clock, assisting students at any time. This enhances accessibility, especially for those
who have scheduling conflicts or urgent queries outside regular office hours.
 Scalability: The chatbot can handle multiple student inquiries simultaneously, without
being limited by the constraints of human resources. This scalability ensures that all
students receive prompt responses and reduces waiting times.

VII.3. Overall weaknesses


 Limited Contextual Understanding: Chatbots often struggle to comprehend complex or
nuanced queries that require context or human judgment. As a result, the chatbot may

67
Chapter 7 Conclusion and future work

provide generic or incomplete responses, leading to student frustration or


misunderstanding.
 Lack of Personal Touch: Unlike face-to-face interactions with human administrators,
the chatbot may lack the personal touch and empathy that some students may seek
during sensitive or emotionally challenging situations. This could potentially affect the
overall student experience.
 Technical Limitations: The chatbot's effectiveness heavily relies on its underlying
technology and natural language processing capabilities. If the system encounters
technical issues or fails to understand student queries accurately, it may lead to errors
or incomplete assistance.

VII.4. Future works


In the future, we see potential in expanding the chatbot's capabilities by integrating it
with other university systems and developing new interfaces for additional administrative
tasks. Furthermore, we can continue to refine and improve the chatbot's responses by
leveraging machine-learning techniques and incorporating user feedback

Several algorithms should be implemented, tested, and evaluated. Template matching


has priority, but combinations of algorithms can also be considered, each assigned a specific
percentage. Uploading individual implementations to a web server and collecting user
feedback can help identify algorithm limitations and determine the best solution, which may
involve combining multiple algorithms.

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.

Finally, in terms of spell checking, if an error is detected, it is beneficial to provide a


hyperlinked version of the corrected sentence to ensure a better and faster user experience. To
address situations where users ask multiple questions at once, specific rules can be used to
provide individual answers, or users can be required to submit only one question at a time.

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

You might also like