๐ Project Overview
Conversational AI Bot is an advanced, feature-rich Python chatbot application that provides intelligent conversational AI with context management and multi-turn dialogue support. This project offers context-aware conversations, intent recognition, entity extraction, sentiment analysis, multi-language support, conversation history management, API integrations (weather, news, jokes, quotes, calculations), conversation analytics, and a beautiful Flask web interface. Perfect for developers looking to build intelligent chatbots or integrate conversational AI functionality into their applications.
โก Quick Facts
โจ Features
Core Features
๐ง Context-Aware Conversations
Maintains context across multiple turns for coherent and natural dialogues.
๐ฏ Intent Recognition
Identifies user intentions from natural language using pattern matching and ML.
๐ Entity Extraction
Extracts important information like names, dates, locations from messages.
๐ฌ Multi-Turn Dialogue
Handles complex conversation flows and follow-up questions intelligently.
Advanced Features
๐ Sentiment Analysis
Analyzes user sentiment to provide better, empathetic responses.
๐ Multi-Language Support
Detects and supports 8+ languages (English, Spanish, French, German, Hindi, Chinese, Japanese, Arabic).
๐พ Conversation History
Stores and retrieves past conversations for context continuity.
๐ API Integrations
Weather, news, jokes, quotes, and calculation APIs for enhanced functionality.
๐ Conversation Analytics
Tracks metrics, intent distribution, and session statistics.
๐ Response Templates
Template-based response system for consistent interactions.
๐ Flask Web Interface
Beautiful and modern Flask-based web application with responsive design.
๐ Advanced Error Handling
Comprehensive error handling with user-friendly messages and fallback responses.
โ๏ธ Easy Configuration
Simple configuration through config.py and environment variables.
๐ฑ Responsive Design
Works perfectly on mobile, tablet, and desktop with adaptive layouts.
๐งช Test Suite
Comprehensive test suite included for quality assurance.
๐ Well Documented
Complete documentation with examples, quick start guide, and installation instructions.
๐ ๏ธ Technologies
Python 3.8+
Modern Python programming language
LanguageFlask 2.3.0+
Lightweight Python web framework
FrameworkNLTK 3.6+
Natural Language Toolkit for text processing
NLP LibraryspaCy 3.4.0+
Advanced NLP library for entity extraction
NLP Libraryscikit-learn 1.0.0+
Machine learning library for NLP
ML LibraryNumPy 1.21.0+
Numerical computing library
LibraryRequests 2.28.0+
HTTP library for API calls
Library๐ฆ Installation
Prerequisites
- Python 3.8 or higher and pip
- Virtual environment (recommended: venv or virtualenv)
Quick Installation (Copy & Paste)
# 1. Create virtual environment
python -m venv venv
# 2. Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Run the chatbot
python main.py
Detailed Setup Steps
- Clone or download this project
git clone https://github.com/rskworld/conversational-ai-bot.git cd conversational-ai-bot - Create and activate virtual environment:
# Create virtual environment python -m venv venv # Activate (Windows) venv\Scripts\activate # Activate (Linux/Mac) source venv/bin/activate - Install dependencies:
pip install -r requirements.txt - Run the chatbot:
# CLI mode python main.py # Web interface mode python app.pyThe CLI chatbot will start in interactive mode. For web interface, it will be available at http://localhost:5000
- Optional: Download NLTK data (if needed):
python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords')"This downloads required NLTK data for text processing.
๐ Usage
Getting Started
- Start the Flask web interface: python app.py
- The app will be available at http://localhost:5000
- Start chatting with the AI assistant
- Or use CLI mode: python main.py
- Configure settings in config.py:
- Language settings
- API integration keys (optional)
- Response templates
- Analytics preferences
Features Usage
- Context Management: The bot automatically maintains conversation context
- Intent Recognition: Automatically identifies user intentions from messages
- Entity Extraction: Extracts names, dates, locations automatically
- Sentiment Analysis: Analyzes user sentiment for better responses
- Multi-Language: Supports 8+ languages with automatic detection
- API Integrations: Ask for weather, news, jokes, quotes, or calculations
- Conversation Analytics: View analytics and metrics through the interface
- Export Data: Export conversations and analytics as JSON
๐ป Code Examples
Basic Python Usage
from chatbot import ConversationalAIBot
# Create bot instance
bot = ConversationalAIBot()
# Basic chat
response = bot.chat("Hello, how are you?")
print(response)
# Context-aware conversation
bot.chat("My name is John")
response = bot.chat("What's my name?")
print(response) # The bot remembers your name
Advanced Features Usage
from chatbot import ConversationalAIBot
bot = ConversationalAIBot()
# Sentiment Analysis
sentiment = bot.get_sentiment_analysis("I'm feeling great today!")
print(sentiment['sentiment']) # 'positive'
# Language Support
bot.set_language('es') # Set to Spanish
current_lang = bot.get_current_language()
# Analytics
analytics = bot.get_analytics()
summary = bot.get_analytics_summary()
print(summary)
# API Integrations
response = bot.chat("Tell me a joke")
response = bot.chat("What's 25 + 17?")
response = bot.chat("Weather in New York")
Flask Web Interface
# Run Flask web interface
from app import app
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)
# Or simply run:
# python app.py
Intent Recognition
from intent_recognizer import IntentRecognizer
recognizer = IntentRecognizer()
intent = recognizer.recognize("What's the weather like?")
print(intent) # 'weather_inquiry'
Entity Extraction
from entity_extractor import EntityExtractor
extractor = EntityExtractor()
entities = extractor.extract("My name is John and I live in New York")
print(entities) # {'name': 'John', 'location': 'New York'}
Configuration
# config.py
DEFAULT_LANGUAGE = 'en'
ENABLE_ANALYTICS = True
ENABLE_SENTIMENT_ANALYSIS = True
# Access in code
from config import DEFAULT_LANGUAGE
print(DEFAULT_LANGUAGE)
๐ API Integrations
External API Services
The application integrates with various external APIs through the api_integrations.py module.
Available APIs
| API | Description |
|---|---|
| get_weather() | Get weather information for any location |
| get_news() | Fetch latest news articles and headlines |
| get_joke() | Retrieve random jokes and humor content |
| get_quote() | Get inspirational and motivational quotes |
| calculate() | Perform mathematical calculations and expressions |
Configuration Options
| Option | Description | Default |
|---|---|---|
| WEATHER_API_KEY | Weather API key (optional) | None |
| NEWS_API_KEY | News API key (optional) | None |
| ENABLE_APIS | Enable/disable API integrations | True |
| FALLBACK_RESPONSES | Use fallback responses if API fails | True |
โ๏ธ Configuration
Configuration in this Python application is handled through:
Configuration File
Edit config.py file in the root directory:
# config.py
DEFAULT_LANGUAGE = 'en'
ENABLE_ANALYTICS = True
ENABLE_SENTIMENT_ANALYSIS = True
ENABLE_API_INTEGRATIONS = True
# Optional API keys
WEATHER_API_KEY = None
NEWS_API_KEY = None
Note: API keys are optional. The bot works without them but with limited functionality.
Environment Variables
You can also use environment variables:
export DEFAULT_LANGUAGE=en
export ENABLE_ANALYTICS=true
export WEATHER_API_KEY=your_key_here
Runtime Configuration
Configure settings programmatically:
- Language: Use bot.set_language('es') to change language
- Analytics: Enable/disable through config.py
- API Integrations: Configure API keys in config.py
- Response Templates: Customize in response_templates.py
Configuration changes require restarting the application.
Web Interface Configuration
The Flask web interface can be configured in app.py. Default port is 5000, but you can change it in the run configuration.
๐ Project Structure
Note: Edit config.py to customize settings and optional API keys.
๐ Detailed File Descriptions
๐ค chatbot.py
Purpose: Core ConversationalAIBot class. Main chatbot implementation with context management, intent recognition, entity extraction, and response generation.
Key Features:
- Main chatbot class
- Context-aware conversations
- Multi-turn dialogue support
- Integration with all modules
- Response generation
- Conversation management
๐ง context_manager.py
Purpose: Context management module. Maintains conversation context across multiple turns for coherent dialogues.
Key Features:
- Context storage and retrieval
- Multi-turn conversation handling
- Context window management
- Context cleanup
๐ฏ intent_recognizer.py
Purpose: Intent recognition module. Identifies user intentions from natural language using pattern matching and ML.
Key Features:
- Pattern matching
- Machine learning-based recognition
- Intent classification
- Confidence scoring
๐ entity_extractor.py
Purpose: Entity extraction module. Extracts important information like names, dates, locations from messages.
Key Features:
- Named entity recognition
- Date/time extraction
- Location extraction
- Person name extraction
๐พ conversation_history.py
Purpose: Conversation history management. Stores and retrieves past conversations for context continuity.
Key Features:
- Conversation storage
- History retrieval
- Session management
- JSON persistence
๐ sentiment_analyzer.py
Purpose: Sentiment analysis module. Analyzes user sentiment to provide better, empathetic responses.
Key Features:
- Sentiment classification
- Positive/negative/neutral detection
- Emotion analysis
- Sentiment scoring
๐ language_support.py
Purpose: Multi-language support module. Detects and supports 8+ languages with automatic detection.
Key Features:
- Language detection
- Multi-language responses
- Language switching
- Translation support
๐ api_integrations.py
Purpose: API integrations module. Handles external API calls for weather, news, jokes, quotes, and calculations.
Key Features:
- Weather API integration
- News API integration
- Jokes and quotes APIs
- Calculation functionality
- Error handling and fallbacks
๐ conversation_analytics.py
Purpose: Analytics module. Tracks metrics, intent distribution, and session statistics.
Key Features:
- Metrics tracking
- Intent distribution analysis
- Session statistics
- Analytics reporting
๐ response_templates.py
Purpose: Response templates module. Template-based response system for consistent interactions.
Key Features:
- Template management
- Response formatting
- Template selection
- Custom template support
โ๏ธ config.py
Purpose: Configuration module. Contains settings, constants, and configuration options.
Key Features:
- Application settings
- Default configurations
- API key management
- Feature toggles
๐ app.py
Purpose: Flask web interface application. Provides web-based interface for the chatbot.
Key Features:
- Flask web server
- REST API endpoints
- Web interface routes
- Template rendering
๐ฆ requirements.txt
Purpose: Python dependencies list. Contains all required packages and versions.
Key Features:
- Dependency management
- Version specifications
- Package listings
- Installation instructions
๐ README.md
Purpose: Project overview and quick start guide. Provides introduction, features, installation instructions, and usage examples.
Contents:
- Project description
- Features list
- Installation guide
- Usage instructions
- Project structure
- Support information
๐ RELEASE_NOTES.md
Purpose: Release notes. Documents features, changes, and updates in the current version.
Contents:
- Release information
- Feature list
- Technical details
- Changelog
โ๏ธ LICENSE
Purpose: MIT License file. Contains the full MIT License text and copyright information.
License Type: MIT License
Copyright: ยฉ 2026 RSK World
๐ซ .gitignore
Purpose: Git ignore rules. Specifies files and directories that should not be tracked by version control.
Excluded Items:
- .env files (API keys)
- node_modules/ directory
- build/ directory
- IDE configuration files
- OS-specific files
- Log files
๐ File Statistics
๐ File Organization
Core Modules: chatbot.py, context_manager.py, intent_recognizer.py, entity_extractor.py, conversation_history.py
Advanced Features: sentiment_analyzer.py, language_support.py, api_integrations.py, conversation_analytics.py, response_templates.py
Documentation: README.md, QUICKSTART.md, INSTALLATION.md, LICENSE
Configuration: config.py, requirements.txt, .gitignore
Web Interface: app.py, templates/index.html, static/
๐ Advanced Features Details
1. Context-Aware Conversations
Advanced context management maintains conversation context across multiple turns. The bot remembers previous messages, user information, and conversation history, enabling coherent and natural multi-turn dialogues.
2. Intent Recognition & Entity Extraction
Intelligent intent recognition identifies user intentions from natural language using pattern matching and machine learning. Entity extraction automatically identifies names, dates, locations, and other important information from messages.
3. Sentiment Analysis
Sentiment analysis module analyzes user sentiment (positive, negative, neutral) to provide better, empathetic responses. The bot adapts its tone and responses based on user emotions.
4. Multi-Language Support
Supports 8+ languages (English, Spanish, French, German, Hindi, Chinese, Japanese, Arabic) with automatic language detection. Users can switch languages or the bot detects the language automatically.
5. API Integrations
Integrated with external APIs for weather information, news articles, jokes, quotes, and calculations. The bot can fetch real-time data and provide enhanced functionality beyond basic conversations.
6. Conversation Analytics
Comprehensive analytics tracking metrics, intent distribution, session statistics, and conversation patterns. Provides insights into user engagement and bot performance.
7. Flask Web Interface
Beautiful Flask-based web interface with responsive design. Provides easy-to-use web interface for interacting with the chatbot, viewing analytics, and managing conversations.
8. Modular & Extensible
Well-organized modular design makes it easy to extend with new features, integrations, and customizations. Each module is independent and can be modified or extended easily.
๐ง Troubleshooting
Installation Issues
- Make sure you're using Python 3.8 or higher: python --version
- Install all dependencies: pip install -r requirements.txt
- Use virtual environment: python -m venv venv then activate it
- If pip install fails, try: pip install --upgrade pip first
NLTK Data Issues
- Download required NLTK data: python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords')"
- If NLTK download fails, check internet connection
- NLTK data is downloaded automatically on first use
Import Errors
- Make sure you're in the project directory
- Activate virtual environment before running
- Check that all dependencies are installed: pip list
- If module not found, reinstall: pip install -r requirements.txt --force-reinstall
Common Issues
- Module not found errors: Run pip install -r requirements.txt to install all dependencies
- Port already in use: The default Flask port is 5000. Change it in app.py or set PORT environment variable
- Virtual environment issues: Make sure virtual environment is activated before running
- API integration errors: API keys are optional. The bot works without them but with limited functionality
- Context errors: Check that conversation_history.json is writable
๐ Requirements
numpy>=1.21.0
scikit-learn>=1.0.0
nltk>=3.6
spacy>=3.4.0
python-dateutil>=2.8.2
colorama>=0.4.4
setuptools>=65.0.0
flask>=2.3.0
requests>=2.28.0
See requirements.txt for the complete list of dependencies.
Python Version: Python 3.8 or higher required.
๐ฏ Use Cases
๐ป Development
AI coding assistant for developers
๐ Education
Learning and tutoring platform
๐ผ Business
Professional consultation and advice
โ๏ธ Creative Writing
Storytelling and content creation
๐ฌ General Chat
Casual conversations and assistance
๐ Multi-Language
8+ languages with automatic detection
๐ฌ Support
For support, questions, or more projects:
- Website: https://rskworld.in
- Email: help@rskworld.in
- Phone: +91 93305 39277
๐ License
This project is provided as-is for educational and development purposes.
MIT License - See LICENSE file for details.
๐ Demo Folder Structure
The demo/ folder contains demonstration and documentation files for this project.
demo/
โโโ index.html # This documentation page
โโโ demo.html # Interactive demo page
โโโ style.css # Stylesheet (optional, styles are inline)
โโโ script.js # JavaScript (optional, can be added for interactivity)
๐ Demo Files Description
๐ index.html
Purpose: Comprehensive project documentation and information page. This HTML file contains all details about the Conversational AI Bot project.
Contents:
- Complete project overview
- All features documentation
- Installation instructions
- Usage examples
- Code examples
- API integration reference
- Configuration details
- Detailed file and folder descriptions
- Project structure
- Troubleshooting guide
- Support information
Features:
- Self-contained HTML with inline CSS
- Responsive design
- Modern, beautiful UI
- Well-organized sections
- Easy navigation
๐จ style.css
Purpose: External stylesheet file (optional). Currently, all styles are embedded inline in index.html, but this file can be used for additional custom styles if needed.
Status: Empty file - can be used for custom styling
Usage: Add custom CSS styles here if you want to override or extend the inline styles in index.html
๐ script.js
Purpose: External JavaScript file (optional). Can be used to add interactive features to the documentation page.
Status: Empty file - can be used for additional functionality
Potential Uses:
- Table of contents navigation
- Smooth scrolling
- Search functionality
- Copy code snippets
- Theme toggle
- Print functionality
- Interactive elements
๐ฎ demo.html
Purpose: Interactive demo page showcasing the Conversational AI Bot features in action.
Features:
- Live chat interface
- Context management demonstration
- Intent recognition and entity extraction
- Sentiment analysis display
- API integrations (weather, news, jokes, calculations)
- Real-time statistics and analytics
- Quick action buttons
- Beautiful, responsive UI
Usage: Open demo.html in your browser to try the interactive demo!
๐ก About the Demo Folder
The demo/ folder is separate from the main conversational-ai-bot/ project folder. It contains:
- Documentation: This comprehensive HTML documentation page that explains the entire project
- Interactive Demo: demo.html - Live interactive demo showcasing all chatbot features
- Styling: Optional CSS file for custom styling
- Scripts: Optional JavaScript file for enhanced interactivity
Note: To view this documentation, simply open demo/index.html in any web browser. To try the interactive demo, open demo.html. Both pages are self-contained and work offline.