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
multi-language-chatbot
/
modules
RSK World
multi-language-chatbot
Multi-language Chatbot - Python + Flask + OpenAI API + NLP + Translation + Language Detection + Cultural Adaptation
modules
  • __pycache__
  • __init__.py194 B
  • analytics_engine.py28.6 KB
  • chatbot_core.py10.8 KB
  • collaboration_manager.py22.3 KB
  • conversation_memory.py25.2 KB
  • cultural_adapter.py12.3 KB
  • document_analyzer.py21.5 KB
  • language_detector.py5.8 KB
  • multimodal_processor.py32.7 KB
  • personality_engine.py33.6 KB
  • sentiment_analyzer.py16.9 KB
  • translator.py7.5 KB
  • voice_processor.py13.2 KB
README.md.env.example.gitignoreconfig.py
README.md
Raw Download

README.md

# Multi-language Chatbot

**Advanced NLP Chatbot with Multi-language Support and Cultural Adaptation**

![Multi-language Chatbot](https://img.shields.io/badge/Python-3.8+-blue.svg)
![License](https://img.shields.io/badge/License-MIT-green.svg)
![Status](https://img.shields.io/badge/Status-Active-brightgreen.svg)

**Developed by RSK World (https://rskworld.in)**
*Founder: Molla Samser | Designer & Tester: Rima Khatun*
*Contact: help@rskworld.in | +91 93305 39277*
*Year: 2026*

---

## 🌟 Features

### Core Features
- **🌍 Multi-language Support**: Communicate in 12+ languages including English, Hindi, Bengali, Spanish, French, German, Chinese, Japanese, Arabic, Portuguese, Russian, and Italian
- **πŸ” Automatic Language Detection**: Automatically detects user's language with confidence scoring
- **πŸ”„ Real-time Translation**: Seamlessly translates messages between supported languages
- **🎭 Cultural Adaptation**: Adapts responses based on cultural context and regional preferences
- **πŸ’¬ Intelligent Conversation**: Powered by OpenAI GPT with fallback to rule-based responses
- **🎨 Modern Web Interface**: Responsive, Bootstrap-based UI with real-time chat
- **πŸ“Š Session Analytics**: Track conversation statistics and language usage
- **πŸ’Ύ Chat History**: Save and export conversation history
- **πŸ”’ Security Features**: Rate limiting, input validation, CORS configuration
- **πŸ§ͺ Comprehensive Testing**: Full test suite with pytest

### Advanced Features
- **🎀 Voice Input/Output**: Speech-to-text and text-to-speech capabilities with multiple language support
- **😊 Sentiment Analysis**: Advanced sentiment and emotion detection with multi-language support
- **🧠 Conversation Memory**: Persistent conversation context with learning capabilities
- **πŸ“„ Document Analysis**: Support for PDF, Word, Excel, images with OCR and content extraction
- **πŸ‘₯ Real-time Collaboration**: Multi-user chat rooms with WebSocket support
- **πŸ“ˆ Advanced Analytics**: Comprehensive analytics dashboard with visualizations and reports
- **🎭 Personality Customization**: Multiple personality profiles (Professional, Friendly, Casual, Academic, Creative)
- **πŸ–ΌοΈ Multi-modal Input**: Support for text, voice, images, video, and mixed input processing
- **πŸ€– AI-Powered Features**: OpenAI integration for advanced NLP capabilities
- **πŸ“± Mobile Responsive**: Fully responsive design for all devices

---

## πŸš€ Quick Start

### Prerequisites

- Python 3.8 or higher
- pip (Python package manager)
- OpenAI API key (optional, for AI responses)
- Google Translate API key (optional, for enhanced translations)

### Installation

1. **Clone or download the project**
```bash
cd multi-language-chatbot
```

2. **Create a virtual environment**
```bash
python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate
```

3. **Install dependencies**
```bash
pip install -r requirements.txt
```

4. **Set up environment variables**
```bash
# Copy the example environment file
cp .env.example .env

# Edit .env file with your API keys
# OPENAI_API_KEY=your_openai_api_key_here
# GOOGLE_TRANSLATE_API_KEY=your_google_translate_api_key_here
```

5. **Run the application**
```bash
python run.py
```

6. **Open your browser**
Navigate to `http://localhost:5000`

---

## πŸ“ Project Structure

```
multi-language-chatbot/
β”œβ”€β”€ app.py # Main Flask application
β”œβ”€β”€ run.py # Application runner
β”œβ”€β”€ config.py # Configuration settings
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ .env.example # Environment variables template
β”œβ”€β”€ README.md # This file
β”œβ”€β”€ modules/ # Core modules
β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ language_detector.py # Language detection
β”‚ β”œβ”€β”€ translator.py # Translation services
β”‚ β”œβ”€β”€ cultural_adapter.py # Cultural adaptation
β”‚ └── chatbot_core.py # Chatbot logic
β”œβ”€β”€ templates/ # HTML templates
β”‚ └── index.html # Main interface
β”œβ”€β”€ static/ # Static assets
β”‚ β”œβ”€β”€ css/
β”‚ β”‚ └── style.css # Stylesheets
β”‚ └── js/
β”‚ └── chatbot.js # JavaScript functionality
β”œβ”€β”€ tests/ # Test files
β”œβ”€β”€ logs/ # Log files
└── instance/ # Instance files
```

---

## πŸ› οΈ Configuration

### Environment Variables

Create a `.env` file based on `.env.example`:

```bash
# Required for AI responses
OPENAI_API_KEY=your_openai_api_key_here

# Optional for enhanced translations
GOOGLE_TRANSLATE_API_KEY=your_google_translate_api_key_here

# Flask settings
FLASK_ENV=development
SECRET_KEY=your-secret-key-here

# Server settings
HOST=0.0.0.0
PORT=5000
```

### Supported Languages

The chatbot supports the following languages:

| Code | Language | Native Name |
|------|----------|-------------|
| en | English | English |
| hi | Hindi | ΰ€Ήΰ€Ώΰ€¨ΰ₯ΰ€¦ΰ₯€ |
| bn | Bengali | বাংলা |
| es | Spanish | EspaΓ±ol |
| fr | French | FranΓ§ais |
| de | German | Deutsch |
| zh | Chinese | δΈ­ζ–‡ |
| ja | Japanese | ζ—₯本θͺž |
| ar | Arabic | Ψ§Ω„ΨΉΨ±Ψ¨ΩŠΨ© |
| pt | Portuguese | PortuguΓͺs |
| ru | Russian | Русский |
| it | Italian | Italiano |

---

## 🎯 Usage

### Basic Usage

1. **Open the web interface** at `http://localhost:5000`
2. **Type your message** in any supported language
3. **The chatbot will**:
- Detect your language automatically
- Process your message
- Respond in the same language
- Adapt responses culturally

### Advanced Features

- **Language Selection**: Manually select your preferred language
- **Language Detection**: Detect the language of any text
- **Chat Export**: Export conversation history as JSON
- **Session Stats**: View message count and languages used
- **Cultural Adaptation**: Responses are adapted for cultural context

### API Endpoints

- `POST /chat` - Send a message and get response
- `POST /detect_language` - Detect language of text
- `POST /translate` - Translate text between languages
- `GET /languages` - Get supported languages
- `GET /health` - Health check

---

## πŸ”§ Development

### Running Tests

```bash
# Install test dependencies
pip install pytest pytest-flask

# Run tests
pytest tests/
```

### Code Style

```bash
# Format code
black .

# Check linting
flake8 .
```

### Adding New Languages

1. Update `SUPPORTED_LANGUAGES` in `config.py`
2. Add language patterns in `language_detector.py`
3. Update language mappings in `translator.py`
4. Add cultural context in `cultural_adapter.py`

---

## 🌐 API Reference

### Chat Endpoint

**POST** `/chat`

```json
{
"message": "Hello, how are you?",
"language": "en"
}
```

**Response:**
```json
{
"response": "I'm doing well, thank you! How can I help you today?",
"detected_language": "en",
"language_name": "English",
"confidence": 0.95
}
```

### Language Detection Endpoint

**POST** `/detect_language`

```json
{
"text": "Bonjour, comment allez-vous?"
}
```

**Response:**
```json
{
"language": "fr",
"language_name": "FranΓ§ais (French)",
"confidence": 0.92
}
```

### Translation Endpoint

**POST** `/translate`

```json
{
"text": "Hello, world!",
"source_language": "en",
"target_language": "es"
}
```

**Response:**
```json
{
"translated_text": "Β‘Hola, mundo!",
"source_language": "en",
"target_language": "es"
}
```

---

## πŸ”’ Security

- Input validation and sanitization
- Rate limiting to prevent abuse
- CORS configuration
- Environment variable protection
- Secure session handling

---

## πŸ“Š Monitoring

### Logging

- Application logs stored in `logs/chatbot.log`
- Configurable log levels
- Error tracking and reporting

### Analytics

- Message count tracking
- Language usage statistics
- Performance monitoring
- User session analytics

---

## 🀝 Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

---

## πŸ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

## πŸ“ž Support

**RSK World**
- πŸ“§ Email: help@rskworld.in
- πŸ“± Phone: +91 93305 39277
- 🌐 Website: https://rskworld.in
- πŸ“ Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147

---

## πŸ™ Acknowledgments

- OpenAI for GPT API
- Google for Translate API
- Flask web framework
- Bootstrap for UI components
- Font Awesome for icons

---

## πŸ“ˆ Version History

- **v1.0.0** (2026) - Initial release with multi-language support
- Features: Language detection, translation, cultural adaptation, web interface

---

**Β© 2026 RSK World. All rights reserved.**
*Content used for educational purposes only.*
.env.example
Raw Download
Find: Go to:
# Multi-language Chatbot Environment Configuration
# Author: RSK World (https://rskworld.in)
# Founder: Molla Samser
# Designer & Tester: Rima Khatun
# Contact: help@rskworld.in, +91 93305 39277
# Year: 2026

# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key_here

# Flask Configuration
FLASK_ENV=development
FLASK_DEBUG=True
SECRET_KEY=your-secret-key-here

# Server Configuration
HOST=0.0.0.0
PORT=5000

# Translation Service Configuration
GOOGLE_TRANSLATE_API_KEY=your_google_translate_api_key_here

# Logging Configuration
LOG_LEVEL=INFO
LOG_FILE=logs/chatbot.log

# Database Configuration (Optional)
DATABASE_URL=sqlite:///chatbot.db

# Redis Configuration (Optional for caching)
REDIS_URL=redis://localhost:6379/0

# Rate Limiting
RATE_LIMIT_PER_MINUTE=60

# Chatbot Configuration
MAX_CONVERSATION_LENGTH=20
DEFAULT_LANGUAGE=en
SUPPORTED_LANGUAGES=en,hi,bn,es,fr,de,zh,ja,ar,pt,ru,it

# Cultural Adaptation
CULTURAL_ADAPTATION_ENABLED=True
TIMEZONE_AWARENESS=True

# Security
CORS_ORIGINS=*
ENABLE_HTTPS=False

# Monitoring and Analytics
ENABLE_ANALYTICS=False
ANALYTICS_API_KEY=your_analytics_api_key_here
52 linesβ€’1.1 KB
text
.gitignore
Raw Download
Find: Go to:
# Multi-language Chatbot Git Ignore
# Author: RSK World (https://rskworld.in)
# Founder: Molla Samser
# Designer & Tester: Rima Khatun
# Contact: help@rskworld.in, +91 93305 39277
# Year: 2026

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Project specific
logs/
*.log
chatbot.db
instance/
.pytest_cache/

# API Keys and secrets
config.json
secrets.json
*.pem
*.key

# Temporary files
tmp/
temp/
*.tmp
*.temp

# Backup files
*.bak
*.backup

# Cache
.cache/
cache/

# Docker
.dockerignore

# Node.js (if using for frontend)
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Compiled files
*.pyc
*.pyo
*.pyd

# Virtual environments
bin/
include/
lib/
lib64/
share/
pyvenv.cfg

# Local development
local/
dev/
development/
186 linesβ€’2 KB
text
config.py
Raw Download
Find: Go to:
"""
Configuration Module
Author: RSK World (https://rskworld.in)
Founder: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in, +91 93305 39277
Year: 2026
Description: Configuration settings for multi-language chatbot
"""

import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

class Config:
    """Base configuration"""
    
    # Basic Flask Configuration
    SECRET_KEY = os.getenv('SECRET_KEY', 'multi-language-chatbot-rsk-world-2026')
    DEBUG = os.getenv('FLASK_DEBUG', 'False').lower() == 'true'
    
    # Server Configuration
    HOST = os.getenv('HOST', '0.0.0.0')
    PORT = int(os.getenv('PORT', 5000))
    
    # API Keys
    OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
    GOOGLE_TRANSLATE_API_KEY = os.getenv('GOOGLE_TRANSLATE_API_KEY')
    
    # Chatbot Configuration
    MAX_CONVERSATION_LENGTH = int(os.getenv('MAX_CONVERSATION_LENGTH', 20))
    DEFAULT_LANGUAGE = os.getenv('DEFAULT_LANGUAGE', 'en')
    SUPPORTED_LANGUAGES = os.getenv('SUPPORTED_LANGUAGES', 'en,hi,bn,es,fr,de,zh,ja,ar,pt,ru,it').split(',')
    
    # Cultural Adaptation
    CULTURAL_ADAPTATION_ENABLED = os.getenv('CULTURAL_ADAPTATION_ENABLED', 'True').lower() == 'true'
    TIMEZONE_AWARENESS = os.getenv('TIMEZONE_AWARENESS', 'True').lower() == 'true'
    
    # Security
    CORS_ORIGINS = os.getenv('CORS_ORIGINS', '*').split(',')
    ENABLE_HTTPS = os.getenv('ENABLE_HTTPS', 'False').lower() == 'true'
    
    # Rate Limiting
    RATE_LIMIT_PER_MINUTE = int(os.getenv('RATE_LIMIT_PER_MINUTE', 60))
    
    # Logging
    LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
    LOG_FILE = os.getenv('LOG_FILE', 'logs/chatbot.log')
    
    # Database (Optional)
    DATABASE_URL = os.getenv('DATABASE_URL', 'sqlite:///chatbot.db')
    
    # Redis (Optional for caching)
    REDIS_URL = os.getenv('REDIS_URL', 'redis://localhost:6379/0')
    
    # Analytics
    ENABLE_ANALYTICS = os.getenv('ENABLE_ANALYTICS', 'False').lower() == 'true'
    ANALYTICS_API_KEY = os.getenv('ANALYTICS_API_KEY')
    
    # Language Detection Settings
    LANGUAGE_DETECTION_CONFIDENCE_THRESHOLD = float(os.getenv('LANGUAGE_DETECTION_CONFIDENCE_THRESHOLD', 0.7))
    
    # Translation Settings
    TRANSLATION_CACHE_SIZE = int(os.getenv('TRANSLATION_CACHE_SIZE', 1000))
    TRANSLATION_TIMEOUT = int(os.getenv('TRANSLATION_TIMEOUT', 10))
    
    # OpenAI Settings
    OPENAI_MODEL = os.getenv('OPENAI_MODEL', 'gpt-3.5-turbo')
    OPENAI_MAX_TOKENS = int(os.getenv('OPENAI_MAX_TOKENS', 500))
    OPENAI_TEMPERATURE = float(os.getenv('OPENAI_TEMPERATURE', 0.7))
    
    @staticmethod
    def init_app(app):
        """Initialize application with configuration"""
        pass

class DevelopmentConfig(Config):
    """Development configuration"""
    DEBUG = True
    LOG_LEVEL = 'DEBUG'

class ProductionConfig(Config):
    """Production configuration"""
    DEBUG = False
    ENABLE_HTTPS = True
    
    @classmethod
    def init_app(cls, app):
        Config.init_app(app)
        
        # Production-specific initialization
        import logging
        from logging.handlers import RotatingFileHandler
        
        if not app.debug:
            file_handler = RotatingFileHandler(
                cls.LOG_FILE, 
                maxBytes=10240000, 
                backupCount=10
            )
            file_handler.setFormatter(logging.Formatter(
                '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
            ))
            file_handler.setLevel(logging.INFO)
            app.logger.addHandler(file_handler)
            app.logger.setLevel(logging.INFO)
            app.logger.info('Multi-language Chatbot startup')

class TestingConfig(Config):
    """Testing configuration"""
    TESTING = True
    OPENAI_API_KEY = 'test-key'
    DEBUG = True

# Configuration dictionary
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'testing': TestingConfig,
    'default': DevelopmentConfig
}

def get_config():
    """Get current configuration based on environment"""
    env = os.getenv('FLASK_ENV', 'development')
    return config.get(env, config['default'])
129 linesβ€’4.2 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