A Python-based conversational chatbot that dynamically learns new responses, analyzes user sentiment, and provides context-aware replies using fuzzy string matching. It can respond to predefined queries, learn new answers from users, and personalize replies with emojis based on sentiment.
- 💬 Dynamic Learning: Learns new responses from users in real-time.
- 🧠 Sentiment Analysis: Uses TextBlob to detect mood and adjust replies.
- 🔍 Fuzzy Matching: Handles typos and similar queries using RapidFuzz.
- 📂 Persistent Memory: Stores learned responses in
learned_responses.json. - 😊 Emoji-Enhanced Responses: Automatically adds emojis for positive/negative/neutral moods.
- ⚡ Lightweight & Fast: Runs entirely in the command-line interface.
Chatbot-with-python/
│
├── chatbot.py
├── responses.json
├── learned_responses.json
├── requirements.txt
└── README.md
git clone https://github.com/Mamoonkhan11/Chatbot-with-python
cd Chatbot-with-pythonpython -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windowspip install -r requirements.txtDependencies include:
- TextBlob – For sentiment analysis
- RapidFuzz – For fuzzy string matching
python chatbot.py- Load Responses: Predefined responses from
responses.jsonand any previously learned responses fromlearned_responses.json. - User Input: Chatbot receives input via CLI.
- Sentiment Analysis: Detects user mood (positive, negative, neutral) using TextBlob.
- Fuzzy Matching: Searches for the closest known question to provide a relevant answer.
- Learning: If no match exists, chatbot asks the user for a new response and saves it for future use.
- Emoji Feedback: Adds emoji depending on sentiment for personalized replies.
🤖 Chatbot: Hello! Type 'bye' to exit.
You: Hello
🤖 Chatbot: Hi there! 😊
You: I feel sad
🤖 Chatbot: I’m sorry to hear that. Hope things get better ❤️
You: What is AI?
🤖 Chatbot: I don’t know how to respond. What should I reply next time?
🧠 Teach me: AI stands for Artificial Intelligence
🤖 Chatbot: Got it! I’ll remember that for next time.
- Always keep
learned_responses.jsonto persist chatbot knowledge. - The bot’s learning is case-insensitive and stores responses in lowercase.
- Predefined responses are stored in
responses.jsonand can be edited manually.
- 🌐 Add a web-based or GUI interface
- 🗣️ Voice input/output support
- 📊 Analytics dashboard for conversation insights
- 🤖 Integrate with GPT API for smarter responses