๐ŸŒ Multi-language Chatbot

Advanced NLP chatbot with multi-language support and cultural adaptation. Features automatic language detection, real-time translation, cultural adaptation, voice input/output, sentiment analysis, conversation memory, document analysis, collaboration tools, and analytics.
Try Interactive Demo

๐Ÿ“– Project Overview

Multi-language Chatbot is an advanced NLP chatbot that integrates OpenAI API with Flask to create an intelligent multilingual conversational assistant. This project offers automatic language detection, real-time translation between 12+ languages, cultural adaptation of responses, voice input/output with multi-language support, sentiment analysis and emotion detection, conversation memory with persistent context, document analysis with OCR support, real-time collaboration features, comprehensive analytics dashboard, and personality customization. Perfect for global communication, multilingual applications, and businesses requiring intelligent multilingual conversational AI.

โšก Quick Facts

๐ŸŽฏ Type: Multi-language Chatbot with NLP Capabilities
๐Ÿค– AI Features: OpenAI API, Language Detection, Translation, Cultural Adaptation, Voice I/O, Sentiment Analysis
โšก Setup Time: ~5 minutes
๐Ÿ“ฆ Backend: Python with Flask
๐ŸŽจ Frontend: HTML5, CSS3, JavaScript
๐Ÿง  AI Model: OpenAI GPT-3.5 Turbo
๐Ÿ“ฑ Platform: Web Browser
๐Ÿ”ง Technologies: Python, Flask, OpenAI API, langdetect, googletrans
25+
Files
5000+
Lines of Code
20+
Advanced Features
200K
Context Tokens
Developer: Molla Samser | Website: rskworld.in | Email: help@rskworld.in
Difficulty Level: Intermediate - Perfect for developers learning Python, Flask, OpenAI API integration, NLP, translation services, and multi-language chatbot development.

โœจ 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 for seamless multilingual conversations.

๐Ÿ”„ Real-time Translation

Seamlessly translates messages between any supported languages in real-time with cultural context awareness.

๐ŸŽญ Cultural Adaptation

Adapts responses based on cultural context and regional preferences for better understanding and engagement.

Advanced Features

๐ŸŽค Voice Input/Output

Speech-to-text and text-to-speech capabilities with multiple language support for voice interactions.

๐Ÿ˜Š Sentiment Analysis

Advanced sentiment and emotion detection with multi-language support to understand user feelings.

๐Ÿง  Conversation Memory

Persistent conversation context with learning capabilities for context-aware interactions.

๐Ÿ“„ Document Analysis

Support for PDF, Word, Excel, images with OCR and content extraction for document processing.

๐Ÿ‘ฅ Real-time Collaboration

Multi-user chat rooms with WebSocket support for collaborative conversations.

๐Ÿ“ˆ Advanced Analytics

Comprehensive analytics dashboard with visualizations and reports for conversation insights.

๐ŸŽญ Personality Customization

Multiple personality profiles (Professional, Friendly, Casual, Academic, Creative) for different use cases.

๐Ÿ–ผ๏ธ Multi-modal Input

Support for text, voice, images, video, and mixed input processing for versatile interactions.

๐Ÿ’พ Chat History

Save and export conversation history as JSON for record-keeping and analysis.

๐Ÿ“Š Session Analytics

Track conversation statistics, language usage, and performance metrics in real-time.

๐Ÿ”’ Security Features

Rate limiting, input validation, CORS configuration for secure and reliable operation.

โšก Real-time Responses

Fast AI responses with real-time processing for smooth multilingual conversations.

๐Ÿ› ๏ธ Technologies

Python

Core programming language for educational platform

Language

Flask

Python web framework for backend API

Framework

OpenAI API

AI model integration for intelligent conversations

AI API

langdetect

Automatic language detection library

NLP

googletrans

Translation services for multi-language support

Translation

python-dotenv

Environment variable management for configuration

Config

Speech Recognition

Voice input/output processing for multilingual interactions

Voice

Modular Architecture

Clean, modular code structure for easy extension

Architecture

๐Ÿ“ฆ Installation Guide - Step by Step

โฑ๏ธ Installation Time: ~5 minutes

Follow these simple steps to set up the Multi-language Chatbot on your system.

๐Ÿ“‹ Prerequisites

๐Ÿ Python 3.8+

Python 3.8 or higher required for the educational platform

Download: Python

๐ŸŒ Web Browser

Modern web browser (Chrome, Firefox, Safari, Edge) for accessing the educational platform

Recommended: Latest version of Chrome or Firefox

๐ŸŒ OpenAI API Key

Get your API key from OpenAI Platform (required for AI features)

Get Key: OpenAI Platform

๐ŸŒ Internet Connection

Required for Flask server and OpenAI API calls

๐Ÿš€ Step-by-Step Installation

๐Ÿ“Œ Step 1: Download or Clone the Project

Option A: Download ZIP

  1. Download the project ZIP file from the repository
  2. Extract it to your desired location (e.g., C:\Projects\multi-language-chatbot or ~/Projects/multi-language-chatbot)
  3. Navigate to the extracted folder

Option B: Clone with Git

git clone https://github.com/rskworld/multi-language-chatbot.git
cd multi-language-chatbot
โœ… Step 2: Install Python Dependencies

Install required Python packages using pip.

# Install dependencies
pip install -r requirements.txt
๐Ÿ”‘ Step 3: Set Up API Keys

Configure your OpenAI API key in the environment file.

  1. Copy .env.example to .env
  2. Edit .env and add your API key:
    • OPENAI_API_KEY=sk-your-openai-key-here
    • FLASK_ENV=development (optional)
    • PORT=5000 (optional, default is 5000)
  3. Get your OpenAI API key from OpenAI Platform
  4. Optionally get Google Translate API key for enhanced translations
  5. Make sure your API key has sufficient credits for testing
๐Ÿš€ Step 4: Start the Flask Server

Start the Flask backend server by running app.py.

# Start Flask server
python app.py

# The server will start on http://localhost:5000
๐ŸŒ Step 5: Open Frontend

Open the HTML file in your browser or use a local web server.

Method 1: Direct File Opening

  1. Open index.html in your browser

Method 2: Using Local Web Server (Recommended)

# In a new terminal, start HTTP server
python -m http.server 8000

# Then open: http://localhost:8000

โœ… Installation Complete!

Congratulations! You've successfully set up the Multi-language Chatbot. The chatbot is ready to use with all features including:

  • OpenAI API integration for intelligent conversations
  • Automatic language detection for 12+ languages
  • Real-time translation between languages
  • Cultural adaptation of responses
  • Voice input/output with multi-language support
  • Sentiment analysis and emotion detection
  • Conversation memory with persistent context
  • Document analysis with OCR support
  • Advanced analytics and reporting

Next Steps:

  1. Ensure the Flask server is running (Step 4)
  2. Open the frontend in your browser (Step 5)
  3. Start chatting in any supported language to test the chatbot
  4. Explore all the features, language options, and customization settings!

๐Ÿ”ง Troubleshooting Installation

โŒ API Key Issues

Solution: Ensure your .env file contains a valid OPENAI_API_KEY starting with sk-. Check API key has sufficient credits.

โŒ Flask Server Not Starting

Solution: Check Python version (3.8+), verify dependencies installed with pip install -r requirements.txt, ensure port 5000 is available.

โŒ Connection Errors

Solution: Verify Flask server is running on port 5000, check script.js has correct API_BASE_URL, ensure CORS is enabled in Flask.

โŒ Import Errors

Solution: Reinstall dependencies, check virtual environment is activated, verify all packages in requirements.txt are installed.

๐Ÿ“š Usage Guide - Step by Step

๐ŸŽฏ Getting Started with Multi-language Chatbot

Step-by-Step Usage Instructions

๐Ÿ“ Step 1: Start Backend Server

  1. Ensure Flask server is running: python run.py
  2. Check server status at http://localhost:5000
  3. You should see the Multi-language Chatbot interface

๐ŸŒ Step 2: Open Frontend

  1. Open http://localhost:5000 in your web browser
  2. You should see the Multi-language Chatbot interface with:
    • Chat messages area with markdown support
    • Text input field
    • Language selection dropdown
    • Quick action buttons for different languages
    • Features panel with chatbot capabilities
    • Statistics cards showing conversation stats
    • Send button

๐Ÿ’ฌ Step 3: Start Chatting

  1. Text Input: Type your message in any supported language and press Enter or click Send
  2. Language Detection: The chatbot will automatically detect your language
  3. Translation: Ask for translations between languages
  4. Try These:
    • "Hello! How are you?" (English)
    • "เคจเคฎเคธเฅเคคเฅ‡! เค†เคช เค•เฅˆเคธเฅ‡ เคนเฅˆเค‚?" (Hindi)
    • "Hola! ยฟCรณmo estรกs?" (Spanish)
    • "Translate: Hello world to Spanish"
    • "What languages do you support?"
  5. View Responses: The chatbot will respond in the same language with cultural adaptation

โš™๏ธ Step 4: Explore Features

Try out the chatbot features:

  • Language Selection: Manually select your preferred language
  • Language Detection: Test automatic language detection
  • Translation: Translate messages between languages
  • Cultural Adaptation: Notice how responses adapt to cultural context
  • Voice Input/Output: Use voice commands in multiple languages
  • Sentiment Analysis: Check sentiment detection in responses

๐Ÿ’ป Using the Multi-language Chatbot

You can interact with the Multi-language Chatbot through the web interface:

# Example Interactions User: "Hello! How are you?" (English) Bot: [Response in English with cultural adaptation] User: "เคจเคฎเคธเฅเคคเฅ‡! เค†เคช เค•เฅˆเคธเฅ‡ เคนเฅˆเค‚?" (Hindi) Bot: [Response in Hindi with cultural context] User: "Hola! ยฟCรณmo estรกs?" (Spanish) Bot: [Response in Spanish with cultural adaptation] User: "Translate: Hello world to Spanish" Bot: [Translation: "Hola mundo"] User: "What languages do you support?" Bot: [List of 12+ supported languages]
# Quick Action Buttons - English: Start conversation in English - Hindi: Start conversation in Hindi - Spanish: Start conversation in Spanish - French: Start conversation in French - Translate: Request translations - Languages: View supported languages

๐Ÿ“Š Features Usage

๐ŸŒ Multi-language

Chat in 12+ languages - the chatbot automatically detects your language and responds accordingly

๐Ÿ”„ Translation

Request translations between any supported languages with cultural context

๐ŸŽญ Cultural Adaptation

Responses are culturally adapted based on detected language and regional preferences

๐ŸŽค Voice I/O

Use voice input/output in multiple languages for hands-free multilingual conversations

๐Ÿ˜Š Sentiment Analysis

Automatic sentiment and emotion detection across all supported languages

๐Ÿง  Conversation Memory

Maintains context across conversations in any language for better understanding

๐Ÿ“„ Document Analysis

Upload documents in any language for analysis with OCR and content extraction

๐Ÿ“Š Analytics

Track conversation statistics, language usage, and performance metrics

๐Ÿš€ Advanced Features & Capabilities

The Multi-language Chatbot includes advanced NLP capabilities, translation services, and multilingual features. Here's what you can do:

๐ŸŒ Multi-language Intelligence

The chatbot excels at understanding and responding in 12+ languages with automatic detection, real-time translation, and cultural adaptation. Communicate naturally in any supported language.

๐Ÿ”„ Advanced Translation

Translate messages between any supported languages with cultural context awareness. The chatbot maintains meaning and cultural nuances during translation.

๐ŸŽญ Cultural Intelligence

Responses are culturally adapted based on detected language and regional preferences. The chatbot understands cultural context and adjusts responses accordingly.

๐Ÿ˜Š Sentiment & Emotion

Advanced sentiment analysis and emotion detection across all supported languages. Understand user feelings and respond appropriately in any language.

๐Ÿ’ป Code Examples

Basic Multi-language Chatbot Integration

// Python Flask backend - app.py from flask import Flask, request, jsonify from modules.language_detector import LanguageDetector from modules.translator import Translator from modules.chatbot_core import ChatbotCore app = Flask(__name__) language_detector = LanguageDetector() translator = Translator() chatbot_core = ChatbotCore() @app.route('/chat', methods=['POST']) def chat(): data = request.json message = data.get('message', '') # Detect language detected_lang = language_detector.detect(message) # Translate to English if needed if detected_lang != 'en': message_en = translator.translate(message, 'en', detected_lang) else: message_en = message # Generate response response_en = chatbot_core.generate_response(message_en) # Translate back to user language if detected_lang != 'en': response = translator.translate(response_en, detected_lang, 'en') else: response = response_en return jsonify({ 'response': response, 'detected_language': detected_lang, 'confidence': language_detector.get_confidence() }) if __name__ == '__main__': app.run(debug=True, port=5000)

JavaScript Frontend Integration

// Frontend JavaScript - chatbot.js async function sendMessage(message, userLanguage = null) { const response = await fetch('http://localhost:5000/chat', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ message: message, language: userLanguage // Optional: let chatbot detect automatically }) }); const data = await response.json(); return { response: data.response, detectedLanguage: data.detected_language, languageName: data.language_name, confidence: data.confidence }; } // Usage sendMessage('Hello! How are you?').then(result => { console.log('Chatbot:', result.response); console.log('Detected Language:', result.detectedLanguage); console.log('Confidence:', result.confidence); });

Complete Multi-language Chatbot Example

// Multi-language Chatbot Class class MultiLanguageChatbot { constructor(apiUrl) { this.apiUrl = apiUrl || 'http://localhost:5000/chat'; this.conversationHistory = []; this.currentLanguage = 'en'; } async sendMessage(message, userLanguage = null) { const response = await fetch(this.apiUrl, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ message: message, language: userLanguage }) }); const data = await response.json(); // Update conversation history this.conversationHistory.push( {role: 'user', content: message, language: data.detected_language}, {role: 'assistant', content: data.response, language: data.detected_language} ); // Update current language this.currentLanguage = data.detected_language; return { response: data.response, language: data.detected_language, confidence: data.confidence }; } async translate(text, targetLanguage) { const response = await fetch('http://localhost:5000/translate', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ text: text, target_language: targetLanguage }) }); return await response.json(); } clearHistory() { this.conversationHistory = []; } } // Usage const chatbot = new MultiLanguageChatbot(); chatbot.sendMessage('Hello! How are you?').then(result => { console.log('Chatbot:', result.response); console.log('Language:', result.language); });

Configuration Example

// Frontend config - chatbot.js const ChatbotConfig = { api: { baseUrl: 'http://localhost:5000', endpoints: { chat: '/chat', detectLanguage: '/detect_language', translate: '/translate', languages: '/languages' } }, languages: { supported: ['en', 'hi', 'bn', 'es', 'fr', 'de', 'zh', 'ja', 'ar', 'pt', 'ru', 'it'], default: 'en', autoDetect: true }, model: { default: 'gpt-3.5-turbo', maxTokens: 1024, temperature: 0.7 }, ui: { animationDuration: 300, messageDelay: 500 } }; // Access configuration console.log(ChatbotConfig.languages.supported);
# Backend config - config.py import os from dotenv import load_dotenv load_dotenv() class Config: OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') GOOGLE_TRANSLATE_API_KEY = os.getenv('GOOGLE_TRANSLATE_API_KEY') DEFAULT_MODEL = 'gpt-3.5-turbo' DEFAULT_MAX_TOKENS = 1024 DEFAULT_TEMPERATURE = 0.7 SUPPORTED_LANGUAGES = ['en', 'hi', 'bn', 'es', 'fr', 'de', 'zh', 'ja', 'ar', 'pt', 'ru', 'it'] DEFAULT_LANGUAGE = 'en' CULTURAL_ADAPTATION_ENABLED = True

๐Ÿ”— OpenAI API Integration

OpenAI API Integration

The application integrates with OpenAI's GPT API for advanced NLP and multilingual conversations. The backend uses Python Flask to handle API calls, language detection, translation, and cultural adaptation, while the frontend uses JavaScript for user interactions and response rendering.

Available APIs & Technologies

API/Technology Type Description
OpenAI GPT API AI API Advanced NLP and multilingual conversations
Google Translate API Translation API Real-time translation between languages
langdetect NLP Library Automatic language detection
Flask REST API Backend Python Flask server for API endpoints
LocalStorage Browser API Store settings and conversation history
Web Speech API Browser API Voice input/output with multi-language support

Backend API Endpoints

# Flask Backend - app.py @app.route('/chat', methods=['POST']) def chat(): data = request.json message = data.get('message', '') user_language = data.get('language') result = chatbot.process_message(message, user_language) return jsonify(result) @app.route('/detect_language', methods=['POST']) def detect_language(): data = request.json text = data.get('text', '') detected = chatbot.language_detector.detect(text) return jsonify({ 'language': detected, 'language_name': chatbot.supported_languages.get(detected, 'English'), 'confidence': chatbot.language_detector.get_confidence() }) @app.route('/translate', methods=['POST']) def translate(): data = request.json text = data.get('text', '') target_language = data.get('target_language', 'en') source_language = data.get('source_language') translated = chatbot.translator.translate(text, target_language, source_language) return jsonify({ 'translated_text': translated, 'source_language': source_language or 'auto', 'target_language': target_language }) @app.route('/languages', methods=['GET']) def languages(): return jsonify({ 'languages': chatbot.supported_languages }) @app.route('/health', methods=['GET']) def health(): return jsonify({ 'status': 'healthy', 'openai_configured': bool(os.getenv('OPENAI_API_KEY')) })
// Frontend JavaScript - API Integration async function sendMessage(message, userLanguage = null) { try { const response = await fetch('http://localhost:5000/chat', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ message: message, language: userLanguage // null for auto-detection }) }); if (!response.ok) { throw new Error('API request failed'); } const data = await response.json(); return { response: data.response, detectedLanguage: data.detected_language, languageName: data.language_name, confidence: data.confidence }; } catch (error) { console.error('Error:', error); return {error: error.message}; } } // Detect language async function detectLanguage(text) { const response = await fetch('http://localhost:5000/detect_language', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({text: text}) }); return await response.json(); } // Translate text async function translateText(text, targetLanguage) { const response = await fetch('http://localhost:5000/translate', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ text: text, target_language: targetLanguage }) }); return await response.json(); }

Browser Compatibility

// Check Chatbot API Connection async function checkHealth() { try { const response = await fetch('http://localhost:5000/health'); const data = await response.json(); console.log('Server Status:', data.status); console.log('OpenAI Configured:', data.openai_configured); return data.openai_configured; } catch (error) { console.error('Health check failed:', error); return false; } } // Get supported languages async function getSupportedLanguages() { const response = await fetch('http://localhost:5000/languages'); const data = await response.json(); return data.languages; } // Recommended setup: // - Backend: Python 3.8+ with Flask, langdetect, googletrans // - Frontend: Modern browsers (Chrome, Edge, Safari, Firefox) // - Voice Features: Chrome/Edge for Web Speech API support // - Translation: Google Translate API key (optional)

โš™๏ธ Configuration

Configuration in this application is handled through environment variables and settings files:

Environment Variables

Create a .env file in the project root (copy from .env.example):

# .env file OPENAI_API_KEY=sk-your-openai-api-key-here GOOGLE_TRANSLATE_API_KEY=your-google-translate-api-key-here FLASK_ENV=development SECRET_KEY=your-secret-key-here PORT=5000

Note: Get your API keys from OpenAI Platform and Google Cloud. Never commit your .env file to version control.

Python Configuration (config.py)

The config.py file contains configuration settings:

# config.py import os from dotenv import load_dotenv load_dotenv() class Config: OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') GOOGLE_TRANSLATE_API_KEY = os.getenv('GOOGLE_TRANSLATE_API_KEY') DEFAULT_MODEL = 'gpt-3.5-turbo' DEFAULT_MAX_TOKENS = 1024 DEFAULT_TEMPERATURE = 0.7 SUPPORTED_LANGUAGES = ['en', 'hi', 'bn', 'es', 'fr', 'de', 'zh', 'ja', 'ar', 'pt', 'ru', 'it'] DEFAULT_LANGUAGE = 'en' CULTURAL_ADAPTATION_ENABLED = True

Frontend Configuration

Edit chatbot.js to configure API endpoint:

// chatbot.js const API_BASE_URL = 'http://localhost:5000'; const DEFAULT_MODEL = 'gpt-3.5-turbo'; const DEFAULT_MAX_TOKENS = 1024; const DEFAULT_TEMPERATURE = 0.7; const SUPPORTED_LANGUAGES = ['en', 'hi', 'bn', 'es', 'fr', 'de', 'zh', 'ja', 'ar', 'pt', 'ru', 'it']; const DEFAULT_LANGUAGE = 'en'; const AUTO_DETECT_LANGUAGE = true;

Browser LocalStorage Settings

User settings are automatically saved to browser's local storage:

// Settings are saved automatically localStorage.setItem('chatbotSettings', JSON.stringify({ model: 'gpt-3.5-turbo', maxTokens: 1024, temperature: 0.7, language: 'en', autoDetectLanguage: true, culturalAdaptation: true, voiceEnabled: false })); // Load settings const settings = JSON.parse(localStorage.getItem('chatbotSettings'));

Runtime Configuration

Configure settings through the web interface:

  • Language: Select preferred language (12+ languages supported)
  • Auto-detect Language: Enable/disable automatic language detection
  • Cultural Adaptation: Enable/disable cultural adaptation of responses
  • Voice Input/Output: Enable/disable voice functionality
  • Translation: Request translations between languages
  • Sentiment Analysis: Enable/disable sentiment detection

All settings are saved automatically and persist across browser sessions.

๐Ÿ“ Project Structure

The Multi-language Chatbot follows a clean, organized structure for easy navigation and maintenance.

multi-language-chatbot/
โ”œโ”€โ”€ multi-language-chatbot/
โ”‚   โ”œโ”€โ”€ templates/
โ”‚   โ”‚   โ””โ”€โ”€ index.html      # Main HTML interface
โ”‚   โ”œโ”€โ”€ static/
โ”‚   โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ style.css   # Modern styling
โ”‚   โ”‚   โ””โ”€โ”€ js/
โ”‚   โ”‚       โ””โ”€โ”€ chatbot.js  # Frontend logic
โ”‚   โ”œโ”€โ”€ modules/
โ”‚   โ”‚   โ”œโ”€โ”€ language_detector.py  # Language detection
โ”‚   โ”‚   โ”œโ”€โ”€ translator.py         # Translation services
โ”‚   โ”‚   โ”œโ”€โ”€ cultural_adapter.py   # Cultural adaptation
โ”‚   โ”‚   โ”œโ”€โ”€ chatbot_core.py       # Chatbot logic
โ”‚   โ”‚   โ”œโ”€โ”€ voice_processor.py    # Voice I/O
โ”‚   โ”‚   โ”œโ”€โ”€ sentiment_analyzer.py # Sentiment analysis
โ”‚   โ”‚   โ””โ”€โ”€ ...                   # Other modules
โ”‚   โ”œโ”€โ”€ app.py              # Flask backend server
โ”‚   โ”œโ”€โ”€ config.py           # Configuration settings
โ”‚   โ”œโ”€โ”€ run.py              # Application runner
โ”‚   โ””โ”€โ”€ requirements.txt    # Python dependencies
โ”œโ”€โ”€ demo/
โ”‚   โ”œโ”€โ”€ index.html          # Documentation page
โ”‚   โ”œโ”€โ”€ demo.html           # Interactive demo
โ”‚   โ”œโ”€โ”€ style.css           # Demo styling
โ”‚   โ””โ”€โ”€ script.js           # Demo scripts
โ”œโ”€โ”€ .env                    # Environment variables
โ””โ”€โ”€ README.md               # Project documentation

๐Ÿ“„ Frontend Files

Location: multi-language-chatbot/templates/ and multi-language-chatbot/static/

  • templates/index.html - Main UI interface with chat
  • static/css/style.css - Modern gradient styling
  • static/js/chatbot.js - JavaScript functionality

๐Ÿ Backend Files

Location: multi-language-chatbot/

  • app.py - Flask server & API endpoints
  • config.py - Configuration settings
  • run.py - Application entry point
  • modules/language_detector.py - Language detection
  • modules/translator.py - Translation services
  • modules/cultural_adapter.py - Cultural adaptation
  • modules/chatbot_core.py - Chatbot logic

โš™๏ธ Configuration

Setup: Configure these files for your environment

  • .env - Environment variables (API keys)
  • requirements.txt - Python dependencies
  • config.py - Application configuration

๐Ÿ”ง Troubleshooting

API Key Issues

  • Ensure your .env file contains a valid OPENAI_API_KEY starting with sk-
  • Optionally add GOOGLE_TRANSLATE_API_KEY for enhanced translations
  • Check that the API key is correctly formatted and not expired
  • Verify your API key has sufficient credits in OpenAI Platform
  • Make sure the .env file is in the project root directory
  • Restart the Flask server after updating the API key

Flask Server Issues

  • Server not starting: Check Python version (3.8+), verify dependencies installed with pip install -r requirements.txt
  • Port 5000 in use: Change port in .env file or stop other applications using port 5000
  • Import errors: Ensure virtual environment is activated, reinstall dependencies
  • CORS errors: Verify Flask-CORS is installed and enabled in app.py
  • Connection refused: Check firewall settings, ensure server is running on correct port

Frontend Connection Issues

  • Failed to fetch: Ensure Flask server is running, check API_BASE_URL in chatbot.js
  • CORS errors: Make sure Flask-CORS is installed and configured in backend
  • Server offline indicator: Check server status at http://localhost:5000
  • Port mismatch: Verify frontend API_BASE_URL matches backend port
  • Language detection not working: Ensure langdetect is installed: pip install langdetect
  • Translation errors: Check Google Translate API key if using enhanced translations

Common Issues

  • API key not found: Create .env file from .env.example and add your API keys
  • Module not found: Install dependencies with pip install -r requirements.txt
  • Language detection errors: Ensure langdetect is installed: pip install langdetect
  • Translation errors: Check googletrans installation: pip install googletrans==4.0.0rc1
  • Response errors: Check API key validity, verify credits, check OpenAI API status
  • Cultural adaptation not working: Verify cultural_adapter module is properly configured
  • Voice features not working: Check browser compatibility (Chrome/Edge recommended)

๐Ÿ“‹ Requirements

Backend Requirements: - Python 3.8 or higher - Flask web framework - OpenAI Python SDK - Flask-CORS for CORS support - langdetect for language detection - googletrans for translation services Frontend Requirements: - Modern Web Browser (Chrome, Edge, Safari, Firefox) - JavaScript ES6+ support - LocalStorage API - Web Speech API (for voice features, optional) API Requirements: - OpenAI API Key (get from platform.openai.com) - Google Translate API Key (optional, for enhanced translations) - Active internet connection for API calls Python Dependencies (see requirements.txt): - openai - flask - flask-cors - python-dotenv - langdetect - googletrans Optional Dependencies: - Voice features require Web Speech API (Chrome/Edge recommended) - Google Translate API for enhanced translation quality

Browser Compatibility: Chrome, Edge, Safari, or Firefox (Chrome/Edge recommended for voice features).

Python Version: Python 3.8 or higher required for backend server.

Internet Connection: Required for OpenAI API calls and CDN resources.

๐ŸŽฏ Use Cases

๐ŸŒ Global Communication

Communicate with users worldwide in their native languages with automatic detection and translation

๐Ÿ”„ Translation Services

Real-time translation between 12+ languages with cultural context awareness

๐Ÿ’ผ Customer Support

Multilingual customer support chatbots for international businesses

๐Ÿ“ฑ Mobile Apps

Integrate multilingual chatbot capabilities into mobile applications

๐ŸŒ Website Integration

Add multilingual chat support to websites for global audiences

๐Ÿ“Š Analytics & Insights

Track conversation statistics, language usage, and user engagement across languages

๐ŸŽญ Cultural Adaptation

Provide culturally appropriate responses for different regions and languages

๐Ÿ‘ฅ Collaboration

Multi-user chat rooms with multilingual support for team collaboration

๐Ÿ’ฌ Support

For support, questions, or more projects:

๐Ÿ“„ License

This project is provided as-is for educational and development purposes.

MIT License - See LICENSE file for details.