{"id":42651312,"url":"https://github.com/soos3d/ai-tg-translator-bot","last_synced_at":"2026-01-29T07:33:29.136Z","repository":{"id":298384480,"uuid":"999807382","full_name":"soos3d/ai-tg-translator-bot","owner":"soos3d","description":"LLM-powered Telegram bot for automatic message translation in multilingual group chats","archived":false,"fork":false,"pushed_at":"2025-06-20T16:05:03.000Z","size":60,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-20T16:51:23.586Z","etag":null,"topics":["bot","groq-api","llm","telegram","telegram-bot","translation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soos3d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-10T20:19:41.000Z","updated_at":"2025-06-13T14:06:32.000Z","dependencies_parsed_at":"2025-06-10T21:36:44.222Z","dependency_job_id":"078abc13-aece-4d2d-88f2-c8d6567b1feb","html_url":"https://github.com/soos3d/ai-tg-translator-bot","commit_stats":null,"previous_names":["soos3d/ai-tg-translator-bot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/soos3d/ai-tg-translator-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soos3d%2Fai-tg-translator-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soos3d%2Fai-tg-translator-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soos3d%2Fai-tg-translator-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soos3d%2Fai-tg-translator-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soos3d","download_url":"https://codeload.github.com/soos3d/ai-tg-translator-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soos3d%2Fai-tg-translator-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28870417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T06:56:44.678Z","status":"ssl_error","status_checked_at":"2026-01-29T06:56:35.794Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","groq-api","llm","telegram","telegram-bot","translation"],"created_at":"2026-01-29T07:33:28.634Z","updated_at":"2026-01-29T07:33:29.116Z","avatar_url":"https://github.com/soos3d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI Translator Telegram Bot\n\nAn AI-powered bot that enables real-time multilingual communication in Telegram groups. It automatically detects and translates non-English messages into English, then translates English replies back into the original sender’s language—allowing fluid, two-way conversations across languages.\n\n## Features\n\n- 🌐 Automatic language detection\n- 🔄 Bidirectional translation (any language ↔️ English)\n- 📝 Preserves message context and threading\n- 💾 Message caching for improved performance\n- 🗄️ Dual database storage (local SQLite + MongoDB)\n- 📊 Analytics-ready data collection\n- 🛠️ Highly configurable\n\n## Prerequisites\n\n- Python 3.x\n- A Telegram Bot Token (get it from [@BotFather](https://t.me/botfather))\n- A Groq API Key (get it from [Groq Console](https://console.groq.com/docs/quickstart))\n- MongoDB URI (optional, for cloud storage)\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/soos3d/ai-tg-translator-bot.git\n```\n\n2. Create and activate a virtual environment:\n```bash\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .\\venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n4. Set up environment variables:\n```bash\ncp .env.example .env\n# Edit .env with your configuration\n```\n\n## Configuration\n\nThe bot is configured through environment variables in the `.env` file:\n\n### Required Settings\n- `TELEGRAM_BOT_TOKEN`: Your Telegram bot token\n- `GROQ_API_KEY`: Your Groq API key\n\n### Optional Settings\n- `TRANSLATION_LLM`: LLM model for translations (default: llama-3.3-70b-versatile)\n- `DEBUG_MODE`: Enable debug logging (default: False)\n- `CACHE_MAX_SIZE`: Maximum number of cached messages (default: 100)\n- `CACHE_EXPIRATION_SECONDS`: Cache entry lifetime in seconds (default: 1800)\n- `DB_CLEANUP_DAYS`: Days to keep translations in local database (default: 7)\n- `LANG_CONFIDENCE_THRESHOLD`: Minimum confidence for language detection (default: 0.75)\n\n### MongoDB Settings (Optional)\n\nYou can store the messages in MongoDB for analytics and reporting.\n\n- `MONGODB_URI`: MongoDB connection string\n- `MONGODB_DB_NAME`: Database name (default: tg_translator)\n- `MONGODB_COLLECTION_NAME`: Collection name (default: messages)\n\n## Usage\n\n### Bot\n\n1. Start the bot:\n```bash\npython3 bot.py\n```\n\n2. Add the bot to your Telegram group\n\u003e Important: The bot must be added to the group as an admin.\n\n### Analytics Dashboard\n\nIf you're using MongoDB for data storage, you can access the analytics dashboard:\n\n1. Set up your Streamlit secrets:\n```bash\ncp .streamlit/secrets.toml.template .streamlit/secrets.toml\n# Edit secrets.toml with your MongoDB credentials\n```\n\n2. Run the dashboard:\n```bash\npython3 -m streamlit run streamlit-ui/analytics_dashboard.py\n```\n\n3. The bot will automatically:\n   - Detect non-English messages\n   - Translate them to English\n   - Translate replies back to the original language (Must reply to the translated message) \n\n## How It Works\n\n1. **Message Detection**:\n   - Bot monitors group messages\n   - Uses language detection to identify non-English messages\n   - Only processes messages with high confidence (\u003e75% by default)\n\n2. **Translation Flow**:\n   - User sends message in their language\n   - Bot detects language and confidence level\n   - If non-English, translates to English\n   - Creates a threaded reply with:\n     - User information\n     - Original message\n     - Detected language\n     - English translation\n\n3. **Agent Response**:\n   - Support agent replies to the translated message\n   - Bot automatically translates the reply to user's language\n   - Sends translated response as a reply to original message\n\n4. **Data Management**:\n    - Translations are cached in memory for performance\n    - Translation mappings stored in local SQLite database\n    - User data and English messages stored in MongoDB (if configured)\n      - Includes user profiles, message metadata\n      - Stores both original and translated content\n      - Enables advanced analytics and reporting\n   - Automatic cleanup of old entries\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Deployment\n\nThe bot can be deployed on any system with Python 3.x installed. For production environments, consider:\n\n### Production Considerations\n\n1. **Database Management**:\n   - Local SQLite database for translation mappings\n   - MongoDB for analytics and data persistence\n   - For higher loads, consider optimizing database cleanup schedules\n\n2. **System Requirements**:\n   - Stable internet connection\n   - Sufficient memory for caching (adjust `CACHE_MAX_SIZE` as needed)\n   - Adequate storage for local database\n\n2. **Environment Variables**:\n   - Never commit `.env` to version control\n   - Use platform-specific secrets management\n\n3. **Monitoring**:\n   - Set up logging to a service like Papertrail\n   - Configure uptime monitoring\n\n4. **Backup**:\n   - Regularly backup the `data` directory\n   - Consider automated backup solutions\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoos3d%2Fai-tg-translator-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoos3d%2Fai-tg-translator-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoos3d%2Fai-tg-translator-bot/lists"}