Status Python FastAPI OpenAI Telegram

๐Ÿ—“๏ธ PlanAI

Your AI-Powered Group Calendar Assistant
The intelligent command center that unifies your chaotic communication channels into one seamless schedule.


๐ŸŽฏ The Problem We Solve

Students today are drowning in information scattered across multiple platforms:

Channel Problem
๐Ÿ“ง Official Emails (coming soon) Important deadlines buried in long chains
๐Ÿ’ฌ Telegram Groups Event details lost in 500+ unread messages
๐Ÿ“… Calendar Apps (coming soon) Empty because manual entry is tedious
๐Ÿง  Human Memory Unreliable for tracking multiple commitments

The Market Gap

Traditional calendar apps are passive storage binsโ€”they only work if you manually enter every event. But students receive scheduling information through conversations, not forms.

PlanAI bridges this gap by acting as an active AI agent that:

  • ๐Ÿ‘‚ Listens to your group chats for event mentions
  • ๐Ÿง  Understands natural language ("let's meet tomorrow at 2pm")
  • ๐Ÿ” Researches the web for deadlines you might miss
  • โš ๏ธ Warns you about schedule conflicts in real-time
  • ๐Ÿ“ฒ Proactively reminds you of tomorrow's events every night

โœจ Key Features

1. ๐Ÿ‘‚ Passive Group Chat Listener

Never miss an event mentioned in your group chats again

Add PlanAI to any Telegram group, and it will automatically:

  • Detect event-related messages using AI
  • Extract event details (time, location, title)
  • Check for schedule conflicts
  • Send you a private notification (no group spam!)
๐Ÿ‘ฅ Group Chat:
"Let's meet tomorrow at 2pm at COM1"

๐Ÿค– PlanAI (privately to you):
โœ… Event Added!
๐Ÿ“Œ Meeting
๐Ÿ• Jan 18, 2:00 PM
๐Ÿ“ COM1

2. ๐Ÿ“… /agenda - Daily Dashboard

See your entire day at a glance

Command: /agenda or "what is my plan today?"

๐Ÿ“… Your Agenda for Saturday, January 18, 2026

09:00 - CS2103T Lecture
๐Ÿ“ I3 Auditorium

14:00 - Team Meeting
๐Ÿ“ COM1-0210

16:00 - Gym Session

18:00 - Dinner with Friends
๐Ÿ“ UTown
โš ๏ธ CONFLICT

Design Principles:

  • โœ… Celebratory empty state ("No events! Enjoy your free time!")
  • โœ… Visual timeline with bold times
  • โœ… Location shown only when available
  • โœ… Clear conflict warnings

3. ๐Ÿ•ต๏ธ /track - Active Research Mode

Let AI find deadlines for you

Don't know the important dates? PlanAI searches the web and extracts deadlines automatically.

Command: /track [topic]

/track CS2103 deadlines
๐Ÿ” Research Complete: CS2103 deadlines

๐Ÿ“‹ Found 5 events:

1. CS2103 PE-D
   ๐Ÿ“… Mar 21, 2026, 4:00 PM

2. CS2103 Final Exam
   ๐Ÿ“… Apr 26, 2026, 9:00 AM

3. Team Project Submission
   ๐Ÿ“… Apr 15, 2026, 11:59 PM

...

โœ… Added to your calendar!
๐ŸŒ Source: Web Research

4. ๐Ÿง  Statefulness - Smart Update Detection

Context-aware conversations

PlanAI remembers the last event discussed in each group and intelligently handles updates:

๐Ÿ‘ค "Meeting tomorrow at 2pm at COM1"
๐Ÿค– โœ… Event saved!

๐Ÿ‘ค "Actually, change it to 3pm"
๐Ÿค– โœ… Event Updated!
   โฐ Time: Jan 18, 2PM โ†’ Jan 18, 3PM

Not confused by new events:

๐Ÿ‘ค "Dinner at 7pm tomorrow"
๐Ÿค– โœ… New event saved! (not an update)

5. ๐ŸŒ™ Nightly Briefing

Proactive reminders at 9 PM

Every night at 9 PM (Singapore time), PlanAI sends you tomorrow's schedule:

๐ŸŒ™ Tomorrow's Schedule
๐Ÿ“… Sunday, January 19, 2026

You have 3 events tomorrow:

09:00 - CS2103T Lecture
   ๐Ÿ“ I3 Auditorium

14:00 - Team Meeting
   ๐Ÿ“ COM1-0210

18:00 - Dinner with Friends
   ๐Ÿ“ UTown

๐Ÿ’ช Busy day ahead! You've got this!

Demo Command: /force_briefing - Test the nightly briefing instantly

6. โš ๏ธ Real-Time Conflict Detection

Never double-book yourself again

When adding any event, PlanAI automatically checks for overlapping schedules:

โš ๏ธ CONFLICT DETECTED

Your new event overlaps with:
1. CS2103T Lecture (Jan 18, 2:00 PM)

๐Ÿ’ก Please choose a different time.

7. ๐Ÿ”— Web Enrichment

Automatic context for your events

When you add an event, PlanAI searches the web for relevant information:

โœ… Event Added!
๐Ÿ“Œ CS2103T Lecture
๐Ÿ• Jan 24, 2:00 PM
๐Ÿ“ I3 Auditorium

๐Ÿ”— More Information
โ†’ https://nus-cs2103.github.io/website/

8. ๐Ÿ—‘๏ธ /clearall - Clear Your Day & Rest!

When you need a break from productivity

Sometimes you just need to clear your schedule and take a day off. PlanAI understands!

Command: /clearall

๐Ÿ—‘๏ธ Cleared 4 events...

๐Ÿ’ฅ KABOOM! Your to-do list has exploded into confetti!

๐ŸŽŠ Congratulations! You've unlocked: FREE TIME! ๐ŸŽŠ

Quick, do nothing before responsibilities find you! ๐Ÿƒโ€โ™‚๏ธ

Remember: You can't be late if you have nowhere to be *taps head*

Features:

  • โœ… Clears all events for today
  • โœ… Random goofy messages encouraging you to rest
  • โœ… Smart empty state detection ("Your schedule was already empty. You absolute legend. ๐Ÿ‘‘")

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         TELEGRAM                                โ”‚
โ”‚                    (Groups + Private DMs)                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      FastAPI Webhook                            โ”‚
โ”‚                    (app/api/webhook.py)                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Message Router                             โ”‚
โ”‚                   (app/bot/router.py)                           โ”‚
โ”‚                                                                 โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚   โ”‚  Private Chat   โ”‚              โ”‚     Group Chat          โ”‚  โ”‚
โ”‚   โ”‚  (Master Hub)   โ”‚              โ”‚     (Listener)          โ”‚  โ”‚
โ”‚   โ”‚                 โ”‚              โ”‚                         โ”‚  โ”‚
โ”‚   โ”‚ โ€ข /agenda       โ”‚              โ”‚ โ€ข Event Detection       โ”‚  โ”‚
โ”‚   โ”‚ โ€ข /track        โ”‚              โ”‚ โ€ข Update Detection      โ”‚  โ”‚
โ”‚   โ”‚ โ€ข /clearall     โ”‚              โ”‚ โ€ข Conflict Checking     โ”‚  โ”‚
โ”‚   โ”‚ โ€ข /force_brief  โ”‚              โ”‚                         โ”‚  โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚                                   โ”‚
             โ–ผ                                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      AI Layer (OpenAI GPT-4o)                   โ”‚
โ”‚                      (app/core/llm.py)                          โ”‚
โ”‚                                                                 โ”‚
โ”‚   โ€ข extract_event_from_text() - Natural language โ†’ Event       โ”‚
โ”‚   โ€ข detect_update_intent() - Is this an update?                 โ”‚
โ”‚   โ€ข check_event_intent() - Fast keyword filter                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Research Agent (Tavily)                    โ”‚
โ”‚                    (app/core/agent.py)                          โ”‚
โ”‚                                                                 โ”‚
โ”‚   โ€ข scavenge_events() - Web search โ†’ Events                     โ”‚
โ”‚   โ€ข enrich_event() - Add web context                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Supabase (PostgreSQL)                      โ”‚
โ”‚                   (app/services/crud.py)                        โ”‚
โ”‚                                                                 โ”‚
โ”‚   โ€ข save_event_to_db() - With conflict detection                โ”‚
โ”‚   โ€ข get_events_by_date() - For /agenda & briefings              โ”‚
โ”‚   โ€ข update_event() - For statefulness updates                   โ”‚
โ”‚   โ€ข delete_events_by_date() - For /clearall command             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10+
  • Telegram Bot Token (from @BotFather)
  • OpenAI API Key
  • Supabase Project (free tier works!)
  • Tavily API Key (for web search)

Installation

# Clone the repository
git clone https://github.com/dannylhk/PlanAI.git
cd PlanAI

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Configuration

Create a .env file in the project root:

TELEGRAM_BOT_TOKEN=your_telegram_bot_token
OPENAI_API_KEY=your_openai_api_key
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_anon_key
TAVILY_API_KEY=your_tavily_api_key

Database Setup

Create an events table in Supabase:

CREATE TABLE events (
    id SERIAL PRIMARY KEY,
    title TEXT NOT NULL,
    start_time TIMESTAMP NOT NULL,
    end_time TIMESTAMP,
    location TEXT,
    description TEXT,
    source TEXT DEFAULT 'telegram',
    context_notes TEXT,
    web_enrichment TEXT,
    user_id BIGINT,
    created_at TIMESTAMP DEFAULT NOW()
);

Running the Server

# Development mode with auto-reload
uvicorn main:app --reload --port 8000

# Production mode
uvicorn main:app --host 0.0.0.0 --port 8000

Setting Up Telegram Webhook

curl -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/setWebhook?url=https://<YOUR_DOMAIN>/api/telegram"

๐Ÿงช Test Cases - Try These in Your Telegram!

Test 1: Basic Event Creation

In a group chat with the bot:

Let's meet tomorrow at 2pm at COM1

Expected: Private notification with event details

Test 2: Event Update (Statefulness)

After Test 1, in the same group:

Actually, change it to 3pm

Expected: Update confirmation showing time change

Test 3: New Event Detection

After Test 2, in the same group:

Dinner at 7pm at UTown

Expected: New event created (not treated as update)

Test 4: Conflict Detection

In a group chat:

Meeting at 3pm tomorrow at NUS

If you already have an event at 3pm: Expected: Conflict warning with existing event details

Test 5: Daily Agenda

In private chat with bot:

/agenda

Expected: Beautiful timeline of today's events

Test 6: Natural Language Agenda

In private chat with bot:

what is my plan today?

Expected: Same agenda output as /agenda

Test 7: Active Research

In private chat with bot:

/track NUS academic calendar 2026

Expected: List of academic deadlines added to your calendar

Test 8: Force Nightly Briefing

In private chat with bot:

/force_briefing

Expected: Tomorrow's schedule preview

Test 9: Empty State

In private chat (with no events today):

/agenda

Expected: ๐ŸŽ‰ No events scheduled for today. Enjoy your free time!

Test 10: Location Enrichment

In a group chat:

CS2103T lecture tomorrow at 2pm at I3

Expected: Event card with web enrichment link to course website

Test 11: Clear All Events

In private chat with bot:

/clearall

Expected: All today's events cleared + goofy rest message encouraging you to relax

Test 12: Clear All (Empty State)

In private chat (with no events today):

/clearall

Expected: Message saying "Your schedule was already empty. You absolute legend. ๐Ÿ‘‘"


๐Ÿ“ Project Structure

PlanAI/
โ”œโ”€โ”€ main.py                 # FastAPI entry + APScheduler (9 PM briefing)
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ .env                    # Environment variables (not in git)
โ”‚
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ””โ”€โ”€ webhook.py      # Telegram webhook endpoint
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ bot/
โ”‚   โ”‚   โ”œโ”€โ”€ router.py       # Message routing brain
โ”‚   โ”‚   โ”œโ”€โ”€ responses.py    # Telegram message formatting
โ”‚   โ”‚   โ”œโ”€โ”€ briefing.py     # Nightly briefing logic
โ”‚   โ”‚   โ”œโ”€โ”€ date_utils.py   # Date formatting utilities
โ”‚   โ”‚   โ””โ”€โ”€ utils.py        # Helper functions
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ llm.py          # OpenAI GPT-4o integration
โ”‚   โ”‚   โ”œโ”€โ”€ agent.py        # Web search agent (Tavily)
โ”‚   โ”‚   โ””โ”€โ”€ prompts.py      # LLM system prompts
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ schemas/
โ”‚   โ”‚   โ””โ”€โ”€ event.py        # Pydantic Event model
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ crud.py         # Database operations
โ”‚       โ””โ”€โ”€ db.py           # Supabase client
โ”‚
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ test_agenda.py      # /agenda feature tests
    โ”œโ”€โ”€ test_briefing.py    # Nightly briefing tests
    โ”œโ”€โ”€ test_track.py       # /track command tests
    โ”œโ”€โ”€ test_statefulness.py # Update detection tests
    โ””โ”€โ”€ test_conflict_fix.py # Conflict detection tests

๐Ÿ› ๏ธ Technologies

Technology Purpose
FastAPI High-performance async web framework
Telegram Bot API User interface via httpx
OpenAI GPT-4o Natural language understanding
Tavily Web search for deadline research
Supabase PostgreSQL database with real-time
APScheduler Cron jobs for nightly briefings
Pydantic Data validation & schemas
pytz Singapore timezone handling

๐ŸŽฏ What Makes PlanAI Different?

Feature Traditional Calendars PlanAI
Event Entry Manual typing Automatic from chat
Conflict Check After booking Real-time prevention
Deadline Discovery You search AI searches for you
Daily Reminder Generic notification Personalized briefing
Group Events Everyone enters separately One person mentions, all synced
Context Awareness None Remembers last event
Web Integration None Auto-enriches with links

๐Ÿ”ฎ Future Roadmap

  • [ ] ๐Ÿ“ง Email parsing for official university announcements
  • [ ] ๐Ÿ”„ Two-way sync with Google Calendar
  • [ ] ๐Ÿ‘ฅ Shared group calendars
  • [ ] ๐Ÿ”” Custom reminder times
  • [ ] ๐Ÿ“Š Analytics dashboard
  • [ ] ๐ŸŒ Multi-timezone support

๐Ÿ‘ฅ Contributors

Role Responsibility
Member A LLM Integration, Web Research Agent, Database Layer
Member B Bot UX, Message Routing, Telegram Integration

๐Ÿ“„ License

MIT License - feel free to use and modify!


Built with โค๏ธ at Hack&Roll 2026
Because your schedule shouldn't be another thing to worry about.

Built With

Share this project:

Updates