# EduChat: An AI-Based Chatbot for University-Related Information Using a Hybrid Approach
## 3 The Proposed Model  
The proposed model aims to improve the understanding and interaction capabilities of the chatbot in complex situations, thereby enhancing the user experience. EduChat operates according to the following mechanism:  
1. Start: EduChat initiates the conversation with a welcoming message.
2. User Input: Users send messages, which can be either questions (queries) or statements.
3. Understanding and Message Classification: EduChat comprehends the intent and context of the messages as follows: * If the user's input falls within the context of the application: * EduChat provides relevant responses by using predefined answers or accessing information from the knowledge base. * If the user's input indicates a request beyond the scope of the application: * EduChat acknowledges the request and forwards it to ChatGPT to address such queries.
4. Conclusion: When user questions have been resolved or when users indicate they have completed their interaction, EduChat concludes the conversation. EduChat bids farewell or provides concluding information.  
The following modules are designed to implement the operating mechanism described above (illustrated in Figure 2):  
* User Interface: A web-based chat window serving as the user interface.
* Conversation Management: Manages the flow of the conversation. This ensures that EduChat responds appropriately to user input, adheres to the context, and maintains a smooth conversation.
* Knowledge Base: Contains information that EduChat can use to answer user queries. The knowledge base includes frequently asked questions, help guides, and other university-related information.
* Natural Language Processing (NLP) Module: This module allows EduChat to understand and process human language. Its role involves parsing the syntax and semantics of text messages.
* Machine Learning Module: EduChat is equipped with machine learning and artificial intelligence approaches to comprehend and respond to messages that the NLP module cannot handle.
* ChatGPT API: EduChat is integrated with ChatGPT through an API to handle messages evaluated as below the threshold by the machine learning module.  
The EduChat model utilizes an NLP module and an improved random forest machine learning module as two main modules to process input data and generate responses. The algorithm of the EduChat model is described as follows (Algorithm 1).  
```
functionEduChat(conversation) Input: conversation Output: response content for the user Variables: user_input: the newest user's message  prolog: an instance of the Prolog class. DCG syntax and semantics rules was loaded into this variable. model: an instance of the improved random forest (IRF) model.  db: database object.  gpt: an instance of ChatGPTConnector, which helps connect to ChatGPT via Open AI's APIs.
1. user_input = encode(user_input) # user input in Vietnamese will be preprocessed, standardized and encoded.
2. task = prolog.query(user_input) # try to parse the syntax and semantics of user input 3. if task is None then
4. predicted_task, prob = model.predict_prob(user_input) # The IRF model will predict and give the probability of each class. If the maximum probability value is greater than the system's configuration threshold, the system will accept this classification value.
5. if prob \(\geq\) threshold then
6. task = predicted_task
7. if task is not None then
8. response = db.query(task)
9. else
10. response = gpt.post(conversation, user_input)
11. return response endfunction
```  
**Algorithm 1** EduChat Algorithm