A lightweight task manager inside a Telegram bot designed for fast and simple task tracking without the overhead of complicated management tools.
The bot allows you to quickly record, view, close, and review tasks directly from Telegram making it perfect for users who just want to keep notes without switching apps.
-
Instant task creation: Simply send a message and the bot automatically treats it as a task and asks for its urgency level.
-
Urgency levels: Task urgency is defined in the
URGENCY_LABELSlist. The higher the index, the longer the time horizon:0 < 1 < 2 = today < week < month -
Task listing & ordering: Use the
/taskscommand to view your active tasks. Each task is displayed as a separate message showing:- Task text
- Urgency level
- Creation date & time
-
Custom sorting: By default, the most urgent tasks appear at the top (today -> week -> month). You can reverse this order by setting:
TASKS_REVERSE = True
-
Close (complete) tasks: Pressing the Delete❌ button on a task does not permanently erase it — the bot marks it as closed (
done = true) and records thedone_attimestamp. Closed tasks are excluded from/tasksbut remain in history. -
Full task history: Use
/historyto retrieve the full task history (open and closed tasks) including creation times, urgency and close timestamps. -
Per-user storage: Tasks are stored per Telegram user. The bot upserts basic user info (id, username, fullname) on first interaction.
- Framework: Aiogram 3
- Database: PostgreSQL
- Containerization: Docker & Docker Compose
- Clone the repository:
git clone https://github.com/samanwirst/taskmanager_tgbot
cd taskmanager_tgbot- Create a
.envfile in the root directory and set your environment variables:
BOT_TOKEN="YOUR_TELEGRAM_BOT_TOKEN" DATABASE_URL="YOUR_DATABASE_URL"
The running code expects both
BOT_TOKENandDATABASE_URLto be present — the config validates and raises an error if either is missing.
Run with Docker Compose (recommended):
docker-compose up --build -d
Or run locally:
- Create a virtual environment and install dependencies (project provides requirements):
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Start the bot:
python app/main.py
- Send any text message and the bot saves it as a task.
- Select its urgency level.
- Retrieve active tasks anytime using
/tasks. - Close a task using the Delete❌ button.
- Use
/historyto inspect all tasks (open and closed) and their timestamps.
| Variable | Description | Example |
|---|---|---|
URGENCY_LABELS |
List of urgency categories | ["Today", "This Week", "This Month"] |
TASKS_REVERSE |
Reverse the order of task display | True or False |
BOT_TOKEN |
Telegram bot token (required) | 123456:ABC... |
DATABASE_URL |
PostgreSQL DSN (required) | postgresql://user:pass@host:5432/db |
Notes:
- The database schema is created/updated on startup. The
taskstable includesdone(boolean) anddone_at(timestamp with timezone) columns. Deleting a task in the UI simply marks it done. - The code uses a small
asyncpgpool (min_size=1, max_size=5) for efficient async DB access. INFO_MESSAGEandINFO_BUTTONScontain bot information and external links; invalid entries are ignored safely.
BOT_TOKEN=1234567890:ABCDEFG_your_token_here DATABASE_URL=postgresql://user:password@db:5432/tasks_db
Mukhammadiev Samandar