Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Chat2Task

Turn messy Telegram chats into reminders, summaries, and ready-to-send drafts.

Python 3.11+ FastAPI License: MIT


Chat2Task is a Telegram-first task copilot. Send it a messy message like "besok ingetin saya bayar listrik, rangkum meeting ini, terus bikin draft WA ke tim" and it parses it into structured actions β€” reminders, summaries, and drafts β€” then lets you approve and execute each one.

✨ Features

Feature Description
Multi-action parsing Extracts multiple actions from a single message
Approval-first workflow Nothing executes without your confirmation
Smart reminders One-time and recurring, with snooze and timezone support
Summaries Concise, structured text summaries on demand
Draft generation Ready-to-send messages for WhatsApp, email, etc.
πŸŽ™ Voice messages Send a voice note β€” it gets transcribed and parsed automatically
πŸ€– Multi-turn clarification Bot asks follow-up questions for ambiguous requests
πŸ“… Google Calendar sync Approved reminders auto-create Google Calendar events
πŸ““ Notion sync Approved tasks auto-create pages in your Notion database
πŸ‘₯ Group chat support Add bot to groups β€” responds only when @mentioned or replied to
πŸ“Š Web dashboard Dark-themed dashboard at /dashboard to view & filter tasks
Multilingual Works in English, Indonesian, and other languages
Daily digest Morning summary of your tasks and reminders
REST API Task inbox accessible via API alongside Telegram
Provider-agnostic LLM Works with any OpenAI-compatible API (NVIDIA NIM, OpenRouter, local models)
Persistent scheduling Reminders survive restarts

πŸ—‚ Architecture

app/
β”œβ”€β”€ main.py              # FastAPI entrypoint & lifespan
β”œβ”€β”€ config.py            # Pydantic settings from .env
β”œβ”€β”€ database.py          # SQLAlchemy engine & session
β”œβ”€β”€ models/              # DB models (User, Task, Reminder, ActionLog)
β”œβ”€β”€ schemas/             # Pydantic schemas (actions, tasks, users)
β”œβ”€β”€ llm/
β”‚   β”œβ”€β”€ provider.py      # Abstract LLM interface
β”‚   β”œβ”€β”€ openai_compat.py # OpenAI-compatible client (default)
β”‚   β”œβ”€β”€ parser.py        # Task extraction engine
β”‚   β”œβ”€β”€ summarizer.py    # Summary generation
β”‚   β”œβ”€β”€ drafter.py       # Draft generation
β”‚   └── prompts.py       # Prompt templates
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ task_service.py      # Task lifecycle management
β”‚   β”œβ”€β”€ reminder_service.py  # Reminder scheduling
β”‚   β”œβ”€β”€ user_service.py      # User CRUD & preferences
β”‚   β”œβ”€β”€ digest_service.py    # Daily digest builder
β”‚   β”œβ”€β”€ voice_service.py     # πŸŽ™ Voice transcription (Whisper API)
β”‚   β”œβ”€β”€ conversation.py      # πŸ€– Multi-turn state manager
β”‚   β”œβ”€β”€ gcal_service.py      # πŸ“… Google Calendar integration
β”‚   └── notion_service.py    # πŸ““ Notion integration
β”œβ”€β”€ scheduler/           # APScheduler engine & reminder jobs
β”œβ”€β”€ telegram/
β”‚   β”œβ”€β”€ bot.py           # Bot & Dispatcher factory
β”‚   β”œβ”€β”€ handlers/        # Command, message, voice, callback handlers
β”‚   β”œβ”€β”€ keyboards.py     # Inline keyboard builders
β”‚   └── formatting.py    # Message formatting helpers
β”œβ”€β”€ routers/             # FastAPI routes (webhook, tasks API, health)
β”‚   └── dashboard.py     # πŸ“Š Web dashboard routes
└── templates/           # Jinja2 HTML templates (dashboard UI)

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • A Telegram bot token (from @BotFather)
  • An OpenAI-compatible API key (OpenAI, NVIDIA NIM, OpenRouter, etc.)

1. Clone & Install

git clone https://github.com/your-username/chat2task.git
cd chat2task
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

2. Configure

cp .env.example .env
# Edit .env with your tokens:
#   TELEGRAM_BOT_TOKEN=your-bot-token
#   LLM_API_KEY=your-api-key
#   LLM_BASE_URL=https://integrate.api.nvidia.com/v1  (or any OpenAI-compatible endpoint)
#   LLM_MODEL=meta/llama-3.1-8b-instruct

3. Run

# Local development (long polling mode β€” no webhook needed)
make dev
# Or directly:
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

4. Use

Open your bot in Telegram and send a message:

Besok ingetin saya bayar listrik jam 10, rangkum meeting ini, terus bikin draft WA ke tim

The bot will respond with detected actions and approval buttons.

Docker

cp .env.example .env
# Edit .env
docker compose up --build

πŸ’¬ Example Conversations

Single Reminder

You: Remind me to call the dentist tomorrow at 3pm

Chat2Task: 🎯 Detected Actions

⏰ #1 β€” Call the dentist Type: reminder 🟒 πŸ“… 2025-01-15 15:00

[βœ… Approve] [❌ Cancel]

Multiple Actions

You: besok ingetin saya bayar listrik, rangkum meeting ini, terus bikin draft WA ke tim

Chat2Task: 🎯 Detected Actions

⏰ #1 β€” Bayar listrik Type: reminder 🟒 πŸ“… 2025-01-15

πŸ“ #2 β€” Rangkum meeting Type: summary 🟑

βœ‰οΈ #3 β€” Draft WA ke tim Type: draft 🟑 πŸ“¨ To: Tim (WhatsApp)

[βœ… Approve All] [βœ… #1] [❌ #1] [βœ… #2] [❌ #2] [βœ… #3] [❌ #3] [πŸ—‘ Ignore All]

Reminder Fires

Chat2Task: ⏰ Reminder

πŸ“Œ Bayar listrik

What would you like to do?

[βœ… Done] [⏰ 10m] [⏰ 1h] [πŸ“… Tomorrow]

πŸ”§ Configuration

Variable Default Description
TELEGRAM_BOT_TOKEN β€” Your Telegram bot token (required)
WEBHOOK_URL β€” Webhook URL (leave empty for polling mode)
WEBHOOK_SECRET change-me Secret for webhook verification
LLM_BASE_URL https://integrate.api.nvidia.com/v1 OpenAI-compatible API base URL
LLM_API_KEY β€” API key for the LLM provider
LLM_MODEL meta/llama-3.1-8b-instruct Model identifier
LLM_TIMEOUT 30 Request timeout in seconds
LLM_TEMPERATURE 0.1 LLM temperature for parsing
DATABASE_URL sqlite:///./chat2task.db Database connection string
DEFAULT_TIMEZONE Asia/Jakarta Fallback timezone
DEFAULT_REMINDER_HOUR 9 Default hour for reminders without time
STT_BASE_URL β€” Whisper-compatible STT endpoint (blank = use LLM_BASE_URL)
STT_API_KEY β€” STT API key (blank = use LLM_API_KEY)
STT_MODEL whisper-1 STT model name
GOOGLE_CALENDAR_ENABLED false Enable Google Calendar sync
GOOGLE_CREDENTIALS_FILE credentials.json Path to Google OAuth credentials
GOOGLE_TOKEN_FILE token.json Path to cached Google auth token
NOTION_ENABLED false Enable Notion sync
NOTION_API_KEY β€” Notion integration API key
NOTION_DATABASE_ID β€” Target Notion database ID

πŸ“‘ REST API

The app exposes a lightweight REST API alongside the Telegram interface:

  • GET /health β€” Health check
  • GET /api/tasks/?telegram_id=123 β€” List user tasks
  • GET /api/tasks/{id} β€” Get task details
  • PATCH /api/tasks/{id} β€” Update task
  • POST /api/tasks/{id}/approve β€” Approve task
  • POST /api/tasks/{id}/cancel β€” Cancel task
  • GET /docs β€” Interactive API docs (Swagger UI)
  • GET /dashboard β€” Web dashboard (task overview & stats)
  • GET /dashboard/tasks β€” Task list with status filter

πŸ§ͺ Testing

make test
# Or:
pytest tests/ -v

πŸ›  Extending

Add a new LLM provider

  1. Implement app/llm/provider.py::LLMProvider interface
  2. Create your provider class (e.g., app/llm/anthropic.py)
  3. Update the provider instantiation in message handlers

Switch to PostgreSQL

  1. Install psycopg2-binary
  2. Update DATABASE_URL in .env:
    DATABASE_URL=postgresql+psycopg2://user:pass@localhost:5432/chat2task
    
  3. Uncomment the PostgreSQL service in docker-compose.yml

Add new action types

  1. Add the type to ActionType enum in app/schemas/action.py
  2. Update the LLM prompt in app/llm/prompts.py
  3. Add execution logic in app/telegram/handlers/callback.py::_execute_task

πŸ—Ί Roadmap

  • Multi-turn clarification & settings state machine
  • Google Calendar sync
  • Notion integration
  • Voice message transcription β†’ action extraction
  • Group chat support with @mention parsing
  • Web dashboard for task management
  • Alembic migrations for production schema management
  • Todoist / CalDAV integration
  • Rate limiting and usage quotas
  • Multi-model fallback chain
  • Docker production-ready image
  • Webhook mode with HTTPS reverse proxy guide

πŸ“„ License

MIT β€” see LICENSE.


Built with ❀️ for people who think faster than they can organize.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages