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
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
conversational-ai-bot
RSK World
conversational-ai-bot
Conversational AI Bot - Python + NLP + Flask + Machine Learning + Chatbot + AI
conversational-ai-bot
  • __pycache__
  • static
  • templates
  • .gitignore577 B
  • ADVANCED_FEATURES.md5.7 KB
  • CHANGELOG.md2.2 KB
  • INSTALLATION.md1.8 KB
  • LICENSE1.2 KB
  • PROJECT_INFO.md2.8 KB
  • PROJECT_STATUS.md3.4 KB
  • QUICKSTART.md2.5 KB
  • README.md4.8 KB
  • __init__.py448 B
  • api_integrations.py6 KB
  • app.py4.2 KB
  • chatbot.py14.8 KB
  • config.py1.1 KB
  • context_manager.py5.8 KB
  • conversation_analytics.py5.9 KB
  • conversation_history.json413 B
  • conversation_history.py4.9 KB
  • entity_extractor.py6.6 KB
  • example_usage.py4.3 KB
  • intent_recognizer.py6.6 KB
  • language_support.py5 KB
  • main.py4.7 KB
  • requirements.txt311 B
  • response_templates.py7.2 KB
  • sentiment_analyzer.py5.6 KB
  • setup.py1.6 KB
  • test_chatbot.py5 KB
  • validate_project.py4.1 KB
QUICKSTART.mdapp.pylanguage_support.py
QUICKSTART.md
Raw Download

QUICKSTART.md

# Quick Start Guide

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

## Quick Start (5 Minutes)

### Step 1: Install Dependencies

```bash
pip install -r requirements.txt
```

### Step 2: Download NLTK Data

```bash
python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords')"
```

### Step 3: Run the Bot

```bash
python main.py
```

That's it! You're ready to chat.

## Basic Usage

### Interactive Mode

```bash
python main.py
```

Then type your messages and press Enter.

### Programmatic Usage

```python
from chatbot import ConversationalAIBot

# Create bot instance
bot = ConversationalAIBot()

# Chat with the bot
response = bot.chat("Hello, my name is John")
print(response)

# Bot remembers context
response = bot.chat("What's my name?")
print(response) # Output: "Your name is John..."
```

## Example Commands

When running in interactive mode, you can use:

- `help` - Show available commands
- `context` - Show current conversation context
- `history` - Show conversation history
- `clear` - Clear conversation history
- `quit` or `exit` - Exit the chatbot

## Example Conversations

### Example 1: Basic Introduction

```
You: Hello
Bot: Hello! I'm a conversational AI bot. How can I assist you today?

You: My name is Alice
Bot: Nice to meet you, Alice! I'll remember that. How can I help you today?

You: What's my name?
Bot: Your name is Alice. I remember you from our previous conversation!
```

### Example 2: Asking Questions

```
You: What can you do?
Bot: I'm a conversational AI bot with the following capabilities:
• Context-aware conversations
• Multi-turn dialogue support
• Intent recognition
• Entity extraction
• Conversation history

You: What time is it?
Bot: The current time is 03:45 PM.

You: What's the date?
Bot: Today's date is January 01, 2026.
```

## Run Examples

To see more examples:

```bash
python example_usage.py
```

## Run Tests

To run the test suite:

```bash
python test_chatbot.py
```

## Need Help?

- Check the full [README.md](README.md) for detailed documentation
- See [INSTALLATION.md](INSTALLATION.md) for installation help
- Visit https://rskworld.in for more resources

## 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
language_support.py
Raw Download
Find: Go to:
"""
Multi-Language Support Module
Provides translation and multi-language support for the chatbot.

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

from typing import Dict, Optional
import re


class LanguageSupport:
    """
    Provides multi-language support and language detection.
    """
    
    def __init__(self):
        """Initialize language support."""
        # Supported languages
        self.supported_languages = {
            'en': 'English',
            'es': 'Spanish',
            'fr': 'French',
            'de': 'German',
            'hi': 'Hindi',
            'zh': 'Chinese',
            'ja': 'Japanese',
            'ar': 'Arabic'
        }
        
        # Language detection patterns
        self.language_patterns = {
            'hi': r'[\u0900-\u097F]',  # Devanagari script
            'zh': r'[\u4e00-\u9fff]',  # Chinese characters
            'ja': r'[\u3040-\u309F\u30A0-\u30FF]',  # Hiragana/Katakana
            'ar': r'[\u0600-\u06FF]',  # Arabic script
        }
        
        # Common phrases in different languages
        self.greetings = {
            'en': ['hello', 'hi', 'hey', 'greetings'],
            'es': ['hola', 'buenos días', 'buenas tardes'],
            'fr': ['bonjour', 'salut', 'bonsoir'],
            'de': ['hallo', 'guten tag', 'guten morgen'],
            'hi': ['नमस्ते', 'नमस्कार', 'हैलो'],
            'zh': ['你好', '您好'],
            'ja': ['こんにちは', 'こんばんは'],
            'ar': ['مرحبا', 'السلام عليكم']
        }
        
        self.current_language = 'en'
    
    def detect_language(self, text: str) -> str:
        """
        Detect language of input text.
        
        Args:
            text: Input text
            
        Returns:
            Language code (e.g., 'en', 'es', 'hi')
        """
        if not text:
            return 'en'
        
        # Check for script-based languages
        for lang_code, pattern in self.language_patterns.items():
            if re.search(pattern, text):
                return lang_code
        
        # Check for common phrases
        text_lower = text.lower()
        for lang_code, phrases in self.greetings.items():
            for phrase in phrases:
                if phrase.lower() in text_lower:
                    return lang_code
        
        # Default to English
        return 'en'
    
    def set_language(self, language_code: str) -> bool:
        """
        Set current language.
        
        Args:
            language_code: Language code (e.g., 'en', 'es')
            
        Returns:
            True if language is supported, False otherwise
        """
        if language_code in self.supported_languages:
            self.current_language = language_code
            return True
        return False
    
    def get_language(self) -> str:
        """Get current language code."""
        return self.current_language
    
    def get_language_name(self, language_code: Optional[str] = None) -> str:
        """
        Get language name.
        
        Args:
            language_code: Language code (uses current if not provided)
            
        Returns:
            Language name
        """
        code = language_code or self.current_language
        return self.supported_languages.get(code, 'Unknown')
    
    def get_supported_languages(self) -> Dict[str, str]:
        """
        Get all supported languages.
        
        Returns:
            Dictionary mapping language codes to names
        """
        return self.supported_languages.copy()
    
    def translate_greeting(self, language_code: str) -> str:
        """
        Get greeting in specified language.
        
        Args:
            language_code: Target language code
            
        Returns:
            Greeting in target language
        """
        greetings = {
            'en': 'Hello! How can I help you?',
            'es': '¡Hola! ¿Cómo puedo ayudarte?',
            'fr': 'Bonjour! Comment puis-je vous aider?',
            'de': 'Hallo! Wie kann ich Ihnen helfen?',
            'hi': 'नमस्ते! मैं आपकी कैसे मदद कर सकता हूं?',
            'zh': '你好!我能为你做什么?',
            'ja': 'こんにちは!何かお手伝いできますか?',
            'ar': 'مرحبا! كيف يمكنني مساعدتك؟'
        }
        return greetings.get(language_code, greetings['en'])
    
    def is_supported(self, language_code: str) -> bool:
        """
        Check if language is supported.
        
        Args:
            language_code: Language code to check
            
        Returns:
            True if supported, False otherwise
        """
        return language_code in self.supported_languages

160 lines•5 KB
python

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