1. Trang chủ
  2. » Luận Văn - Báo Cáo

(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning

117 8 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Developing a Virtual Sales Assistant Using Deep Learning
Tác giả Ho Quoc Dat, Vo Thanh Van
Người hướng dẫn TRAN NHAT QUANG, PhD
Trường học Ho Chi Minh City University of Technology and Education
Chuyên ngành Information Technology
Thể loại Capstone project
Năm xuất bản 2021
Thành phố Ho Chi Minh City
Định dạng
Số trang 117
Dung lượng 4,7 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Cấu trúc

  • Chapter 1: INTRODUCTION (15)
    • 1.1. The reason for choosing the topic (15)
    • 1.2. Goals (15)
    • 1.3. Technologies (15)
  • Chapter 2: LITERATURE REVIEW (16)
    • 2.1. MERN stack (16)
    • 2.2. Deep Learning (18)
    • 2.3. Chatbot (18)
      • 2.3.1. Definition (19)
      • 2.3.2. Building a Chatbot (19)
      • 2.3.3. Advantages of Chatbot (19)
      • 2.3.4. Disadvantages of chatbot (19)
    • 2.4. Virtual assistant (20)
      • 2.4.1. Definition (20)
      • 2.4.2. The advantages of virtual assistants set up in chatbot (20)
    • 2.5. Text-To-Speech platforms (21)
      • 2.5.1. FPT API Text-To-Speech (21)
      • 2.5.2. ZALO API Text-To-Speech (21)
  • Chapter 3: THEORETICAL BASIS (22)
    • 3.1. Deep Learning (22)
      • 3.1.1. Python programming language (22)
      • 3.1.2. Tensorflow (22)
      • 3.1.3. Keras (25)
      • 3.1.4. Natural language processing and the NLTK library (25)
      • 3.1.5. Underthesea – A Vietnamese NLP Toolkit (28)
      • 3.1.6. FastAPI (29)
    • 3.2. Technologies for website building (31)
      • 3.2.1. React Library (31)
      • 3.2.2. MongoDB (31)
      • 3.2.3. Node js (31)
      • 3.2.4. Express framework (31)
      • 3.2.5. Socket.IO (32)
  • Chapter 4: SYSTEM DESIGN (33)
    • 4.1. System Architechture (33)
    • 4.2. System design (33)
      • 4.2.1. Database Design (33)
      • 4.2.2. Sequence Diagram (35)
      • 4.2.3. Use Case Diagram (40)
      • 4.2.4. Use Case Description (41)
      • 4.2.5. User Interface Design (68)
        • 4.2.5.1. Screens for unauthenticated users (68)
        • 4.2.5.2. Screens for customers (72)
        • 4.2.5.3. Screens for admins (74)
    • 4.3. Chatbot system (77)
      • 4.3.1. General system (77)
      • 4.3.2. Details of each part (79)
  • Chapter 5: SYSTEM IMPLEMENTATION (90)
    • 5.1. Software development environments (90)
    • 5.2. Source code management (90)
    • 5.3. Deployment environment (90)
      • 5.3.1. Deploying the website on Heroku (90)
      • 5.3.2. Deploying the Chatbot API on Google Cloud Platform (93)
    • 5.4. Built screens (103)
      • 5.4.1. Home Screen (103)
      • 5.4.2. Product Screen (104)
      • 5.4.3. Cart Screen (104)
      • 5.4.4. Place Order Screen (105)
      • 5.4.5. Welcome interface of Chatbot (105)
      • 5.4.6. Chatbot (106)
      • 5.4.7. List Question Screen (Admin) (106)
      • 5.4.8. Edit Question Screen (Admin) (107)
      • 5.4.9. List Dataset Screen (Admin) (107)
      • 5.4.10. Edit Dataset Screen (Admin) (108)
      • 5.4.11. Create New Dataset Screen (Admin) (108)
  • Chapter 6: CONCLUSION (109)
    • 6.1. Conclusion (109)
    • 6.2. Advantages (111)
    • 6.3. Disadvantages (112)
    • 6.4. Development directions (112)

Nội dung

(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning(Đồ án tốt nghiệp) Developing a virtual sales assistant using deep learning

INTRODUCTION

The reason for choosing the topic

The global spread of the coronavirus has made close contact risky, leading to restrictions on direct interaction As a result, businesses, especially retail stores, have shifted to online sales and shipping services to continue operations To meet this growing demand, advancements in technology are essential to enhance customer service in e-commerce The development of 4.0 technology has introduced AI-powered chatbots, which simulate direct communication with customers for a seamless shopping experience Consequently, the implementation team has decided to integrate a chatbot system into the e-commerce website to improve user engagement and support.

Goals

Create a virtual sales staff to advise products on a website selling clothes using deep learning:

• Find out the features and functions required for a virtual salesperson

• Learn and install a deep learning model for text processing and text-to-speech conversion: model, how it works, settings, training

• Learn and build basic Vietnamese communication dataset for website selling clothes

Build a website selling clothes with the functions of a sales website, integrating the communication interface between virtual sales staff and customers:

• Find out the features and install the required functions on a website Online selling

• Learn and install the appropriate technologies used to develop the website

• Learn and use appropriate frameworks and UIs for websites.

Technologies

Implementation using Reactjs, Nodejs, MongoDB, Express, Python, Tensorflow 2.5, NLTK, FastAPI

LITERATURE REVIEW

MERN stack

MERN stands for MongoDB, Express, React, Node, after the four key technologies that make up the stack

- Express(.js) - Node.js web framework

- React(.js) - a client-side JavaScript framework

- Node(.js) - the premier JavaScript web server

The MERN architecture allows us to easily construct a 3-tier architecture (frontend, backend, database) entirely using JavaScript and JSON

Figure 2.1 The MERN stack architecture

React.js is a top-tier component of the MERN stack, serving as a powerful, declarative JavaScript framework for developing dynamic, client-side applications in HTML It enables developers to create complex user interfaces by assembling simple, reusable components, which can seamlessly connect to backend data sources and render updated, interactive HTML content for an optimal user experience.

Express.js is a fast, unopinionated, minimalist web framework for Node.js that operates as the server-side tier within a Node.js environment It offers powerful URL routing capabilities, making it a popular choice for building efficient and scalable server applications.

(matching an incoming URL with a server function), and handling HTTP requests and responses

In a React.js and Express.js application, JSON documents generated on the front end are transmitted to the server, where they are processed and stored efficiently in MongoDB This setup enables seamless data management, allowing for easy retrieval and manipulation of data stored within the MongoDB database Utilizing MongoDB as your database tier ensures flexible, scalable, and JSON-friendly data storage, optimizing your application's performance and responsiveness.

MERN is a full-stack web development framework based on the traditional 3-tier architectural pattern, integrating the front-end display tier with React.js, the application tier with Express.js and Node.js, and the database tier using MongoDB As a popular choice among modern web developers, MERN enables rapid development and streamlined workflow, especially for those skilled in React.js This powerful stack is ideal for building dynamic, scalable web applications efficiently.

Deep Learning

Deep learning is a subset of machine learning algorithms that utilize multiple layers to progressively extract higher-level features from raw input data For instance, in image processing, lower layers typically identify basic features like edges, while higher layers recognize more complex concepts such as digits, letters, or faces This layered approach enables deep learning models to understand and interpret complex data with remarkable accuracy.

Deep learning architectures—including deep neural networks, deep belief networks, graph neural networks, recurrent neural networks, and convolutional neural networks—have been successfully applied across various fields such as computer vision, speech recognition, natural language processing, and machine translation These advanced models have also made significant impacts in bioinformatics, drug design, medical image analysis, material inspection, and board game programs Their capabilities have achieved results comparable to, or in some cases surpassing, human expert performance, demonstrating the transformative potential of deep learning technologies.

Chatbot

• Chatbot is a software application used to conduct an online chat conversation via text or text-to-speech, in lieu of providing direct contact with a live human agent

Chatbot systems are engineered to convincingly mimic human conversational behavior, but they require ongoing tuning and testing to achieve optimal performance Despite advancements, many deployed chatbots still struggle to engage effectively or pass industry-standard assessments like the Turing test.

• Translator: Translating the user's request, helping the computer understand the request it needs to perform → deciding whether the chatbot is smart or not

• Processor: Processing requests, this component helps the ability of the chatbot to be unlimited, whatever the computer can do, the chatbot can also do the same

• Respondent: Receives output and encapsulates it and sends it back to the message platform, returning the result to the user

• Always online 24/7 and quickly respond to all customer requests

• Handle many inbox customers at the same time without confusion

• Instruct customers to use the website to make purchases

• Stimulate buying behavior and increase sales efficiency

Reactive chatbots often struggle to understand unfamiliar queries, as they are limited to their pre-trained knowledge When a customer's question falls outside their programmed responses, the chatbot can become stuck, leading to frustration and a poor user experience.

Installation costs for chatbots can be significant, as these intelligent programs are designed to provide 24/7 customer support and handle multiple inquiries simultaneously However, unlike human staff, each chatbot requires customized programming tailored to the specific needs of your business, which can increase initial setup expenses Additionally, training and fine-tuning your chatbot demands time and resources, so it's important to consider these factors when evaluating the overall investment in chatbot deployment.

To ensure a positive user experience, it's essential to set clear expectations about chatbot capabilities, as misaligned expectations can lead to disappointment Clearly communicate what the chatbot can and cannot do to prevent misunderstandings Keep in mind that chatbots are not magical solutions and have limitations, so transparency about their functions is key for effective interactions Proper expectation management enhances user satisfaction and promotes realistic use of chatbot technology.

Virtual assistant

• An intelligent virtual assistant (IVA) or intelligent personal assistant (IPA) is a software agent that can perform tasks or services for an individual based on commands or questions

A "chatbot" can refer broadly to virtual assistants or more specifically to those accessed through online chat Some chat programs serve purely entertainment purposes, while advanced virtual assistants can interpret human speech and respond with synthesized voices Users can interact with these assistants to ask questions, control home automation devices, manage media playback via voice commands, and handle tasks such as emails, to-do lists, and calendar management using spoken instructions.

2.4.2 The advantages of virtual assistants set up in chatbot

• Speech to text: STT is a technology that helps computers recognize the sound of human voices through microphne and create corresponding text strings

• STT technology used in the project from SpeechRecognition by Web Speech API javacript

• Text to Speech: TTS is a natural language and text understanding technology based on artificial intelligence to create complete synthetic sounds with appropriate rhythm and intonation

The project utilizes Zalo AI API's Text-to-Speech (TTS) technology, specifically the Zalo Text-To-Speech (ZTTS) engine, which converts Vietnamese text into high-quality, rapid audio output Designed for real-time and high-volume applications, ZTTS is ideal for news websites, voice streaming services, chatbots, and virtual assistants The engine currently offers four Vietnamese voices, featuring two Northern and two Southern accents, ensuring natural and regional linguistic accuracy.

Text-To-Speech platforms

2.5.1 FPT API Text-To-Speech

FPT.AI Text to Speech offers advanced speech synthesis, a core feature of many AI systems Developed over nearly 8 years by FPT Technology Innovation Department, FPT Speech Synthesis is recognized as the most comprehensive Vietnamese language voice system available today.

2.5.2 ZALO API Text-To-Speech

Zalo Text-To-Speech (ZTTS) engine provides fast, high-quality audio output from Vietnamese text, making it ideal for real-time and high-volume applications like news websites, voice streaming services, chatbots, and virtual assistants Optimized for efficiency, ZTTS currently offers four Vietnamese voices, featuring two Northern and two Southern accents to enhance naturalness and regional accuracy.

THEORETICAL BASIS

Deep Learning

Python is a high-level programming language for general-purpose programming Python was created by Guido van Rossum and first released in 1991 a Advantages

Python is renowned for its readability, ease of learning, and simplicity, making it an ideal programming language for beginners Its clear and intuitive structure facilitates quick understanding and efficient coding, often requiring minimal keystrokes Widely used in artificial intelligence (AI) development, Python's user-friendly design and versatility have made it a popular choice among developers worldwide.

• In July 2018, Van Rossum stepped down as leader in the Python language community after 30 years of work b Disadvantages

Python lacks explicit access modifiers like protected, private, or public, and does not support constructs like switch-case statements; instead, it uses different approaches such as if-elif chains While Python offers faster processing speeds than PHP, it generally does not match the performance levels of Java or C++ Additionally, Python's version updates introduce new features and improvements that enhance its usability and efficiency.

• Since 1994, Python has had 3 versions: Python 1, Python 2, Python 3 [7]

TensorFlow is a free, open-source machine learning library designed for a wide range of applications, with a primary focus on training and deploying deep neural networks It enables developers to build and optimize complex models efficiently, making it a popular choice in the AI and machine learning communities.

• TensorFlow is a symbolic math library based on dataflow and differentiable programming It is used for both research and production at Google

• TensorFlow was developed by the Google Brain team for internal Google use It was released under the Apache License 2.0 in 2015 [8]

• Graphs: TensorFlow has better computational graph visualizations, which are inherent when compared to other libraries like Torch and Theano

• Library management: Google backs it And it has the advantages of seamless performance, quick updates, and frequent new releases with new features

• Debugging: It helps us execute subpart of a graph which gives it an upper hand as we can introduce and retrieve discrete data

• Scalability: The libraries are deployed on a hardware machine, which is a cellular device to the computer with a complex setup

• Pipelining: TensorFlow is designed to use various backend software (GPUs, ASIC), etc And also, highly parallel

• It has a unique approach that allows monitoring the training progress of our models and tracking several metrics

• TensorFlow has excellent community support

• Its performance is high and matches the best in the industry b Disadvantages

Handling variable-length sequences requires specific features, which are often missing in TensorFlow Since TensorFlow does not provide built-in support for symbolic loops necessary for this purpose, finite folding emerges as the most effective solution to manage variable-length data efficiently.

TensorFlow does not officially support Windows, which may be a concern for users who prefer the Windows environment over Linux However, Windows users can still successfully install TensorFlow using tools like Conda or Python's package manager (pip), ensuring compatibility and ease of use on their preferred operating system.

• Benchmark tests: TensorFlow lacks in both speed and usage when it is compared to its competitors

• No GPU support for Nvidia and only language support: Currently, the single supported GPUs are NVIDIA and the only full language support

10 of Python, which makes it a drawback as there is a hike of other languages in deep learning as well as the Lau

• Computation Speed: This is a field where TF is delaying behind, but we focus on the production environment ratherish than the performance, it is still the right choice

• It requires fundamental knowledge of advanced calculus and linear algebra along with a good understanding of machine learning also

• TensorFlow has a unique structure, so it's hard to find an error and difficult to debug

• There is no need for any super low-level matter

• It is a very low level with a steep learning curve [9] c Version

• Tensorflow is now upgraded to version 2.x:

• Usability-related modifications: simpler to use APIs, up-to-date documentation and many pre-built data sources for learning and research TensorFlow

• Performance-related modifications: Based on training and inference results on CPU and GPU processors, on average, TensorFlow 2.0 has 2x better performance than TensorFlow 1.x

• Deployment-related modifications: Allows developers to quickly and efficiently build and deploy ML applications [10]

Keras is an open-source Python library designed for building and training artificial neural networks, serving as a user-friendly interface for the TensorFlow framework Developed and maintained by Google engineer François Chollet, Keras simplifies the process of designing deep learning models, making it accessible for researchers and developers Chollet is also renowned for creating the XCeption deep neural network architecture, further highlighting his contribution to the field of AI and deep learning.

• Up until version 2.3, Keras supported multiple backends, including TensorFlow, Microsoft Cognitive Toolkit, Theano, and PlaidML

• As of version 2.4, only TensorFlow is supported Designed to enable fast experimentation with deep neural networks, it focuses on being user- friendly, modular, and extensible [11] a Advantages

Keras offers a user-friendly API that facilitates fast and straightforward deployment of neural network models, making it ideal for both beginners and experienced developers Its simplicity allows for quick implementation of deep learning algorithms and natural language processing tasks, accelerating project development and enhancing productivity.

We can build a neural network model in just a few lines of code

• Quality Documentation and Large Community Support

• Pretrained models: Keras provides some deep learning models with their pre-trained weights We can use these models directly for making predictions or feature extraction

• Problems in low-level API

• Need improvement in some features

3.1.4 Natural language processing and the NLTK library a Definition

Natural language processing (NLP) is a crucial subfield of linguistics, computer science, and artificial intelligence focused on enabling computers to understand and analyze human language It involves developing algorithms and systems that can process large quantities of natural language data, facilitating improved human-computer interactions NLP's applications range from language translation and sentiment analysis to voice recognition and chatbots, making it essential for advancing intelligent technology.

Natural Language Processing (NLP) aims to develop computers that can "understand" the content and contextual nuances of documents This technology enables accurate extraction of information and insights from texts, while also efficiently categorizing and organizing documents for improved data management and analysis.

The Natural Language Toolkit (NLTK) is a comprehensive suite of libraries and programs designed for symbolic and statistical natural language processing (NLP) in English Built using the Python programming language, NLTK offers powerful tools for analyzing and understanding human language, making it a fundamental resource for NLP projects.

• It was developed by Steven Bird and Edward Loper in the Department of Computer and Information Science at the University of Pennsylvania

Tokenization is a fundamental process in natural language processing that involves dividing large amounts of text into smaller units called tokens These tokens enable the identification of patterns within the text and serve as a crucial first step for techniques like stemming and lemmatization Additionally, tokenization aids in replacing sensitive data with non-sensitive equivalents, enhancing data privacy and security in text analysis.

• Summary, method word_tokenize() to split a sentence into words c Bag-of-words

The bag-of-words model is a simplified representation widely used in natural language processing (NLP) and information retrieval (IR) It transforms text into a format suitable for analysis, such as tokenizing the phrase "Xin chào quí khách" into individual words like "Xin," "chào," "quí," and "khách," facilitating tasks like text classification and search.

The bag-of-words model represents text, such as sentences or documents, as a multiset of words, ignoring grammar and word order while preserving word frequency, making it a valuable approach in natural language processing Additionally, this model has been successfully applied in computer vision tasks, demonstrating its versatility across different fields Techniques like stemming are often used to normalize word forms and improve model performance.

Stemming is a fundamental technique in natural language processing that reduces words to their root or base form This process involves removing suffixes and other word endings that indicate different variations, allowing for more effective text analysis and search optimization By converting words like "running," "runs," and "ran" to their common root "run," stemming enhances the accuracy of keyword matching and improves SEO performance Implementing this method helps in creating more consistent data sets, making it a vital tool for various language processing applications.

Stemming processors, also known as stemmers, are tools that reduce words like walked, walking, and walks to their root form, "walk," by removing suffixes such as -ed, -ing, or -s This process simplifies variations of a word, improving keyword consistency and enhancing SEO effectiveness in search engine optimization.

➢ Because the working principle of the stemmer is so simple, its processing speed is very fast, and the stem result is sometimes not what we want

Technologies for website building

React, also known as React.js or ReactJS, is an open-source front-end JavaScript library designed for building user interfaces and UI components Maintained by Facebook and a dedicated community of developers and companies, React is widely used for developing single-page and mobile applications While React handles state management and rendering components to the DOM, it typically requires additional libraries for routing and other client-side functionalities, making it a flexible foundation for comprehensive web app development.

MongoDB is a versatile, cross-platform document-oriented database program that is classified as a NoSQL database It utilizes JSON-like documents with optional schemas, providing flexibility for diverse data structures Developed by MongoDB Inc., this powerful database software is licensed under the Server-Side Public License (SSPL), ensuring open-source accessibility and robust performance for modern applications.

Node.js is an open-source, cross-platform JavaScript runtime environment that enables developers to execute JavaScript code outside of web browsers, primarily for server-side scripting and command-line tools It allows for the development of dynamic web pages by running server-side scripts that generate content before transmission to the user's browser Embracing the "JavaScript everywhere" approach, Node.js unifies web application development by using a single programming language for both client-side and server-side scripting, simplifying the development process and enhancing efficiency.

Express.js, also known as Express, is a popular back-end web application framework for Node.js, released as free and open-source software under the MIT License It is specifically designed for building scalable web applications and APIs, making it a preferred choice among developers Often referred to as the de facto standard server framework for Node.js, Express simplifies the development process and enhances the performance of server-side applications.

Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server It consists of:

- A Javascript client library for the browser (which can be also run from Node.js)

Here are the features provided by Socket.IO over plain WebSockets:

- Reliability (fallback to HTTP long-polling in case the WebSocket connection cannot be established)

- Broadcasting to all clients or to a subset of clients (what we call “Room”)

- Multiplexing (what we call “Namespace”) [24]

SYSTEM DESIGN

System Architechture

System design

The project includes three tables: Order, User, Product Database is designed on MongoDB, so there is not connection between the tables

Figure 4.2 Tables in the database

4.2.2.1 Add product to cart

Figure 4.4 Sequence diagram for placing orderFigure 4.3 Sequence diagram for adding product to cart

Figure 4.5 Sequence diagram for making payment

4.2.2.4 Chat with Virtual bot

Figure 4.6 Sequence diagram for chatting with virtual bot

Figure 4.7 Sequence diagram for chatting with admin

Figure 4.8 Sequence diagram for updating question

Figure 4.9 Usecase diagram for system Table 4.1 Actors in usecase diagram

Unauthenticated user Who does not login to the system

Customer Who logged in into the system using a customer account

Admin Who logged in into the system using an admin account

Figure 4.10 Usecase diagram for searching product Table 4.2 Usecase description for searching product

Use Case No CHOPPER_UC_01 Use Case Version 1.0

Use Case Name Search product

- Allow to user search product

- User can search products in web

- User inputs a text to the search input field

- User clicks “Search” icon or press “Enter”

- Success: The system will navigate to Search Result Screen and return products which match the text in the search input field

- Fail: System shows error messages

Step Actor Action System Response

1 User inputs a text to the search input field

2 User clicks “Search” icon or press

The system will navigate to Search Result Screen and return products which match the text in the search input field

No Actor Action System Response

Figure 4.11 Usecase diagram for sorting product

Table 4.3 Usecase description for sorting product

Use Case No CHOPPER_UC_02 Use Case Version 1.0

Use Case Name Sort product

- Allow to user sort products

- Users can sort products after searching

- The user clicks sort dropdown

- The user selects an option in sort dropdown

- Success: The system will sort products base on customer’s choice

- Fail: System shows error messages

Step Actor Action System Response

1 The user clicks sort dropdown The sort of dropdown will display options

2 The user selects an option in sort dropdown

The system will sort products base on user’s choice

No Actor Action System Response

4.2.4.3 Chat with bot

Figure 4.12 Usecase diagram for chatting with bot Table 4.4 Usecase description for chatting with BOT

Use Case No CHOPPER_UC_03 Use Case Version 1.0

Use Case Name Chat with BOT

- Allow to user chat with a virtual bot

- Users can chat with a virtual bot

- The user clicks on the “Message” icon

- The user writes text in the input or clicks “Micro” icon and says something

- The user clicks “Send” icon or presses “Enter”

- Success: The system responses a message based on the input of the customer and reads the content of the response

- Fail: System shows error messages

Step Actor Action System Response

1 The user clicks on the “Message” icon

The system will display options in dropdown box

2 The user writes text in the input or clicks “Micro” icon and says something

3 The user clicks “Send” icon or presses “Enter”

The system responses a message based on the input of the customer and reads the content of the response

No Actor Action System Response

4 The user clicks “Send” icon or presses

4.2.4.4 Add product to cart

Figure 4.13 Usecase diagram for adding product to cart Table 4.5 Usecase description for adding product to cart

Use Case No CHOPPER_UC_04 Use Case Version 1.0

Use Case Name Add product to cart

- Allow to customer add products to cart

- Customers can add products to cart

- The customer clicks “Add to cart” button

- Success: The system will add this product into cart and navigate to Cart Screen

- Fail: System shows error messages

Step Actor Action System Response

1 The customer selects a product The system will navigate to Product

2 The customer clicks “Add to cart” button

The system will add this product into cart and navigate to Cart Screen

No Actor Action System Response

1 Customer selects a product System shows error messages

Figure 4.14 Usecase diagram for adding shipping address

Table 4.6 Usecase description for adding shipping address

Use Case No CHOPPER_UC_05 Use Case Version 1.0

Use Case Name Add shipping address

- Allow to customer add shipping address

- Customers can add shiping address for payment

- The customer inputs the shipping address information

- The customer clicks “Continue” button

- The customer must complete the “Add to cart” action

- All field input must not be empty

- Success: The system will save the shipping address and navigate to Payment Method Screen

- Fail: System shows error messages

Step Actor Action System Response

1 The customer inputs the shipping address information

2 The customer clicks “Continue” button

The system will save the shipping address and navigate to Payment Method Screen

No Actor Action System Response

2 The customer clicks “Continue” button

- The customer must complete the “Add to cart” action

- All field input must not be empty

Figure 4.15 Usecase diagram for choosing a payment method Table 4.7 Usecase description for choosing a payment method

Use Case No CHOPPER_UC_06 Use Case Version 1.0

Use Case Name Choose a payment method

- Allow to customer choose a payment method

- Customers can choose payment method for payment

- The customer chooses a payment method

- The customer clicks “Continue” button

- The customer must complete the “Add shipping address” action

- Success: The system will save the payment medthod and navigate to Place Order

- Fail: System shows error messages

Step Actor Action System Response

1 The customer inputs the shipping address information

2 The customer clicks “Continue” button

The system will save the shipping address and navigate to Place Order Screen

No Actor Action System Response

2 The customer clicks “Continue” button

- The customer must complete the “Add shipping address” action

Figure 4.16 Usecase diagram for placing order Table 4.8 Usecase description for placing order

Use Case No CHOPPER_UC_07 Use Case Version 1.0

Use Case Name Place order

- Allow to customer place order

- The customer clicks “Place Order” button

- The customer must complete the “Choose payment method” action

- Success: The system will create a new order and navigate to Order Screen

- Fail: System shows error messages

Step Actor Action System Response

1 The customer clicks “Place Order” button

The system will create a new order and navigate to Order Screen

No Actor Action System Response

1 The customer clicks “Place Order” button

- The customer must complete the “Choose payment method” action

Figure 4.17 Usecase diagram for paying order Table 4.9 Usecase description for paying order

Use Case No CHOPPER_UC_08 Use Case Version 1.0

Use Case Name Pay order

- Allow to customer pay order

- Customers can pay their orders

- The customer clicks “Paypal” button

- The customer inputs card info and clicks “Pay now”

- The customer must have their orders

- Success: The system will pay this order and update this status order

- Fail: System shows error messages

Step Actor Action System Response

1 The customer clicks “Paypal” button

The system will navigate to Paypal service

2 The customer inputs card info and clicks “Pay now”

The system will get the result from Paypal service and alert to customer, update Order Screen

No Actor Action System Response

1 The customer inputs card info and clicks “Pay now”

- The customer must have their orders

4.2.4.9 Rate and Review product

Figure 4.18 Usecase diagram for rating and reviewing product Table 4.10 Usecase description for rating and reviewing product

Use Case No CHOPPER_UC_09 Use Case Version 1.0

Use Case Name Rate and Review product

- Allow to customer rate and review product

- Customers can rate and review products

- The customer clicks on the rating dropdown box

- The customer selects an option in dropdown

- The customer writes a comment into the comment text area

- The customer clicks “Submit” button

- Success: The system will save the rating and review of this customer and display them in the bottom of list reviews

- Fail: System shows error messages

Step Actor Action System Response

1 The customer clicks on the rating dropdown box

The system will display options in dropdown box

2 The customer selects an option in dropdown

3 The customer writes a comment into the comment text area

4 The customer clicks “Submit” button

The system will save the rating and review of this customer and display them in the bottom of list reviews

No Actor Action System Response

4 The customer clicks “Submit” button System shows error messages

Figure 4.19 Usecase diagram for chatting with admin Table 4.11 Usecase description for chatting with admin

Use Case No CHOPPER_UC_10 Use Case Version 1.0

Use Case Name Chat with Admin

- Allow to customer chat with admin

- Customers can chat with a admin

- The customer clicks on the “Message” icon

- The customer writes text in the input or clicks “Micro” icon and says something

- The customer clicks “Send” icon or presses “Enter”

- Success: The system responses a message of the admin

- Fail: System shows error messages

Step Actor Action System Response

1 The customer clicks on the

The system will display options in dropdown box

2 The customer writes text in the input or clicks “Micro” icon and says something

3 The customer clicks “Send” icon or presses “Enter”

The system responses a message of the admin

No Actor Action System Response

4 The customer clicks “Send” icon or presses “Enter”

Figure 4.20 Usecase diagram for chatting with user Table 4.12 Usecase description for chatting with user

Use Case No CHOPPER_UC_11 Use Case Version 1.0

Use Case Name Chat with user

- Allow admin to chat with customers

- Admin can chat with customers

- The admin selects an online user in Support Screen

- The admin writes text in the text input

- The admin clicks “Send” button or presses “Enter”

- Success: The system sends this message to the selected customer

- Fail: System shows error messages

Step Actor Action System Response

1 The admin selects an online user in

The system will display a box for admin to chat with the selected user

2 The admin writes text in the text input

3 The admin clicks “Send” button or presses “Enter”

The system sends this message to the selected customer

No Actor Action System Response

3 The admin clicks “Send” button or presses “Enter”

Figure 4.21 Usecase for training dataset Table 4.13 Usecase description for training dataset

Use Case No CHOPPER_UC_12 Use Case Version 1.0

Use Case Name Train dataset

- Allow admin to train dataset

- The admin clicks “Train” button in Q&A Screen

- Success: The system executes training dataset and alerts the result

- Fail: System shows error messages

Step Actor Action System Response

1 The admin clicks “Train” button in

The system executes training dataset

No Actor Action System Response

1 The admin clicks “Train” button in

Figure 4.22 Usecase diagram for managin question

Figure 4.23 Usecase Diagram for editing question Table 4.14 Usecase description for editing question

Use Case No CHOPPER_UC_13 Use Case Version 1.0

Use Case Name Edit question

- Allow admin to edit question

- Admin can add the answer for the question

- The admin clicks “Edit” button in Q&A Screen

- The admin updates the text in question field, answer field and tag field in Q&A Edit Screen

- The admin clicks “Update” button

- Success: The system updates and deletes this question

- Fail: System shows error messages

Step Actor Action System Response

1 The admin clicks “Edit” button in

The system will navigate to Q&A Edit Screen

2 The admin updates question field, answer field and tag field in Q&A

3 The admin clicks “Update” button The system will update and delete this question

No Actor Action System Response

3 The admin clicks “Update” button System shows error messages

Business Rules: b Delete question

Figure 4.24 Usecase diagram for deleting question

Table 4.15 Usecase description for deleting question

Use Case No CHOPPER_UC_14 Use Case Version 1.0

Use Case Name Delete question

- Allow admin to delete question

- Admin can delete the question that is not useful

- The admin clicks “Delete” button in Q&A Screen

- The admin clicks “OK” button in the dialog box

- Success: The system deletes this question

- Fail: System shows error messages

Step Actor Action System Response

1 The admin clicks “Delete” button in

The system will display a dialog box for admin to confirm the delete action

2 The admin clicks “OK” button in the dialog box

The system will delete this question and updates list question

No Actor Action System Response

2 The admin clicks “Cancel” button in the dialog box

This system cancels the delete action

Figure 4.25 Usecase diagram for managing dataset a Add dataset

Figure 4.26 Usecase diagram for adding dataset Table 4.16 Usecase description for adding dataset

Use Case No CHOPPER_UC_15 Use Case Version 1.0

Use Case Name Add dataset

- Allow admin to add datasets

- Admin can add datasets into the system

- The admin clicks “Add” button in Q&A Dataset Screen

- The admin inputs the text in pattern field or response field

- The admin clicks “Update” button

- Success: The system updates the datasets

- Fail: System shows error messages

Step Actor Action System Response

1 The admin clicks “Add” button in

The system will navigate to Q&A Dataset Edit Screen

2 The admin inputs the text in pattern field or response field

3 The admin clicks “Update” button The system updates the datasets

No Actor Action System Response

3 The admin clicks “Update” button System shows error messages

Business Rules: b Delete dataset

Figure 4.27 Usecase diagram for deleting dataset Table 4.17 Usecase description for deleting dataset

Use Case No CHOPPER_UC_16 Use Case Version 1.0

Use Case Name Delete dataset

- Allow admin to delete datasets

- Admin can delete datasets by tag

- The admin clicks “Delete” button in Q&A Dataset Screen

- The admin clicks “OK” button in the dialog box

- Success: The system deletes this dataset

- Fail: System shows error messages

Step Actor Action System Response

1 The admin clicks “Delete” button in

The system will display a dialog box for admin to confirm the delete action

2 The admin clicks “OK” button in the dialog box

The system will delete this dataset and updates list dataset

No Actor Action System Response

2 The admin clicks “Cancel” button This system cancels the delete action

4.2.5.1 Screens for unauthenticated users a Home Screen

Figure 4.28 UI design for Home Screen

When visitors access the website, they are directed to the Home Screen, featuring a prominent image carousel showcasing the top three most-reviewed products Below the carousel, users can browse a comprehensive list of available products, with clickable links that direct them to detailed product information Additionally, customers can easily engage with a virtual chatbot by clicking on the message icon for instant assistance.

Figure 4.29 UI design for Product Screen

After selecting a product on the Home Screen, users are directed to the Product Screen, which showcases detailed information such as product images, descriptions, prices, availability status, and stock quantity This page also features customer reviews, providing valuable insights for potential buyers From the Product Screen, users can easily add items to their cart, leading them to the Cart Screen for a seamless shopping experience.

Figure 4.30 UI design for Cart Screen

After clicking the “Add to Cart” button on the product page, users are redirected to the Cart Screen, where all added items are displayed This page allows users to easily adjust product quantities or remove items from their shopping cart, enhancing the overall shopping experience.

Figure 4.31 UI design for Search Result Screen

On the Search Result Screen, users can easily find products by entering keywords into the search bar and clicking the “search” icon, which displays relevant products below They can then sort or filter the product list to quickly locate their desired items, enhancing the overall shopping experience.

Figure 4.32 UI design for chatting with virtual bot

When users click the message icon, the chatbox UI is displayed, allowing them to interact seamlessly with the virtual chatbot They can type messages in the input field and click the “Send” icon to receive audible responses, enhancing user engagement Additionally, users can use the microphone icon to speak messages aloud, providing a hands-free communication option The volume icon allows users to easily toggle sound on or off, ensuring a customizable and user-friendly chat experience.

4.2.5.2 Screens for customers a Chat with virtual bot and admin

Figure 4.33 UI design for chatting with virtual bot and admin

Upon successfully logging into the website, customers can engage in live chat with both the admin and a virtual bot When the admin is offline, the virtual bot automatically responds to customer messages, ensuring continuous support If the admin is available online, they will directly interact with customers to provide personalized assistance, enhancing the overall user experience.

Figure 4.34 UI design for Place Order Screen

After adding a product to the cart, customers proceed by entering their shipping address and selecting a preferred payment method before reaching the Place Order Screen This screen provides a comprehensive overview of the order, including shipping details, customer name, chosen payment method, product information, and total order cost Additionally, customers can review their past orders on the Order History Screen for easy tracking and reordering.

Figure 4.35 UI design for Order History Screen

This screen displays a comprehensive list of orders placed by the customer, including key details such as order date, total amount, payment status, and delivery status For completed transactions, the table shows the dates when payments were made or shipments were dispatched Customers can easily view more information by clicking the "Details" button to access individual order specifics, enhancing their shopping experience.

4.2.5.3 Screens for admins a Chat with user

Figure 4.36 UI design for chatting with user

When the admin accesses the Support Screen, they can chat with customers via the chat dialog The interface is divided into two sections: the left side displays a list of online customers, while the right side shows the chat history and message content, enabling real-time communication and efficient support.

Figure 4.37 UI design for Q&A Screen

This screen displays a list of customer questions that the virtual has not yet learned Admins can click the “Delete” button to delete the question or click the

“Edit” button to reply to that question Admin can click the “Train” button to let the virtual bot learn the sets of questions and answers c Dataset Screen

Figure 4.38 UI design for Dataset Screen

This screen displays a list of data sets that the vitual bot has learned Each row of the table includes:

- Type: categorize questions and answers

- Question: contains questions or phrases that need to be answered, can contain multiple questions

- Answer: contains answers to questions, can contain multiple answers

Admin can click the "Create" button to add new sets of questions and answers

Chatbot system

➢ Results for the Chatbot system model:

- Number 1: Customers can talk through a receiver that transmits sound as input to the system In addition, customers can also text, not necessarily using voice

- Number 2: The output of Speech-to-Text is text

- Number 3: API Input and Output Processing Center

- Number 5: system deep learning use fully connected neural network

- Number 7: Message returned from predicting results in a deep learning model

- Number 8: API Zalo Text-to-Speech

- Number 9: URL sound This is output by API Zalo Text-to-Speech

- Number 10: Show Message by Bot

- Number 12: Play URL sound in website

➢ New re-trainning function for admin:

Figure 4.40 Re-trainning function for admin

- Number 3: File Json save new questions

- Number 4: Function Delete question by Admin in file Json New Question

- Number 6: Categories tag, patterns – Questions from customers, responses - Question from the salesperson

- Number 7: Function Create and Delete Tag by Admin in file json dataset

4.3.2 Details of each part a Speech to text

Figure 4.41 Speech to text model

• How do you get the voice of a client in the system?

• How to quickly detect words through voice?

• Initially used python's recognition but had a big problem that it was not possible for the client to stream audio directly from the website interface to the backend for processing

• So decided to convert the audio to text from the frontend and then pass the text through the API down to the backend for processing

• Using recognition by javascript b API Input and Output Processing Center

• How do you get a protocol between interface-to-face with the system?

Python offers a wide range of libraries for building APIs, with Flask remaining one of the most popular choices among developers However, since early 2021, FastAPI has gained popularity due to its simplicity and ease of use, making it a convenient option for programmers seeking efficient API development.

• Therefore, the FastAPI library is chosen to build the API for the system

• Note that the library is only available for python version 3.x

• Using FastAPI library of the python to build API c Natural language processing

Figure 4.43 Natural Language processing model

• How can the machine understand the exact meaning of the customer's questions?

• Filter the keywords in the question and learn special phrases?

During data collection, inconsistent capitalization of words was identified, which can hinder the effectiveness of deep learning models To ensure optimal learning performance, the current solution involves standardizing all text by reverting all words to lowercase, maintaining uniformity across the dataset.

In python, using this syntax “.lower()” is quite simple but solved the above problem

Repeated words such as "Nha," "nha," "ạ," "thì," and "là" in both Vietnamese and English can hinder accurate training and lead to confusion in customer inquiries Eliminating these stopwords improves the model's ability to predict responses more precisely and enhances overall understanding in NLP tasks.

Effective sentence tokenization is essential for NLP systems, especially when processing Vietnamese text The NLTK package, a popular NLP library, is widely used but offers limited support for Vietnamese; its "nltk.word_tokenize" function primarily splits text by spaces, which may not be sufficient for accurate word separation in Vietnamese Conversely, Underthesea, a specialized Vietnamese NLP toolkit, provides robust support for Vietnamese language processing, ensuring more precise tokenization tailored to Vietnamese linguistic nuances Utilizing Underthesea enhances the quality of sentence separation, leading to more accurate NLP applications for Vietnamese texts.

• Convert sentense to vector (bag-of-words Model): We can not work with text directly when using machine learning algorithms Instead, we need to convert the text to numbers

• Using word-token by Underthesea d Dataset

➢ Question: How can the dataset learn and be able to classify questions and answers correctly?

In building effective chatbot models, it's essential to organize data based on three key components: Tags, Patterns, and Responses Tags serve as question types or labels that categorize user inputs, enabling the model to identify intent accurately Patterns are training samples that represent typical user queries, helping the system learn various ways users may phrase their questions Responses are message samples that provide appropriate replies to user inputs, ensuring clear and relevant communication Incorporating these elements based on English datasets from the internet enhances the chatbot's ability to understand and respond effectively, optimizing performance with SEO-friendly keywords such as Tags, Patterns, and Responses.

• Using Json file save dataset e System deep learning and message predicting results

"patterns": ["Xin chào", "Tôi cần giúp đỡ"],

"Xin chào quý khách Hãy hỏi, , để biết thêm thông tin về tôi nhé",

"Xin chào Mình có thể hỗ trợ gì cho bạn không? Bạn có thể hỏi ."],

• At first, the model used was from the tflearn package:

The model features an input layer whose size matches the length of the training data, ensuring it can effectively process the input features It includes two fully connected hidden layers that facilitate learning complex patterns, culminating in an output layer designed with a dimension of eight to correspond to the output classes The output layer's size is equal to the length of the training labels, enabling accurate predictions, and employs the "softmax" activation function to generate probability distributions over the classes for effective classification.

To improve model performance, we decided to migrate from an older TFLearn-based model to TensorFlow Keras The new Keras model features a sequential architecture with input, dense, and dropout layers, utilizing ReLU and softmax activations for better accuracy It is compiled with the Adam optimizer and trained using categorical crossentropy loss, enhancing training efficiency and effectiveness This transition facilitates more reliable training and improved prediction capabilities compared to the previous TFLearn model, which had limited ability despite a perfect system setup.

#output layer net = tflearn.regression(net) model = tflearn.DNN(net) model.fit(, , n_epoch00, batch_size=8, show_metric True)

• The first is to initialize the Sequential model for the problem

• Input is a one-dimensional array of the same size as the training data length

• Dense is a way to declare a neural network layer in Keras, with output_dim being the output dimension of that layer, and activation is the activation function of the layer

• Dropout layer used as regularization for layers with limited overfitting

• The output of the problem will use the activation function to calculate the probability (activation ="softmax")

• The compile function is the function needed to identify the optimizers during training

• Loss= “categorical crossentropy”: use in multiclass classification

• Using Model in Tensorflow Keras f Text to speech

• How can chatbots communicate by voice like virtual assistants?

• How can you transmit sound through api?

Chatbots provide users with the instant reply experience, but to better serve customers, transitioning from basic messaging to live chat is essential Live chat enables customers to interact with consultants in real-time, mimicking the experience of shopping in a physical store Incorporating text-to-speech technology enhances this interaction by making conversations more natural and accessible.

Google's Text-to-Speech (gTTS) Python library and CLI tool enable seamless access to Google Translate's text-to-speech API, allowing users to generate spoken MP3 files, stream audio data, or output to stdout for further manipulation It supports a wide variety of languages and is widely used nationwide due to its development by Google, offering a free and reliable solution for converting text into high-quality speech.

72 o Disadvantages: Voice reading for Vietnamese is not good, can't change reading speed

FPT Technology Innovation Department has dedicated nearly 8 years to developing FPT Speech Synthesis, recognized as the leading integrated Vietnamese language voice system in the market today This API Text to Speech solution offers several advantages, including high-quality Vietnamese voice output, customizable reading speeds, and gender options for male or female voices For detailed integration instructions, you can refer to the user manual at https://docs.fpt.ai/docs/en/speech/api/text-to-speech However, the service is limited to a free tier of 100,000 words per month, with additional usage requiring a paid plan.

Figure 4.44 The price of Text to speech FPT.ai

• API Text to speech vbee.vn: Similar to FPT.ai API, but the system is specialized for online consulting calls Free version does not use API o Price list:

Figure 4.45 The price of Text to speech vbee.vn

Zalo.ai's Text-to-Speech (ZTTS) engine provides fast, high-quality Vietnamese audio output suitable for real-time applications like news websites, voice streaming, chatbots, and virtual assistants It supports four Vietnamese voices, including two Northern and two Southern accents, with customizable reading speed and gender options Users can access the API via the user manual at https://zalo.ai/docs/api/text-to-audio-converter While ZTTS offers the advantage of natural Vietnamese voices and adjustable settings, it is limited to 1 million words per month for free; exceeding this quota requires purchasing a plan.

Our system utilizes the API Text-to-Speech feature by Zalo.ai to generate audio outputs, which are provided as sound links We then implement JavaScript to seamlessly play these audio links, enhancing user interaction Additionally, we are developing new data addition functionalities for the chatbot to improve its capabilities and provide a more dynamic conversational experience.

• The system has been completed, but the data needs to be updated to be good for many purposes, what to do?

Figure 4.46 The first research process model

Our system leverages machine learning to classify customer questions, allowing administrators to add accurate answers and continuously expand the knowledge base This dynamic approach enables the system to learn from new questions submitted by customers, improving its responsiveness over time However, reliance on automatic text classification introduces potential inaccuracies, which can lead to misclassification and negatively impact the chatbot's prediction accuracy, making the system more complex.

• The second research direction: (The system is displayed above)

➢ Solutions: Using the second presented system h Deploy server

Deploying a server to Heroku simplifies the process of building, deploying, managing, and scaling applications on a flexible cloud platform Heroku enables developers to focus on product development without concern for server maintenance or hardware, making it an ideal choice for quick launches and testing ideas The platform supports many services for free, though the free tier limits usage to 550 hours per month, with options to upgrade to 1,000 hours by adding a payment method It is suitable for small projects or testing, with a maximum source code size of 500 MB, providing an accessible solution for startups and developers.

Deploying a server on Google Cloud Platform (GCP) enables individuals and organizations to build, develop, and manage applications using Google's cloud computing technology GCP offers a free $100 credit upon sign-up, valid for the first three months, making it an attractive choice for starting projects However, after the initial trial period, users must transition to paid plans to continue using the services, which is an important consideration for long-term deployments.

➢ Solutions: Deploy server to google cloud Platform

SYSTEM IMPLEMENTATION

Software development environments

- Frontend: o Develop in Visual Code IDE o Run with Node server background

- Backend: o Develop in Visual Code IDE o Run with Node server background o Using postman to check APIs

- Deep Learning Service: o Develop in Visual Code IDE o Run FastAPI with Python web server Uvicorn o Using postman to check APIs

Source code management

- Source code in Backend and Frontend are managed by Github

- Github management tool is sourcetree and github desktop

- Link source code Website: https://github.com/zZChopperZz/DOANTOTNGHIEP

- Link source code Backend Chatbot: https://github.com/AlvinDMartin/backend-website-chatbot

Deployment environment

5.3.1 Deploying the website on Heroku

Backend and frontend are deployed to Heroku so the website can be accessed at any time

- Create git repository: open the terminal, in the root folder of project, run the command “git init”

- Create Heroku account in https://dashboard.heroku.com/apps

- Install Heroku CLI in https://devcenter.heroku.com/articles/heroku-cli

- Login to Heroku: in the terminal, run command “heroku login” to login to heroku

- Create heroku app: in the terminal, run command “heroku apps:create

- Edit package.json for build script: o Create a new command in the “scripts” section: “build”: “cd frontend && npm install && npm run build”

Figure 5.3 Create build script in package.json o Set node and npm version on the Heroku sever

Figure 5.4 Set node and npm version on the Heroku server

- Create Procfile: the command in Procfile will run after installing all packages and it will launch the website for us

- Set database connection in Heroku env variables, set

“SKIP_PREFLIGHT_CHECK=true” to skip preflight check

Figure 5.6 Set database connection in Heroku env variables

Figure 5.7 Set env variable to skip preflight check

Figure 5.8 Commit and push to Heroku

Figure 5.9 Deploy changes to Heroku

5.3.2 Deploying the Chatbot API on Google Cloud Platform

- Create VM instances from Google Cloud Platform:

• Login Google Cloud Platform by account google

• Connect Server Ubuntu generated from VM by SSH:

Figure 5.12 Connect Server Ubuntu generated from VM by SSH

• Clone source code by Git:

Figure 5.13 Clone source code by Git

• Install all support libraries for the system

• Install PM2 (process manager for applications) and running python Uvicorn by PM2

Figure 5.14 Install PM2 and running python Uvicorn by PM2

To ensure secure communication on a frontend website deployed via Heroku, it is essential to convert the API from HTTP to HTTPS This process involves installing Nginx as a reverse proxy and utilizing Cloudflare to update the IP address to your custom domain You can create a free domain for 12 months through Freenom.com, providing a cost-effective solution for your website's domain needs.

Figure 5.15 Create domain by Freenom.com o Setting from IP Server to domain by Cloudflare.com

Figure 5.16 Setting from IP Server to domain by Cloudflare.com

82 o Setting configure Nginx on Ubuntu 18.04

• All processing APIs: o Execute API return message “Xin chào…” by Bot at the current time POST: https://quocdatit.tk/chatbot/chat-hello

This server configuration sets up an Nginx server to listen on port 80 for the domain quocdatit.tk, proxying requests to a backend server at http://10.128.0.2:4200 It ensures proper header forwarding with proxy_set_header directives and includes specific settings to handle CORS preflight OPTIONS requests by adding the necessary Access-Control-Allow-Origin, Access-Control-Allow-Credentials, and Access-Control-Allow-Methods headers for seamless cross-origin communication.

OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-

CustomHeader,Keep-Alive,User-Agent,X-Requested- With,If-Modified-Sin$ add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204;

} if ($request_method = 'POST') { add_header Access-Control-Allow-Origin *; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods'

'GET, POST, OPTIONS, HEAD'; add_header 'Access-Control-Allow-Headers' 'DNT,X-

CustomHeader,Keep-Alive,User-Agent,X-Requested- With,If-Modified-Sin$

} if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods'

'GET, POST, OPTIONS HEAD'; add_header 'Access-Control-Allow-Headers' 'DNT,X-

CustomHeader,Keep-Alive,User-Agent,X-Requested- With,If-Modified-Sin$

Figure 5.17 API return welcom message

Return message and URL mp3 sound o Execute API return message by Bot:

POST: https://quocdatit.tk/chatbot/chat-run Body/raw/json:

{ "user": "your_user_here", "name": "your_name", "request_question": "your_message"

Figure 5.18 API return greet message o Execute API training model:

GET: https://quocdatit.tk/chatbot/chat-training

Figure 5.19 API training model o Execute API get list new questions

GET: https://quocdatit.tk/update/chat-getlistquestions/

Or GET: https://quocdatit.tk/update/chat-getlistquestions/ “item_id”

Figure 5.20 API get list new questions o Execute API update dataset

POST: https://quocdatit.tk/update/chat-newquestions/ “id_question” Body/raw/json:

Figure 5.21 API update dataset o Execute API delete the saved question

GET: https://quocdatit.tk/update/chat-delete-newquestions/ “id”

{ "tag": "xin chào", "responses": "cảm ơn bạn đã đến với cửa hàng Hãy để tôi giúp bạn nhé"

Figure 5.22 API delete the saved question o Execute API get list dataset

GET: https://quocdatit.tk/dataset/get-all-dataset/

Figure 5.23 API get list dataset o Execute API get list “Tag” in dataset

GET: https://quocdatit.tk/dataset/get-tag-dataset/

Or GET: https://quocdatit.tk/dataset/get-tag-dataset/ “id_tag”

Figure 5.24 API get list “Tag” in dataset o Execute API add new “Tag”, “patterns” and “responses” to dataset POST: https://quocdatit.tk/dataset/create-dataset/

Figure 5.25 API add new dataset (tag, pattern, response) o Execute API add new “patterns” and “responses” for “Tag” in dataset POST: https://quocdatit.tk/dataset/edit-dataset/

{ "tag": "new_tag", "patterns":"new_patterns", "responses":"new_responses"

Figure 5.26 API add new dataset (pattern, response) o Execute API delete “Tag”in list dataset

POST: https://quocdatit.tk/dataset/delete-dataset/

Figure 5.27 API delete Tag in list dataset o Execute API Test-to-Speech of Zalo.ai

POST: https://quocdatit.tk/texttospeech/soundAPI/

{ "tag":"current_tag", "patterns":"new_patterns", "responses":"new_responses"

Figure 5.28 API Test-to-Speech of Zalo.ai

Return url mp3 sound: https://chunk.lab.zalo.ai/705d27a244f0adaef4e1/705d27a244f0adaef4e1

Built screens

{ "text": "xin chào, mình là nhân viên bán hàng ảo"

Figure 5.33 Welcom interface of Chatbot

Figure 5.34 Main interface of Chatbot

Figure 5.35 List Question Screen (Admin)

Figure 5.36 Edit Question Screen (Admin)

Figure 5.37 List Dataset Screen (Admin)

Figure 5.38 Edit Dataset Screen (Admin)

5.4.11 Create New Dataset Screen (Admin)

Figure 5.39 Create New Dataset Screen (Admin)

CONCLUSION

Conclusion

The implementation team has completed 90% of the work according to the initial target

An e-commerce website is thoughtfully designed with three primary user roles to enhance functionality and user experience Unauthenticated users can browse product listings, view product details, search for items, add products to their cart, and interact with a chatbot for assistance Registered customers have the capability to place orders, complete payments, rate and review products, update their personal information, and communicate via chat with both the chatbot and admin support Admins hold comprehensive management privileges, including creating, editing, and deleting products; managing user accounts; overseeing orders; moderating questions; handling datasets—adding or deleting datasets, training datasets—and engaging in chat conversations with customers to ensure smooth operation and customer satisfaction.

Our deep learning service offers a comprehensive system that includes automatic message reply functionality, enabling efficient customer interactions With high-quality training data achieving over 95% accuracy, the model demonstrates exceptional performance During training with 500 epochs, the system's loss rate significantly decreases to below 0.1%, ensuring reliable and accurate results.

Figure 6.1 The loss rate after training

96 o Predict the answer well: when the probability reaches more than 60% will return the prediction result, otherwise send the message "not learned"

Red point: location tag highest (more than 60%)

Blue point: location of other points

Result messages predict: “Xin chào Mình có thể hỗ trợ gì cho bạn không?

Bạn có thể hỏi .”

Message customer: “có bán giày không”

Red point: location tag highest (less than 60%)

Blue point: location of other points

Result messages predict: “Có lẽ tôi chưa được học, bạn đợi Admin để được giải đáp nhé.”

Through this experience, I gained a deep understanding of deep learning, particularly in chatbot development, and designed an efficient data update system processing flow for chatbots I developed API interfaces and successfully deployed the system on an Ubuntu server hosted on Google Cloud Platform Additionally, I explored the integration of Speech-to-Text and Text-to-Speech technologies to enhance chatbot interactions This journey also provided valuable insights into how deep learning can be effectively incorporated into website applications.

Advantages

- Frontend and backend are both uploaded to Heroku, this keeps the website ready, anyone can access the website at any time

- MERN stack is a modern technology, it helps to build an organized, easy-to-

98 manage, extensible and upgradeable source code structure, in addition, it also helps to process requests quickly, improve website performance

The chatbot system, powered by advanced deep learning techniques, delivers top-tier performance Its capability to update training data ensures continuous improvement and adaptability across various industries This flexibility allows for more efficient learning, making the chatbot a versatile solution for numerous applications.

- From the Speech-to-Text, Text-to-Speech technology of virtual assistants, we can apply that to chatbots to improve the ability to communicate online with customers more closely.

Disadvantages

- The interface is not really eye-catching, some of the layouts are not properly arranged

- The source code still has many places that are not well optimized, leading to reduced performance

- Although Speech-to-Text has been applied, it has not yet brought the closest approach to users

- Processing speed has not been improved well.

Development directions

- Using system Sentiment Analysis customer

- Optimize code for improved performance and easy extensibility

- Redesign the interface and add advanced functions to make it easier to reach users

[1] MongoDB Inc, MERN Stack [online] Available at: https://www.mongodb.com/mern-stack [Accessed July 05, 2021]

[2] Mau Ha Quang, Nhung gi can biet ve Chatbot [online] Available at: https://viblo.asia/p/tat-ca-nhung-gi-ban-can-biet-ve-chatbot-Az45bnNg5xY

[3] Wikipedia, Chatbot [online] Available at: https://en.wikipedia.org/wiki/Chatbot#Customer_Service [Accessed July 05, 2021]

[4] Wikipedia, Virtual assistant [online] Available at: https://en.wikipedia.org/wiki/Virtual_assistant [Accessed July 05, 2021]

[5] Zalo, Text to Speech [online] Available at: https://zalo.ai/docs/api/text-to-audio-converter [Accessed July 05, 2021]

[6] FPT Corporation, Text to Speech [online] Available at: https://docs.fpt.ai/docs/en/speech/documentation/text-to-speech

[7] Wikipedia, Python [online] Available at: https://en.wikipedia.org/wiki/Python_(programming_language)

[8] Wikipedia, TensorFlow [online] Available at: https://en.wikipedia.org/wiki/TensorFlow [Accessed July 08, 2021]

[9] JavaTpoint, Advantage and disadvantage of TensorFlow [online] Available at: https://www.javatpoint.com/advantage-and-disadvantage-of-tensorflow

[10] Trần Ngọc Minh, Cập nhật nhanh TensorFlow 2.0 [online] Available at: https://ngocminhtran.com/2020/03/22/cap-nhat-nhanh-tensorflow-2-0/

[11] Wikipedia, Keras [online] Available at: https://en.wikipedia.org/wiki/Keras [Accessed July 08, 2021]

[12] DataFlair, Keras Advantages and Limitations [online] Avaiable at: https://data-flair.training/blogs/python-keras-advantages-and-limitations/

[13] Wikipedia, Natural Language Toolkit [online] Available at: https://vi.wikipedia.org/wiki/Natural_Language_Toolkit [Accessed July 12, 2021]

[14] Guru99, NLTK Tokenize words sentences [online] Available at: https://www.guru99.com/tokenize-words-sentences-nltk.html

[15] Wikipedia, Bag-of-words [online] Available at: https://en.wikipedia.org/wiki/Bag-of-words_model [Accessed July 12, 2021]

[16] Tran Xuan Chien, NLP Stemming and Lemmatazation [online] Available at: https://chienuit.wordpress.com/2016/05/03/nlp-stemming-va-lemmatization/

[17] Vu Anh, Readme underthesea [online] Available at: https://underthesea.readthedocs.io/en/latest/readme.html [Accessed July 14, 2021]

[18] FastAPI, FastAPI [online] Available at: https://fastapi.tiangolo.com/ [Accessed July 14, 2021]

[19] Đào Hải Long, Vì sao chọn FastAPI [online] Available at: https://viblo.asia/p/vi-sao-chon-fastapi-gGJ59M6D5X2 [Accessed July 14, 2021]

[20] Wikipedia, ReactJS [online] Available at: https://en.wikipedia.org/wiki/React_(JavaScript_library) [Accessed July 06, 2021]

[21] Wikipedia, MongoDB [online] Available at: https://en.wikipedia.org/wiki/MongoDB [Accessed July 06, 2021]

[22] Wikipedia, NodeJS [online] Available at: https://en.wikipedia.org/wiki/Node.js [Accessed July 06, 2021]

[23] Wikipedia, Express Framework [online] Available at: https://en.wikipedia.org/wiki/Express.js [Accessed July 06, 2021]

[24] Socket.IO, Introduction [online] Available at: https://socket.io/docs/v4/ [Accessed July 08, 2021]

Study and design Chatbot system x 15-03-2021 15-04-2021

Build chatbot run in terminal x 16-04-2021 01-05-2021

Study use Text-to-Speech and Speech-to-Text x 02-05-2021 15-05-2021

Research, design and deploy APIs chatbot on

Ngày đăng: 26/12/2022, 12:12

Nguồn tham khảo

Tài liệu tham khảo Loại Chi tiết
[1] MongoDB Inc, MERN Stack. [online] Available at: https://www.mongodb.com/mern-stack [Accessed July 05, 2021] Sách, tạp chí
Tiêu đề: MERN Stack
Tác giả: MongoDB Inc
[2] Mau Ha Quang, Nhung gi can biet ve Chatbot. [online] Available at: https://viblo.asia/p/tat-ca-nhung-gi-ban-can-biet-ve-chatbot-Az45bnNg5xY [Accessed July 05, 2021] Sách, tạp chí
Tiêu đề: Nhung gi can biet ve Chatbot
Tác giả: Mau Ha Quang
[4] Wikipedia, Virtual assistant. [online] Available at: https://en.wikipedia.org/wiki/Virtual_assistant [Accessed July 05, 2021] Sách, tạp chí
Tiêu đề: Virtual assistant
Tác giả: Wikipedia
Năm: 2021
[5] Zalo, Text to Speech. [online] Available at: https://zalo.ai/docs/api/text-to-audio-converter [Accessed July 05, 2021] Sách, tạp chí
Tiêu đề: Text to Speech
Tác giả: Zalo
[6] FPT Corporation, Text to Speech. [online] Available at: https://docs.fpt.ai/docs/en/speech/documentation/text-to-speech [Accessed July 05, 2021] Sách, tạp chí
Tiêu đề: Text to Speech
Tác giả: FPT Corporation
[7] Wikipedia, Python. [online] Available at: https://en.wikipedia.org/wiki/Python_(programming_language) [Accessed July 06, 2021] Sách, tạp chí
Tiêu đề: Python
Tác giả: Wikipedia
[8] Wikipedia, TensorFlow. [online] Available at: https://en.wikipedia.org/wiki/TensorFlow [Accessed July 08, 2021] Sách, tạp chí
Tiêu đề: TensorFlow
Tác giả: Wikipedia
Năm: 2021
[10] Trần Ngọc Minh, Cập nhật nhanh TensorFlow 2.0. [online] Available at: https://ngocminhtran.com/2020/03/22/cap-nhat-nhanh-tensorflow-2-0/ Sách, tạp chí
Tiêu đề: Cập nhật nhanh TensorFlow 2.0
Tác giả: Trần Ngọc Minh
Năm: 2020
[3] Wikipedia, Chatbot. [online] Available at: https://en.wikipedia.org/wiki/Chatbot#Customer_Service [Accessed July 05, 2021] Link
[9] JavaTpoint, Advantage and disadvantage of TensorFlow. [online] Available at: https://www.javatpoint.com/advantage-and-disadvantage-of-tensorflow [Accessed July 08, 2021] Link

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w