Skip to content

alingom/simple-rule-based-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 SupportBot - Customer Support Chatbot

A production-ready Python chatbot with intelligent keyword scoring and dual interfaces (Terminal + Streamlit Web).

✨ Key Features

  • Intelligent Intent Matching - Keyword-based scoring system
  • Dual Interfaces - Terminal & Streamlit web app
  • 5 Intent Categories - Product, Tech Support, Returns, General, No Match
  • 65+ Response Templates - Natural, varied conversations
  • 39+ Unit Tests - 100% passing
  • Production Ready - Fully tested and deployed

📁 Project Structure

final_project/
├── chatbot.py              # Core logic
├── streamlit_app.py        # Web interface
├── responses.json          # 65+ response templates
├── test_chatbot.py         # 39 tests
├── requirements.txt        # Dependencies
└── README.md

🚀 Quick Start

1. Setup (One Time)

# Create virtual environment
python -m venv venv

# Activate (Windows PowerShell)
.\venv\Scripts\Activate.ps1

# Install dependencies
pip install -r requirements.txt

2. Run the Chatbot

Option A - Web Interface (Recommended):

streamlit run streamlit_app.py

Opens at http://localhost:8501 with 🎨 chat interface, 📋 help sidebar, 📊 statistics

Option B - Terminal:

python chatbot.py

3. Run Tests

python -m unittest test_chatbot -v

Result: All 39 tests PASS ✅

🎯 How It Works

The bot matches queries to 5 intent categories by counting keyword matches:

Intent Keywords Example
Product product, price, buy, order "What's the price?"
Technical technical, problem, error, bug "Getting an error"
Returns return, refund, exchange "Can I return it?"
General how, what, when, help "How can you help?"
No Match (fallback) "xyz abc"

Example: "What's the product price?" → Counts matches → Product Intent wins → Random product response

🧪 Test Results

Ran 39 tests in 0.174s
OK - 100% PASSING ✅

Coverage: Response generation, intent matching, error handling, full workflows, data validation

📊 Technology

  • Python 3.7+ - Core language
  • Streamlit 1.28+ - Web interface
  • Matplotlib 3.5+ - Visualization
  • unittest - Testing framework

📋 Exit Commands

End with: quit | exit | bye | goodbye | farewell | pause

❓ Troubleshooting

Issue Solution
ModuleNotFoundError pip install -r requirements.txt
responses.json not found Place in same directory as chatbot.py
Port in use streamlit run streamlit_app.py --server.port 8502
Tests fail python -m unittest test_chatbot -v

🚀 Get Started

streamlit run streamlit_app.py

Status: ✅ Ready to use!

About

Simple rule-based chatbot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages