Integration layer that enables Sensay Replicas to interact with users through Telegram, with built-in scalability and management features.
This project provides a complete solution for running and managing multiple Telegram bots in a scalable way. It consists of two main packages:
-
Bot (
@sensay/telegram-bot
): The core Telegram bot implementation based on the Grammy library, responsible for handling bot interactions. -
Orchestrator (
@sensay/telegram-orchestrator
): A service that manages multiple bot instances, ensuring they're running correctly, handling health checks, and providing a management API.
- Scalable Architecture: Run multiple bot instances in isolated processes
- Health Monitoring: Automatic health checks and recovery of failed bot instances
- Management API: HTTP API for adding, updating, and removing bots
- Process Isolation: Each bot runs in its own process for improved stability
- Graceful Handling: Proper startup, shutdown, and error handling
/packages
/bot - Core Telegram bot implementation
/orchestrator - Bot orchestration and management service
- Node.js (v22.13.11 recommended)
- npm
- TypeScript
# Install dependencies for all packages
npm install
# Run the bot in development mode
npm run dev:bot
# Run the orchestrator in development mode
npm run dev:orc
# Build all packages
npm run build
# Run tests for all packages
npm run test
# Lint code
npm run lint
# Automatically fix linting issues
npm run lint:write
# Check code formatting and types
npm run check
# Automatically fix formatting issues
npm run check:write
The shared package contains shared utilities and types used across the project. It includes the Telegram API client, logging utilities, and common types.
The bot package provides the core functionality for Telegram bot interactions. It handles messages, commands, and other Telegram events.
For detailed information, see the Bot README.
The orchestrator manages multiple bot instances, ensuring they're running correctly, and provides a management API for adding, updating, and removing bots.
Key features:
- Bot process management in cluster mode
- Health monitoring and automatic restart
- API for bot management
- Graceful handling of bot processes
For detailed information, see the Orchestrator README.
Copy the example environment files to set up your configuration:
cp packages/bot/.env.example packages/bot/.env.local
cp packages/orchestrator/.env.example packages/orchestrator/.env.local
This project is available under the Apache 2.0 License. See LICENSE for the full license text.