0% found this document useful (0 votes)
55 views29 pages

Chat Bot Report

The document outlines a mini project report on the development of a Medical Expert System Chatbot designed to provide preliminary medical diagnoses based on user-reported symptoms. Utilizing a rule-based expert system and a user-friendly graphical interface, the chatbot analyzes symptoms, offers diagnoses, and suggests medications while maintaining patient history and collecting feedback. The project emphasizes the importance of professional medical consultation for serious conditions and showcases the system's effectiveness in diagnosing common ailments.

Uploaded by

aashiqrasool371
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)
55 views29 pages

Chat Bot Report

The document outlines a mini project report on the development of a Medical Expert System Chatbot designed to provide preliminary medical diagnoses based on user-reported symptoms. Utilizing a rule-based expert system and a user-friendly graphical interface, the chatbot analyzes symptoms, offers diagnoses, and suggests medications while maintaining patient history and collecting feedback. The project emphasizes the importance of professional medical consultation for serious conditions and showcases the system's effectiveness in diagnosing common ailments.

Uploaded by

aashiqrasool371
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/ 29

NPR COLLEGE OF ENGINEERING

AND TECHNOLOGY
(An Autonomous Institution, Affiliated to Anna University, Chennai)
Natham, Dindigul - 624 014

BUILDING A CHATBOT

A MINI PROJECT REPORT

Submitted by

AASHIQ RASOOL SATHAKATHULLAH


ABINESH S
ANTONY JOE A

Supervisor/Guide

Dr. John Doe

April 2025
ABSTRACT

This project presents the development of a Medical Expert System Chatbot with a graphical
user interface (GUI) that assists users in obtaining preliminary medical diagnoses based on re-
ported symptoms. The system leverages rule-based expert systems using the Python ’experta’
library for diagnosis logic and ’tkinter’ for creating an intuitive GUI. The chatbot accepts user-
provided symptoms, analyzes them against predefined medical rules, and generates appropriate
diagnoses along with recommended medications and dosages. The system also maintains pa-
tient history, allows for feedback collection, and provides a user-friendly interface accessible
to individuals without medical expertise. Testing demonstrated the system’s effectiveness in
diagnosing common conditions such as flu, migraines, and respiratory issues with clear, ap-
propriate medical recommendations. The Medical Expert System Chatbot serves as a valuable
preliminary screening tool, although it emphasizes the importance of professional medical con-
sultation for serious conditions.

i
ACKNOWLEDGEMENTS

We would like to express our sincere gratitude to our guide, Dr. John Doe, for providing in-
valuable guidance and support throughout the project. We are also thankful to the Department
of Computer Science and Engineering, NPR College of Engineering and Technology, for pro-
viding the necessary resources and infrastructure to complete this project successfully.
We extend our appreciation to our friends and family for their constant encouragement and
moral support during the course of this project.

ii
Contents

ABSTRACT i

ACKNOWLEDGEMENTS ii

LIST OF FIGURES v

LIST OF TABLES vi

LIST OF SYMBOLS AND ABBREVIATIONS vii

1 INTRODUCTION 1
1.1 OVERVIEW OF CHATBOTS . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 MOTIVATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 OBJECTIVES OF THE PROJECT . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 COMPARISON WITH EXISTING SYSTEMS . . . . . . . . . . . . . . . . . 2

2 TECHNOLOGIES USED 4

3 PROJECT REQUIREMENTS 5
3.1 HARDWARE REQUIREMENTS . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 SOFTWARE REQUIREMENTS . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 TOOLS AND PLATFORMS . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 SYSTEM DESIGN 7
4.1 ARCHITECTURE OF THE CHATBOT . . . . . . . . . . . . . . . . . . . . . 7
4.2 FLOW OF THE CHATBOT . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.3 COMPONENTS OF THE SYSTEM . . . . . . . . . . . . . . . . . . . . . . . 8

5 METHODOLOGY 10
5.1 DEVELOPMENT PROCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2 GUI DEVELOPMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.3 EXPERT SYSTEM IMPLEMENTATION . . . . . . . . . . . . . . . . . . . . 11
5.4 TESTING AND EVALUATION . . . . . . . . . . . . . . . . . . . . . . . . . 12

iii
6 RESULTS AND DISCUSSION 13
6.1 FUNCTIONALITY RESULTS . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.2 CHALLENGES FACED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.3 USER FEEDBACK ANALYSIS . . . . . . . . . . . . . . . . . . . . . . . . . 15

7 CONCLUSION 16

8 FUTURE WORK 17

A CODE LISTING 19

B SAMPLE OUTPUTS 20

C RULE BASE DETAILS 21

iv
List of Figures

4.1 System Architecture of the Chatbot . . . . . . . . . . . . . . . . . . . . . . . . 7


4.2 Flowchart of the Chatbot Interaction . . . . . . . . . . . . . . . . . . . . . . . 8

6.1 Sample Diagnosis for Flu Symptoms . . . . . . . . . . . . . . . . . . . . . . . 13


6.2 Sample Diagnosis for Heart-related Symptoms . . . . . . . . . . . . . . . . . 13

v
List of Tables

3.1 Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5


3.2 Software Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

6.1 Testing Results Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

vi
LIST OF SYMBOLS AND ABBREVIATIONS

GUI Graphical User Interface


CSV Comma-Separated Values
UI User Interface
ORS Oral Rehydration Solution

vii
Chapter 1

INTRODUCTION

1.1 OVERVIEW OF CHATBOTS

Chatbots represent a significant advancement in technology, offering automated, intelligent


assistance to users seeking information and services. These systems leverage artificial intelli-
gence, rule-based expert systems, or a combination of both to process user inputs and provide
relevant responses. As digital interaction continues to grow, chatbots serve as accessible points
of contact that can help users understand their queries and determine appropriate next steps.
The emergence of chatbots aligns with the broader trend of digital solutions and automation.
By providing immediate responses to queries, these systems help bridge the gap between the
user’s need and the information or service they seek. While they cannot replace human experts,
chatbots can effectively triage cases, provide basic information, and reduce unnecessary human
intervention for routine tasks.

1.2 MOTIVATION

The development of this Chatbot was motivated by several key factors:

1. Accessibility: Many individuals face barriers to accessing timely information due to ge-
ographic, financial, or time constraints. A chatbot provides an accessible alternative for
preliminary information.

2. Information Overload: The abundance of information online can be overwhelming and


often misleading. A structured expert system can provide consistent, evidence-based
responses to common queries.

3. Preliminary Screening: By offering initial assessments based on user inputs, the chatbot
can help users determine whether their query warrants further expert attention or could
be resolved with basic information.

4. Education: The system can serve as an educational tool, helping users understand the
relationship between queries and potential solutions.

1
5. Record Keeping: The ability to maintain user history provides continuity and allows for
tracking progression over time.

1.3 OBJECTIVES OF THE PROJECT

The primary objectives of this Chatbot project are:

1. To develop a rule-based expert system capable of analyzing user inputs and providing
appropriate responses.

2. To create an intuitive, user-friendly graphical interface that facilitates seamless interac-


tion between users and the expert system.

3. To implement a system for storing and retrieving user histories to provide context-aware
responses.

4. To incorporate appropriate recommendations based on analyzed inputs and user demo-


graphics.

5. To collect user feedback on responses and recommendations to evaluate the system’s


effectiveness.

6. To emphasize the importance of professional consultation, particularly for potentially


serious issues.

7. To design a system that balances simplicity for non-technical users with accuracy and
reliability.

1.4 COMPARISON WITH EXISTING SYSTEMS

Several existing chatbot systems demonstrate various approaches to knowledge representation,


user interaction, and response generation:

1. Commercial Chatbots: Systems like IBM Watson Assistant and Microsoft Bot Frame-
work provide sophisticated platforms for building conversational interfaces but require
significant technical expertise to deploy.

2. Domain-Specific Systems: Specialized chatbots exist for healthcare (Ada Health, Baby-
lon Health), customer service, and education, each optimized for their specific domain
but often limited in flexibility.

3. Open-Source Frameworks: Tools like Rasa and Botpress offer customizable chatbot de-
velopment platforms but require programming knowledge and infrastructure setup.

2
4. Rule-Based vs. ML-Based: Many systems combine rule-based approaches with machine
learning techniques to improve accuracy over time, while our system primarily uses rule-
based logic for transparent decision-making.

Our chatbot addresses limitations in existing systems by focusing on:

• Simplicity of deployment and use

• Transparent decision-making processes

• Local operation without requiring internet connectivity

• Customizability for specific domains without extensive programming knowledge

3
Chapter 2

TECHNOLOGIES USED

Modern chatbots leverage various technologies to deliver effective guidance:

1. Rule-Based Expert Systems: These systems use predefined rules created by domain ex-
perts to make decisions based on user inputs. The primary advantages include trans-
parency in decision-making processes and reliability for well-defined problems. How-
ever, they may struggle with novel situations not covered by existing rules.

2. Natural Language Processing (NLP): Enables chatbots to understand user inputs in nat-
ural language, improving the conversational experience. While not implemented in the
current version of our chatbot, NLP represents a potential future enhancement.

3. Knowledge Representation: Domain knowledge must be structured in ways that comput-


ers can process. This includes decision trees, rule sets, and other formalized representa-
tions of expertise.

4. User Interface Technologies: Modern GUI frameworks like tkinter (Python), React, or
Flutter enable the creation of accessible interfaces that facilitate interaction with the un-
derlying expert system.

5. Data Management: Systems for storing and retrieving user information, typically using
structured databases or simpler file-based storage like CSV files.

The current project primarily utilizes rule-based expert systems through the ’experta’ li-
brary, a Python implementation of the CLIPS rule-based language, combined with a tkinter
GUI for user interaction.

4
Chapter 3

PROJECT REQUIREMENTS

3.1 HARDWARE REQUIREMENTS

The hardware requirements for developing and running the Chatbot are relatively modest, mak-
ing the system accessible on standard computing equipment.

Component Minimum Specification


Processor Intel Core i3 or equivalent
RAM 4 GB
Storage 1 GB free space
Display 1366 x 768 resolution

Table 3.1: Hardware Requirements

3.2 SOFTWARE REQUIREMENTS

The Chatbot relies on several software components and libraries:

Component Specification
Operating System Windows 10/11, macOS, or Linux
Programming Language Python 3.7 or higher
Expert System Library Experta 1.9.4
GUI Framework tkinter (included with Python)
Additional Libraries csv (standard library)

Table 3.2: Software Requirements

3.3 TOOLS AND PLATFORMS

The development process utilized the following tools and platforms:

5
1. Visual Studio Code: Primary integrated development environment (IDE) for coding and
debugging.

2. Git/GitHub: Version control system for tracking changes and collaboration.

3. Python Package Manager (pip): For installing and managing dependencies.

4. Experta Documentation: Reference materials for implementing the rule-based expert sys-
tem.

5. tkinter Documentation: Reference for developing the graphical user interface.

6
Chapter 4

SYSTEM DESIGN

4.1 ARCHITECTURE OF THE CHATBOT

The Chatbot follows a modular architecture that separates the user interface from the expert
system core. This design facilitates maintainability and allows each component to be developed
and tested independently.

System Architecture

User Interface Layer (tkinter)


↓↑
Controller Layer
↓↑
Expert System Core (Experta)
↓↑
Data Management Layer (CSV files)

Figure 4.1: System Architecture of the Chatbot

The system architecture consists of four primary components:

1. User Interface Layer: Implemented using tkinter, this layer handles all user interactions,
input collection, and result display. It includes forms for user information, input selec-
tion, and feedback collection.

2. Expert System Core: Built using the Experta library, this component contains the knowl-
edge base in the form of rules and facts. It processes inputs and user data to generate
responses.

3. Data Management Layer: Handles the reading and writing of user records and feedback
to persistent storage (CSV files).

4. Controller Layer: Coordinates the flow of data between the UI, expert system, and data
management components.

7
This modular architecture allows for future enhancements, such as expanding the knowl-
edge base or replacing the UI with alternative interfaces (e.g., web-based or mobile).

4.2 FLOW OF THE CHATBOT

The interaction flow of the Chatbot follows these key steps:

Chatbot Flow

User Identification → Previous Record Display → Input Collection



Input Analysis → Response Generation → Result Presentation →
Feedback Collection
Figure 4.2: Flowchart of the Chatbot Interaction

1. User Identification: The user enters their name and relevant information. The system
checks for existing records associated with the name.

2. Previous Record Display: If a previous record exists, it is displayed to provide context


and continuity.

3. Input Collection: The user selects inputs from predefined options or enters custom inputs.

4. Input Analysis: The expert system processes the inputs and user data.

5. Response Generation: Based on the rules in the knowledge base, the system generates a
response along with recommendations.

6. Result Presentation: The response and recommendations are displayed to the user in a
clear, readable format.

7. Feedback Collection: The user provides feedback on the usefulness and accuracy of the
response, which is stored for future analysis.

This flow ensures a comprehensive user experience while maximizing the effectiveness of
the expert system’s capabilities.

4.3 COMPONENTS OF THE SYSTEM

The Chatbot comprises several key components:

1. InputChecker Class: This is the core expert system component that inherits from Ex-
perta’s KnowledgeEngine. It contains rules that match patterns of inputs to specific
responses and recommendations. The rules incorporate user-specific logic to provide
appropriate information.

8
2. ChatbotGUI Class: This class implements the graphical user interface using tkinter. It
includes:

• User Information Tab: For collecting user information and inputs


• Response Tab: For displaying results and collecting feedback
• Navigation controls between tabs
• Input validation and error handling

3. Data Management Functions:

• get last record(): Retrieves previous user records based on name


• save user data(): Stores response information in the CSV file
• save feedback(): Records user feedback for evaluation

4. Main Application Loop: Initializes the GUI and maintains the application state.

Each component is designed with clear responsibilities and interfaces, allowing for inde-
pendent development and testing.

9
Chapter 5

METHODOLOGY

5.1 DEVELOPMENT PROCESS

The development of the Chatbot followed an iterative approach:

1. Requirement Analysis: Identifying the core functionalities needed for a useful chatbot,
including:

• User information collection


• Input analysis
• Response generation
• History tracking
• Feedback collection

2. Knowledge Base Development: Creating the rules based on common inputs and condi-
tions.

3. Expert System Implementation: Using Experta to translate domain knowledge into a


rule-based system.

4. GUI Design: Creating wireframes and mockups for the user interface.

5. GUI Implementation: Developing the tkinter-based interface according to the design.

6. Integration: Connecting the GUI to the expert system core.

7. Testing: Verifying the system’s functionality with various input combinations.

8. Refinement: Improving the system based on initial testing results.

This methodology allowed for progressive development and validation of each component
before final integration.

10
5.2 GUI DEVELOPMENT

The GUI was developed using tkinter, Python’s standard GUI toolkit. The interface design
focused on usability, clarity, and accessibility.
Key design considerations included:

1. Tab-based Organization: Separate tabs for input (user information and inputs) and output
(response and feedback) create a clear workflow.

2. Responsive Layout: The interface adapts to different screen sizes while maintaining read-
ability.

3. Visual Hierarchy: Important elements like response results are displayed prominently.

4. Error Prevention: Input validation ensures that required fields are completed and data is
in the expected format.

5. Accessibility: Clear labels, adequate spacing, and logical tab order improve usability.

6. Contextual Information: Previous records are displayed when available, providing valu-
able context.

Implementation details:

1. Widget Selection: Appropriate widgets were chosen for different types of input:

• Entry fields for name and personal information


• Checkboxes for input selection
• Scrolled text areas for displaying results and collecting feedback

2. Event Handling: The interface responds to user actions through event bindings:

• Name field loses focus: Trigger previous record lookup


• Submit button clicked: Run expert system
• Feedback submission: Save user comments

3. State Management: The application maintains its state across tab changes and user inter-
actions.

5.3 EXPERT SYSTEM IMPLEMENTATION

The expert system was implemented using the Experta library, which provides a Python imple-
mentation of a rule-based system. The implementation focused on creating rules that accurately
map inputs to responses.
Each rule in the expert system consists of:

11
1. Antecedents: Conditions that must be true for the rule to fire (inputs and user conditions)

2. Consequents: Actions to take when the rule fires (setting response and recommendation
information)

The expert system processes facts (inputs and user data) against these rules to determine
the appropriate response.

5.4 TESTING AND EVALUATION

The Chatbot underwent systematic testing to ensure its reliability and accuracy:

1. Unit Testing: Individual components were tested separately:

• Expert system rules were tested with various input combinations


• GUI components were tested for proper rendering and interaction
• Data management functions were tested for correct storage and retrieval

2. Integration Testing: The integrated system was tested for proper communication between
components:

• Data flow from GUI to expert system


• Result display from expert system to GUI
• Record storage and retrieval

3. User Testing: The complete system was tested with sample user scenarios:

• New users with various input combinations


• Returning users with existing records
• Edge cases such as incomplete information or rare input combinations

4. Validation: The responses and recommendations were validated against domain knowl-
edge to ensure appropriateness.

Test results were used to refine both the expert system rules and the GUI design, improving
the overall functionality and user experience.

12
Chapter 6

RESULTS AND DISCUSSION

6.1 FUNCTIONALITY RESULTS

The Chatbot successfully implemented all planned features and demonstrated reliable perfor-
mance across various test scenarios.
Sample Diagnosis for Flu Symptoms

[This would contain a screenshot of the chatbot showing flu symptoms


diagnosis]

Figure 6.1: Sample Diagnosis for Flu Symptoms

Sample Diagnosis for Heart-related Symptoms

[This would contain a screenshot of the chatbot showing heart-related


symptoms diagnosis]

Figure 6.2: Sample Diagnosis for Heart-related Symptoms

Key functional achievements include:

1. Accurate Input Analysis: The system correctly matched input combinations to appropri-
ate responses according to the implemented rules.

2. User-Appropriate Recommendations: Recommendations appropriately accounted for


user information, providing specific treatments when necessary.

3. User History Integration: The system successfully retrieved and displayed previous
records, providing valuable context for returning users.

13
4. Feedback Collection: User feedback was properly collected and stored for future analy-
sis.

5. Clear Warning System: For potentially serious conditions, the system prominently dis-
played warnings about seeking appropriate attention.

Test Scenario Expected Result Actual Result Status


New user with flu symptoms Flu diagnosis with appropriate treatment As expected Pass
Returning user Previous record display + new diagnosis As expected Pass
Heart-related symptoms Diagnosis with urgent attention warning As expected Pass
Incomplete information Error message As expected Pass
Multiple input combinations Correct matching to specific conditions As expected Pass

Table 6.1: Testing Results Summary

The system demonstrated reliable performance across all test cases, correctly implementing
the rules and providing appropriate guidance.

6.2 CHALLENGES FACED

During the development and testing of the Chatbot, several challenges were encountered:

1. Rule Complexity: Creating a comprehensive set of rules that accurately capture the rela-
tionship between inputs and conditions proved challenging. The current implementation
includes only basic conditions and would need expansion for more comprehensive cov-
erage.

2. Input Ambiguity: Many inputs can be associated with multiple conditions, making defini-
tive response difficult. The system currently handles this by focusing on specific input
combinations but could benefit from a more nuanced approach.

3. GUI Responsiveness: Ensuring the GUI remained responsive while processing rules and
retrieving records required careful implementation of threading and event handling.

4. Data Validation: Implementing robust validation for user inputs to prevent errors while
maintaining a seamless user experience required careful attention to detail.

5. Warning Communication: Balancing the need to provide clear warnings for serious con-
ditions without causing unnecessary alarm required thoughtful interface design.

These challenges were addressed through iterative development and testing, resulting in a
system that successfully manages these complexities.

14
6.3 USER FEEDBACK ANALYSIS

While the system includes functionality for collecting user feedback, comprehensive analysis
of user responses would require deployment to a broader audience over an extended period.
Initial feedback from testing indicates:

1. Interface Usability: The tab-based design and clear workflow were well-received by test
users.

2. Response Clarity: Users appreciated the clear presentation of diagnoses and recommen-
dations.

3. Warning Effectiveness: The prominent display of warnings for serious conditions was
considered appropriate and helpful.

4. Improvement Areas: Suggestions included:

• Adding more input options


• Providing additional information about each condition
• Including a search functionality for inputs
• Adding visual indicators of severity

This feedback provides valuable direction for future enhancements to the system.

15
Chapter 7

CONCLUSION

The Chatbot successfully demonstrates the potential of rule-based expert systems combined
with user-friendly interfaces for providing guidance. By implementing a knowledge base of
common conditions and inputs, the system offers valuable assistance to users seeking to under-
stand their concerns.
Key conclusions from this project include:

1. Expert System Viability: Rule-based expert systems remain viable and valuable for struc-
tured domains where clear relationships exist between inputs and conditions.

2. GUI Importance: A well-designed graphical interface significantly enhances the utility


of expert systems by making them accessible to non-technical users.

3. User History Value: Maintaining and leveraging user history provides valuable context
that improves the relevance of recommendations.

4. Safety Considerations: Implementing clear warnings and emphasizing the importance of


professional consultation for serious concerns is essential for responsible technology.

5. Feedback Integration: Building mechanisms for user feedback enables continuous im-
provement of both the knowledge base and the user interface.

The Chatbot serves as a promising foundation for more sophisticated assistance tools,
demonstrating that even relatively simple rule-based systems can provide valuable guidance
when paired with thoughtful interface design.

16
Chapter 8

FUTURE WORK

While the current implementation of the Chatbot provides useful functionality, several oppor-
tunities for enhancement and expansion exist:

1. Expanded Knowledge Base: Incorporating additional conditions, inputs, and recommen-


dations would increase the system’s utility.

2. Machine Learning Integration: Adding machine learning components could enable the
system to improve response accuracy based on feedback and outcomes.

3. Multilingual Support: Adding support for multiple languages would make the system
accessible to diverse populations.

4. Integration with Information Resources: Connecting the system to reliable information


resources could provide users with additional context and education.

5. Voice Interface: Implementing voice recognition and synthesis would improve accessi-
bility for users with visual impairments or limited typing ability.

These enhancements would build upon the solid foundation established in the current im-
plementation, creating a more comprehensive and powerful tool for guidance.

17
Bibliography

[1] Python Software Foundation, “Tkinter Documentation,” 2024. [Online]. Available:


https://docs.python.org/3/library/tkinter.html

[2] “Experta Documentation,” 2023. [Online]. Available: https://github.com/nilp0inter/experta

[3] J. Spolsky, User Interface Design for Programmers. Apress, 2001.

18
Appendix A

CODE LISTING

The complete source code is available at:


https://github.com/username/chatbot-project

19
Appendix B

SAMPLE OUTPUTS

This appendix would contain additional screenshots showing the chatbot in action, including
user interface elements and interaction examples.

20
Appendix C

RULE BASE DETAILS

This appendix would contain detailed explanations of each rule in the expert system, including
their conditions, actions, and the reasoning behind their implementation.

21

You might also like