Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Life Scheduler Bot

A privacy-first, self-hosted Telegram bot that converts voice messages into Google Calendar events using local AI processing.

Features

  • 🎤 Voice-to-Calendar: Send voice messages to create, view, and manage calendar events
  • 🔒 Privacy First: All AI processing happens locally (Whisper + Ollama)
  • 🤖 Natural Language: Understands natural speech patterns
  • 📅 Google Calendar Integration: Seamlessly manages your calendar
  • 🐳 Docker Ready: Easy deployment with Docker Compose
  • ✅ Conflict Detection: Prevents double-booking
  • 🧪 Well Tested: Comprehensive test suite

Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone <repository-url>
    cd life-schedule-bot
  2. Set up development environment

    make init
    # Activate virtual environment
    # Windows:
    venv\Scripts\activate
    # Unix/Mac:
    source venv/bin/activate
    
    make install-dev
  3. Configure environment variables

    cp .env.example .env
    # Edit .env with your configuration
  4. Set up Google Calendar API

  5. Install and configure Ollama

    # Install Ollama (see https://ollama.ai/)
    ollama pull llama3.1
  6. Run the bot

    make run

Environment Variables

# Required
TELEGRAM_BOT_TOKEN=your_bot_token_here
GOOGLE_CALENDAR_CREDENTIALS_PATH=config/google_credentials.json

# Optional
OLLAMA_HOST=localhost:11434
OLLAMA_MODEL=llama3.1
WHISPER_MODEL=base
ALLOWED_USER_IDS=your_telegram_user_id

Usage

Send voice messages to your bot with natural language:

Creating Events

  • "Schedule meeting with Sarah tomorrow at 2pm"
  • "Remind me to call the doctor at 3:30"
  • "Block out time for coding from 9 to 11 AM"

Viewing Events

  • "What's on my calendar today?"
  • "Show me tomorrow's schedule"
  • "What do I have next week?"

Managing Events

  • "Cancel my 3pm meeting"
  • "Delete the doctor appointment"
  • "Remove the team standup"

Docker Deployment

  1. Using Docker Compose (recommended)

    # Configure .env file first
    docker-compose up -d
  2. Manual Docker Build

    docker build -t life-schedule-bot .
    docker run -d --name life-scheduler \
      --env-file .env \
      -v ./config:/app/config:ro \
      -v ./data:/app/data \
      life-schedule-bot

Development

Commands

make help          # Show available commands
make test          # Run all tests
make test-unit     # Run unit tests only
make format        # Format code with Black and isort
make lint          # Run linting with flake8 and mypy
make clean         # Clean build artifacts

Project Structure

src/
├── bot/           # Telegram bot handlers and configuration
├── llm/           # Ollama LLM client for intent parsing
└── utils/         # Audio processing and calendar service
tests/
├── unit/          # Unit tests for individual modules
├── integration/   # Integration tests for the full pipeline
└── conftest.py    # Shared test fixtures
config/            # Configuration files and prompts

Testing

The project includes comprehensive tests:

  • Unit Tests: Test individual components in isolation
  • Integration Tests: Test the complete voice-to-calendar pipeline
  • Mocking: External services (Telegram, Google Calendar, Ollama) are mocked
# Run all tests with coverage
make test

# Run only unit tests
make test-unit

# Run with verbose output
pytest -v

# Run specific test file
pytest tests/unit/test_audio.py

Code Quality

  • Black: Code formatting (88 character line length)
  • isort: Import sorting
  • flake8: Linting
  • mypy: Type checking
  • pre-commit: Automated code quality checks

Architecture

Voice Processing Pipeline

  1. Telegram Bot receives voice message
  2. Whisper STT transcribes audio to text locally
  3. Ollama LLM parses calendar intent from text
  4. Calendar Service executes the calendar operation
  5. Bot sends confirmation back to user

Privacy & Security

  • ✅ Local AI processing (no external API calls)
  • ✅ Audio files deleted immediately after processing
  • ✅ No data persistence beyond SQLite patterns
  • ✅ User authorization system
  • ✅ Self-hosted deployment option

Configuration

Whisper Models

Choose based on your hardware and accuracy needs:

  • tiny: Fastest, least accurate
  • base: Good balance (default)
  • small: Better accuracy, slower
  • medium: High accuracy, requires more RAM
  • large: Best accuracy, requires significant resources

Ollama Models

Tested models:

  • llama3.1: Recommended (default)
  • llama3.1:7b: Faster, less accurate
  • llama3.1:70b: More accurate, requires powerful hardware

Troubleshooting

Common Issues

  1. Bot not responding to voice messages

    • Check bot token is correct
    • Verify bot permissions
    • Check user authorization in logs
  2. Transcription errors

    • Try a larger Whisper model
    • Ensure clear audio quality
    • Check available memory
  3. Calendar API errors

    • Verify Google credentials file exists
    • Check calendar API is enabled
    • Ensure proper OAuth scopes
  4. Ollama connection issues

    • Verify Ollama is running (ollama list)
    • Check model is downloaded (ollama pull llama3.1)
    • Verify connection host/port

Logs

Enable debug logging:

export BOT_DEBUG=True
export LOG_LEVEL=DEBUG

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (make test)
  5. Format code (make format)
  6. Commit changes (git commit -m 'Add amazing feature')
  7. Push to branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages