help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
conversational-ai-bot
/
__pycache__
RSK World
conversational-ai-bot
Conversational AI Bot - Python + NLP + Flask + Machine Learning + Chatbot + AI
__pycache__
  • api_integrations.cpython-313.pyc5.4 KB
  • app.cpython-313.pyc5.7 KB
  • chatbot.cpython-313.pyc18.1 KB
  • config.cpython-313.pyc1.1 KB
  • context_manager.cpython-313.pyc7.1 KB
  • conversation_analytics.cpython-313.pyc6.6 KB
  • conversation_history.cpython-313.pyc6.5 KB
  • entity_extractor.cpython-313.pyc7 KB
  • intent_recognizer.cpython-313.pyc5.8 KB
  • language_support.cpython-313.pyc5.2 KB
  • response_templates.cpython-313.pyc6.6 KB
  • sentiment_analyzer.cpython-313.pyc5.4 KB
README.mdapp.pyindex.htmlISSUES_FIXED.mdconversation_history.cpython-313.pyc
README.md
Raw Download

README.md

# Conversational AI Bot

<!--
Project: Conversational AI Bot
Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
-->

Advanced conversational chatbot with context management and multi-turn dialogue support.

## Features

### Core Features
- **Context-aware conversations**: Maintains context across multiple turns
- **Multi-turn dialogue support**: Handles complex conversation flows
- **Intent recognition**: Identifies user intentions from natural language
- **Entity extraction**: Extracts important information from user messages
- **Conversation history**: Stores and retrieves past conversations

### Advanced Features
- **Sentiment Analysis**: Analyzes user sentiment to provide better responses
- **Multi-language Support**: Detects and supports multiple languages (English, Spanish, French, German, Hindi, Chinese, Japanese, Arabic)
- **API Integrations**: Weather, news, jokes, quotes, and calculations
- **Conversation Analytics**: Tracks metrics, intent distribution, and session statistics
- **Response Templates**: Template-based response system for consistent interactions
- **Web Interface**: Beautiful Flask-based web interface for easy interaction
- **Real-time Analytics**: Track conversation patterns and user engagement

## Technologies

- Python 3.8+
- Natural Language Processing (NLP)
- Machine Learning
- Rasa (optional integration)
- Dialogflow (optional integration)

## Installation

1. Clone the repository:
```bash
git clone <repository-url>
cd conversational-ai-bot
```

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Run the chatbot:
```bash
python main.py
```

## Usage

### Basic Usage

```python
from chatbot import ConversationalAIBot

bot = ConversationalAIBot()
response = bot.chat("Hello, how are you?")
print(response)
```

### Advanced Usage with Context

```python
from chatbot import ConversationalAIBot

bot = ConversationalAIBot()
bot.chat("My name is John")
response = bot.chat("What's my name?")
print(response) # The bot remembers your name
```

### Using Advanced Features

```python
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")
```

### Web Interface

Start the web interface:

```bash
python app.py
```

Then open your browser to `http://localhost:5000`

## Project Structure

```
conversational-ai-bot/
├── main.py # Main CLI entry point
├── app.py # Flask web interface
├── chatbot.py # Core chatbot class
├── context_manager.py # Context management
├── intent_recognizer.py # Intent recognition
├── entity_extractor.py # Entity extraction
├── conversation_history.py # Conversation history management
├── sentiment_analyzer.py # Sentiment analysis
├── language_support.py # Multi-language support
├── api_integrations.py # External API integrations
├── conversation_analytics.py # Analytics and metrics
├── response_templates.py # Response templates
├── config.py # Configuration settings
├── example_usage.py # Usage examples
├── test_chatbot.py # Test suite
├── templates/ # Web interface templates
│ └── index.html # Main web interface
├── requirements.txt # Python dependencies
└── README.md # This file
```

## Features

### Context Management
The bot maintains conversation context, allowing it to reference previous messages and maintain coherent multi-turn dialogues.

### Intent Recognition
Uses pattern matching and machine learning techniques to identify user intentions from natural language input.

### Entity Extraction
Extracts entities such as names, dates, locations, and other important information from user messages.

### Conversation History
Stores conversation history for each session, enabling the bot to reference past interactions.

## License

This project is provided by RSK World (https://rskworld.in) for educational and development purposes.

## Contact

- **Website**: https://rskworld.in
- **Email**: help@rskworld.in
- **Phone**: +91 93305 39277

---

© 2026 RSK World. All rights reserved.

app.py
Raw Download
Find: Go to:
"""
Flask Web Interface for Conversational AI Bot
Provides a web-based interface for the chatbot.

Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
"""

from flask import Flask, render_template, request, jsonify, session
from chatbot import ConversationalAIBot
import uuid
import os

app = Flask(__name__)
app.secret_key = os.urandom(24)

# Store bot instances per session
bot_instances = {}


def get_bot():
    """Get or create bot instance for current session."""
    if 'session_id' not in session:
        session['session_id'] = str(uuid.uuid4())
    
    session_id = session['session_id']
    
    if session_id not in bot_instances:
        bot_instances[session_id] = ConversationalAIBot(session_id)
    
    return bot_instances[session_id]


@app.route('/')
def index():
    """Render main chat interface."""
    return render_template('index.html')


@app.route('/api/chat', methods=['POST'])
def chat():
    """Handle chat API requests."""
    try:
        data = request.get_json()
        user_message = data.get('message', '').strip()
        
        if not user_message:
            return jsonify({
                'success': False,
                'error': 'Message is required'
            }), 400
        
        bot = get_bot()
        response = bot.chat(user_message)
        
        # Get additional metadata
        sentiment = bot.get_sentiment_analysis(user_message)
        context = bot.get_context_summary()
        
        return jsonify({
            'success': True,
            'response': response,
            'sentiment': sentiment.get('sentiment'),
            'sentiment_score': sentiment.get('score'),
            'context': context
        })
    
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500


@app.route('/api/history', methods=['GET'])
def get_history():
    """Get conversation history."""
    try:
        bot = get_bot()
        limit = request.args.get('limit', 10, type=int)
        history = bot.get_conversation_history(limit=limit)
        
        return jsonify({
            'success': True,
            'history': history
        })
    
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500


@app.route('/api/analytics', methods=['GET'])
def get_analytics():
    """Get conversation analytics."""
    try:
        bot = get_bot()
        analytics = bot.get_analytics()
        summary = bot.get_analytics_summary()
        
        return jsonify({
            'success': True,
            'analytics': analytics,
            'summary': summary
        })
    
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500


@app.route('/api/clear', methods=['POST'])
def clear_session():
    """Clear conversation session."""
    try:
        bot = get_bot()
        bot.clear_session()
        
        return jsonify({
            'success': True,
            'message': 'Session cleared successfully'
        })
    
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500


@app.route('/api/language', methods=['POST'])
def set_language():
    """Set conversation language."""
    try:
        data = request.get_json()
        language_code = data.get('language', 'en')
        
        bot = get_bot()
        success = bot.set_language(language_code)
        
        return jsonify({
            'success': success,
            'language': bot.get_current_language(),
            'message': f'Language set to {language_code}' if success else 'Invalid language code'
        })
    
    except Exception as e:
        return jsonify({
            'success': False,
            'error': str(e)
        }), 500


if __name__ == '__main__':
    # Create templates directory if it doesn't exist
    os.makedirs('templates', exist_ok=True)
    os.makedirs('static', exist_ok=True)
    
    app.run(debug=True, host='0.0.0.0', port=5000)

168 lines•4.2 KB
python
conversation_history.cpython-313.pyc

This file cannot be displayed in the browser.

Download File
🚀 Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ❤️

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer