An intelligent Telegram bot that manages your Google Calendar using natural language and AI-powered memory.
- Learns your preferences: "I prefer morning meetings" → Remembers for future scheduling
- Stores contact info: "John works at Google" → Recalls when scheduling with John
- Remembers patterns: "My lunch is always 12-1pm" → Avoids scheduling conflicts
- Context awareness: References past conversations and stored information
- Create events: "schedule meeting at 3pm tomorrow"
- Find free time: "when am I free for 2 hours this week?"
- Check availability: "am I free at 2pm tomorrow?"
- Analyze schedule: "plan my day" or "what's my schedule today?"
- Delete events: "delete everything with Jane"
- Smart conflict detection: Warns about overlapping meetings
- 12 available functions: From basic event creation to complex schedule analysis
- Multi-step workflows: LLM chains functions for complex requests
- Numbered selections: "Show slots" → "book slot 3"
- Extensible: Easy to add new calendar operations
- Remembers recent lists: Can respond to "book 1" after showing time slots
- Maintains conversation flow: Understands follow-up questions
- Personalized responses: References your stored preferences and history
- Node.js 18+
- npm or yarn
- Google Cloud Project with Calendar API enabled
- Telegram Bot Token
# Install dependencies
npm install
# Copy environment file
cp .env.example .envEdit .env file with your credentials:
# Telegram Bot
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_WEBHOOK_SECRET=optional_webhook_secret
# OpenAI
OPENAI_API_KEY=your_openai_api_key_here
# Google Calendar
GOOGLE_OAUTH_CLIENT_ID=your_google_client_id_here
GOOGLE_OAUTH_CLIENT_SECRET=your_google_client_secret_here
GOOGLE_OAUTH_REDIRECT_URL=http://localhost:3000/oauth/google/callback- Message @BotFather on Telegram
- Use
/newbotcommand - Follow instructions to create your bot
- Copy the bot token to
.env
- Go to Google Cloud Console
- Create new project or select existing
- Enable Google Calendar API
- Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"
- Set application type to "Web application"
- Add authorized redirect URI:
http://localhost:3000/oauth/google/callback - Copy Client ID and Client Secret to
.env
- Go to OpenAI Platform
- Create account or sign in
- Go to API Keys section
- Create new API key
- Copy to
.env
# Development mode
npm run start:dev
# Production mode
npm run build
npm run start:prodVisit http://localhost:3000/oauth/google/start in your browser to authorize Google Calendar access.
- Find your bot on Telegram
- Send
/startto begin - Try natural language commands like:
- "create event for 7pm called Tennis"
- "schedule meeting tomorrow at 3pm with John"
- "add lunch at 12:30pm"
- Simple: "create event for 7pm called Tennis"
- With details: "schedule meeting tomorrow at 3pm with John at Google office"
- Recurring info: "my standup is every day at 10am for 15 minutes"
- Find free time: "when am I free for 2 hours tomorrow?"
- Check conflicts: "am I free at 3pm Friday?"
- Smart scheduling: "schedule with John for 90 minutes next week"
- Store preferences: "I prefer morning meetings and hate Friday afternoons"
- Remember contacts: "John is my manager at Google, email john@google.com"
- Set patterns: "lunch is always 12:30-1:30pm"
- Query memory: "what do you remember about my meeting preferences?"
- Daily planning: "plan my day" or "optimize my schedule"
- Schedule analysis: "how busy am I this week?"
- Find patterns: "analyze my meeting patterns this month"
- Follow-up selections: After seeing time slots → "book slot 3" or just "3"
- Batch operations: "delete all meetings with Sarah from last month"
- Complex queries: "reschedule my 2pm meeting to first available slot tomorrow"
src/
├── telegram/ # Telegram bot integration & conversation handling
├── llm/ # LLM function calling & response generation
├── calendar/ # Google Calendar API & orchestration service
├── memory/ # Smart memory system with LLM-powered extraction
└── common/ # Shared types, schemas, and function definitions
- 📱 TelegramService: Handles bot interactions and message routing
- 🧠 LlmService: Function calling, planning, and response generation
- 📅 CalendarService: Google Calendar API integration
- 🎯 CalendarOrchestratorService: Dynamic function execution (12+ functions)
- 💾 MemoryService: Context storage, preference learning, conversation memory
- 📋 Function Schemas: 12 calendar operations from simple to complex
- User Message → TelegramService
- Memory Extraction → MemoryService (stores important info)
- Context Building → Retrieves relevant memories + user preferences
- LLM Planning → Determines functions to call with full context
- Function Execution → CalendarOrchestratorService runs operations
- Response Generation → LLM creates natural language response
- Memory Update → Stores conversation context for follow-ups
list_events- Get calendar events for time rangescheck_availability- Check if free at specific timescreate_event- Create calendar eventsdelete_events- Remove events by search criteriafind_free_slots- Find available time slotsanalyze_schedule- Analyze patterns and insightsreschedule_events- Move existing eventsstore_memory- Save important informationsearch_memory- Find relevant stored infoget_user_preferences- Retrieve user contextupdate_user_context- Modify user settingsselect_from_list- Handle numbered selectionscheck_conflicts- Detect scheduling conflicts
# Install dependencies
npm install
# Run in development mode
npm run start:dev
# Run tests
npm test
# Lint code
npm run lintSee plan.MD for detailed development roadmap including future versions with image processing, database persistence, and advanced features.
For issues or questions, check the logs or create an issue in the repository.