A sophisticated Telegram bot for automated team task assignments with flexible participant management, multiple selection strategies, and seamless workflow integration.
- Multiple Selection Policies: Choose between Round-Robin (fair rotation) or Random assignment
- Flexible Team Size: Assign 1, 2, or 3 participants per task automatically
- Active Participant Selection: Easy checkbox interface to exclude unavailable team members
- State Persistence: Round-robin maintains position across sessions
- Admin Control: Role-based permissions for participant configuration
- Default Participants: Pre-configured team list for quick setup
- Dynamic Teams: Real-time participant availability management
- User ID Discovery: Built-in
/myidcommand for easy admin setup
- Channel Broadcasting: Automatic assignment posts to designated channels
- Interactive Polls: Built-in completion tracking with checkbox polls
- @Mention Notifications: Direct participant tagging for immediate alerts
- Custom Descriptions: Rich task descriptions with links and instructions
- Environment-based Setup: Secure configuration via environment variables
- Multiple Admin Support: Configure multiple administrators
- Flexible Channel Setup: Support for numeric IDs and usernames
- Graceful Error Handling: Robust error management and user feedback
- Python 3.13.6+
- Telegram Bot Token (from @BotFather)
- Target channel/chat for assignments
-
Clone the repository
git clone <repository-url> cd assign-bot
-
Install dependencies
pip install -r pyproject.toml # or using uv uv sync -
Configure environment
cp env.example .env # Edit .env with your configuration -
Run the bot
python main.py
Create a .env file with the following variables:
# Required: Your Telegram Bot Token
BOT_TOKEN=your_bot_token_here
# Required: Admin User IDs (comma or space separated)
ADMIN_USER_ID=123456789,987654321
# Required: Target channel for assignments
ASSIGN_CHANNEL_ID=@yourchannel
# Or use numeric ID: ASSIGN_CHANNEL_ID=-1001234567890- Start the bot and send
/myid - Copy your User ID to the
ADMIN_USER_IDenvironment variable
- For public channels: Use
@channelnameformat - For private channels: Use numeric ID (forward a message to @userinfobot)
- Ensure the bot is added to the channel with posting permissions
-
Start the bot
/start -
Configure your team (Admin only)
/configureOr use the "Configure Participants" button and enter usernames:
@alice @bob @charlie @david -
Create assignment
/assignOr use the "Assign Participants" button and follow the interactive flow:
- β Select active participants (checkbox interface)
- π Choose assignment policy (Round-Robin or Random)
- π’ Select number of assignees (1, 2, or 3)
- π Enter task description
- π― Assignment posted to configured channel with completion poll
| Command | Description | Access |
|---|---|---|
/start |
Show welcome message and main menu | Everyone |
/configure |
Set up team participants list | Admins only |
/assign |
Create new task assignment | Everyone |
/myid |
Display your User ID for admin setup | Everyone |
assign-bot/
βββ src/assign_bot/
β βββ bot.py # Main bot logic and handlers
β βββ selector.py # Selection strategies and policies
β βββ __init__.py # Module exports
βββ tests/ # Comprehensive test suite
βββ main.py # Application entry point
βββ pyproject.toml # Dependencies and metadata
βββ env.example # Configuration template
- Bot Module (
bot.py): Telegram bot handlers, user management, and workflow orchestration - Selector Module (
selector.py): Pluggable selection strategies with state management - Strategy Pattern: Clean separation between Random and Round-Robin selection logic
- State Management: In-memory state with planned persistent storage support
Run the comprehensive test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=src/assign_bot
# Run specific test categories
pytest tests/test_selector.py # Selector logic tests
pytest tests/test_bot_integration.py # Bot integration testsTest coverage includes:
- β Selection strategy algorithms
- β Bot workflow integration
- β Error handling scenarios
- β Real-world usage patterns
# Multiple ways to specify admin IDs
ADMIN_USER_ID=123456789,987654321,555666777
# or
ADMIN_USER_ID=123456789 987654321 555666777# Public channel with username
ASSIGN_CHANNEL_ID=@myteamchannel
# Private channel with numeric ID
ASSIGN_CHANNEL_ID=-1001234567890
# Channel username without @
ASSIGN_CHANNEL_ID=myteamchannel- Daily Standups: Rotate meeting facilitators fairly
- Code Reviews: Distribute review assignments across team
- Support Duty: Assign support rotations with vacation handling
- Task Distribution: Random or fair assignment of project tasks
- Event Organization: Assign event planning responsibilities
# Install development dependencies
uv sync --dev
# Run linting
ruff check src/ tests/
# Run type checking
mypy src/
# Run tests with watch mode
pytest-watch- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs or request features via GitHub Issues
- Documentation: Check the code comments and test files for detailed usage examples
- Community: Join discussions in the project's GitHub Discussions section