A production-ready Python chatbot with intelligent keyword scoring and dual interfaces (Terminal + Streamlit Web).
- 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
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
# Create virtual environment
python -m venv venv
# Activate (Windows PowerShell)
.\venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txtOption A - Web Interface (Recommended):
streamlit run streamlit_app.pyOpens at http://localhost:8501 with 🎨 chat interface, 📋 help sidebar, 📊 statistics
Option B - Terminal:
python chatbot.pypython -m unittest test_chatbot -vResult: All 39 tests PASS ✅
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
Ran 39 tests in 0.174s
OK - 100% PASSING ✅
Coverage: Response generation, intent matching, error handling, full workflows, data validation
- Python 3.7+ - Core language
- Streamlit 1.28+ - Web interface
- Matplotlib 3.5+ - Visualization
- unittest - Testing framework
End with: quit | exit | bye | goodbye | farewell | pause
| 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 |
streamlit run streamlit_app.pyStatus: ✅ Ready to use!