A privacy-first, self-hosted Telegram bot that converts voice messages into Google Calendar events using local AI processing.
- 🎤 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
- Python 3.11+
- Telegram Bot Token (create one)
- Google Calendar API credentials (setup guide)
- Ollama running locally (install Ollama)
-
Clone the repository
git clone <repository-url> cd life-schedule-bot
-
Set up development environment
make init # Activate virtual environment # Windows: venv\Scripts\activate # Unix/Mac: source venv/bin/activate make install-dev
-
Configure environment variables
cp .env.example .env # Edit .env with your configuration -
Set up Google Calendar API
- Follow the Google Calendar API quickstart
- Download credentials file to
config/google_credentials.json
-
Install and configure Ollama
# Install Ollama (see https://ollama.ai/) ollama pull llama3.1 -
Run the bot
make run
# 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_idSend voice messages to your bot with natural language:
- "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"
- "What's on my calendar today?"
- "Show me tomorrow's schedule"
- "What do I have next week?"
- "Cancel my 3pm meeting"
- "Delete the doctor appointment"
- "Remove the team standup"
-
Using Docker Compose (recommended)
# Configure .env file first docker-compose up -d -
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
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 artifactssrc/
├── 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
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- Black: Code formatting (88 character line length)
- isort: Import sorting
- flake8: Linting
- mypy: Type checking
- pre-commit: Automated code quality checks
- Telegram Bot receives voice message
- Whisper STT transcribes audio to text locally
- Ollama LLM parses calendar intent from text
- Calendar Service executes the calendar operation
- Bot sends confirmation back to user
- ✅ 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
Choose based on your hardware and accuracy needs:
tiny: Fastest, least accuratebase: Good balance (default)small: Better accuracy, slowermedium: High accuracy, requires more RAMlarge: Best accuracy, requires significant resources
Tested models:
llama3.1: Recommended (default)llama3.1:7b: Faster, less accuratellama3.1:70b: More accurate, requires powerful hardware
-
Bot not responding to voice messages
- Check bot token is correct
- Verify bot permissions
- Check user authorization in logs
-
Transcription errors
- Try a larger Whisper model
- Ensure clear audio quality
- Check available memory
-
Calendar API errors
- Verify Google credentials file exists
- Check calendar API is enabled
- Ensure proper OAuth scopes
-
Ollama connection issues
- Verify Ollama is running (
ollama list) - Check model is downloaded (
ollama pull llama3.1) - Verify connection host/port
- Verify Ollama is running (
Enable debug logging:
export BOT_DEBUG=True
export LOG_LEVEL=DEBUG- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
make test) - Format code (
make format) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI Whisper for local speech-to-text
- Ollama for local LLM inference
- python-telegram-bot for Telegram integration
- Google Calendar API for calendar management