An intelligent Telegram bot that combines personal knowledge management with daily journaling. Built with Claude AI (Anthropic API) for natural, conversational interaction.
π Quick Start Guide β | π Roadmap β
Single bot for two systems:
- π Knowledge Base - Store and organize facts about people, projects, ideas, and admin tasks
- π Daily Journal - Keep a diary with text and voice entries, searchable across time
- π Hybrid Messages - Automatically extract facts from diary entries and cross-reference them
- β° Smart Reminders - Time-based notifications with optional recurring patterns
- π€ Voice Support - Send voice messages, automatically transcribed via Whisper
Search using meaning, not just keywords:
- Finds related content even with different words
- Works across multiple languages
- Hybrid approach: semantic similarity + keyword matching
- Automatic embedding generation on entry creation
Protect your data:
/exportcommand creates complete ZIP backup- Includes all journal entries, knowledge base, and audio files
- Sent directly via Telegram for easy download
- Auto-cleanup of old backups
The bot automatically classifies your messages:
- Diary - Emotional, reflective content goes to journal
- Knowledge - Facts, names, dates go to structured categories
- Hybrid - Diary entry + extracted facts, automatically linked
people- Information about people, relationshipsprojects- Work tasks, deadlines, project updatesideas- Creative thoughts, insights, future plansadmin- Logistics, appointments, locationsinbox- Low-confidence items for manual review
Main Commands:
/help- Show all commands and usage/today- Today's journal + upcoming reminders/day YYYY-MM-DD- View journal for specific date/search <query>- Semantic search across journal and knowledge/reminders- List upcoming reminders/inbox- Review items needing classification
Utilities:
/export- Download complete backup as ZIP/reset- Clear conversation history/rebuild_embeddings- Regenerate semantic search embeddings (admin)
Send voice messages in any language - they're automatically:
- Downloaded and stored
- Transcribed using OpenAI Whisper (local)
- Processed by the AI agent
- Stored in your journal with timestamp
Create reminders with natural language:
- "Remind me to call dentist tomorrow at 3pm"
- "Remind me to review report daily"
- Supports: one-time, daily, weekly, monthly
Hybrid messages automatically link diary and knowledge:
- Journal entries reference extracted facts
- Knowledge entries link back to journal dates
- Full context available in both systems
π Complete setup guide: See GETTING_STARTED.md for detailed step-by-step instructions, including:
- Getting API keys (Telegram + Anthropic)
- Local setup for testing
- Production deployment to Raspberry Pi
- Troubleshooting common issues
- Clone and install
git clone https://github.com/sebasfavaron/second-brain.git
cd second-brain
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install openai-whisper- Configure
cp .env.example .env
# Add your TELEGRAM_TOKEN and ANTHROPIC_API_KEY- Run
mkdir -p brain journal/entries journal/audio
python bot-listener.pyFor production deployment with systemd and cron, see GETTING_STARTED.md.
Telegram Message (text/voice)
β
[Voice? β Whisper transcription]
β
Claude Agent (unified prompt + tools)
β
Routes to: DIARY | KNOWLEDGE | HYBRID
β
βββββββββββββββββββ¬ββββββββββββββββββ
β β β
βΌ βΌ βΌ
journal/ brain/*.json both + links
YYYY/MM/DD.md (categories)
second-brain/
βββ bot-listener.py # Main bot - handles messages, commands
βββ brain-processor.py # Background jobs - digests, reminders
βββ agent_tools.py # Tool definitions for Claude
βββ classifier.py # Claude API client
βββ storage.py # JSON storage for knowledge base
βββ journal_storage.py # Markdown storage for journal
βββ reminder_storage.py # Reminder CRUD + trigger logic
βββ voice_handler.py # Voice transcription via Whisper
βββ conversation_state.py # Conversation history management
βββ context_manager.py # Context enrichment for classification
βββ config.py # Configuration and paths
βββ migrate_lifelog.py # Migration script for existing journals
βββ brain/ # Storage directory
βββ people.json
βββ projects.json
βββ ideas.json
βββ admin.json
βββ inbox.json
βββ reminders.json
βββ audit.json
βββ state.json
βββ *_context.md
βββ journal/ # Journal directory
βββ entries/YYYY/MM/DD.md
βββ audio/YYYY/MM/*.ogg
βββ index.json
Edit config.py to customize:
CONFIDENCE_THRESHOLD = 0.7- Classification confidence thresholdDIGEST_HOUR = 9- Daily digest timeDEFAULT_REMINDER_HOUR = 9- Default reminder timeWHISPER_MODEL = "base"- Whisper model (tiny, base, small, medium, large)
You: "Felipe's birthday is March 15"
Bot: Guardado en people (90%)
You: "Today was tough, long meeting with the team"
Bot: Entrada guardada en diario β
You: "Great call with Juan, we set deadline for Friday"
Bot: Entrada guardada en diario β
TambiΓ©n guardado:
β’ Juan (people)
β’ Deadline Friday (projects)
You: "Remind me to call dentist tomorrow at 3pm"
Bot: Recordatorio creado para maΓ±ana 15:00 β
You: [sends voice message]
Bot: π€ Transcribiendo...
π TranscripciΓ³n: [your message]
Entrada guardada en diario β
The bot has direct access to these tools:
Knowledge Base:
list_entries- List entries in a categorysearch_entries- Search across categoriesget_entry- Get specific entry by IDcreate_entry- Store new informationmove_entry- Move between categoriesdelete_entry- Delete an entry
Journal:
write_journal- Add diary entryread_journal- Read journal for datesearch_journal- Search all journal entries
Reminders:
create_reminder- Set time-based reminderlist_reminders- Show upcoming reminders
Cross-Reference:
link_entries- Link journal to knowledgeget_audio_file- Retrieve voice recording
- Add to
CATEGORIESinconfig.py - Add to
STORAGE_FILESdict - Create context file in
brain/ - Update system prompt in
bot-listener.py
- Create handler function in
bot-listener.py - Add to command handlers in
main() - Add to
post_init()for autocomplete
# Test classification
python -c "from classifier import classify_message; print(classify_message('test message'))"
# Test storage
python -c "from storage import get_all_entries; print(get_all_entries('inbox'))"
# Test journal
python -c "from journal_storage import read_journal; print(read_journal())"Bot not responding:
# Check if bot is running
ps aux | grep bot-listener
# Check logs
tail -f bot.log
# Restart service
sudo systemctl restart second-brain-bot.serviceWhisper not working:
# Install FFmpeg
sudo apt-get install ffmpeg # Debian/Ubuntu
brew install ffmpeg # macOS
# Verify Whisper installation
python -c "import whisper; print('OK')"Commands not autocompleting:
- Delete and restart the Telegram chat with the bot
- Commands are set on bot startup - check logs for "Bot commands configured"
See NEXT_STEPS.md for planned improvements including:
- π¦ Backup & Export functionality
- π Semantic search with embeddings
- π Analytics & insights
- π Relationship mapping
- π·οΈ Hashtag support
- π Templates for common entries
- And more...
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Check NEXT_STEPS.md for ideas on what to work on.
MIT License - See LICENSE file for details
Built with:
- python-telegram-bot - Telegram Bot API
- Anthropic Claude - AI agent with tool use
- OpenAI Whisper - Voice transcription
Created by @sebasfavaron
Co-developed with Claude Sonnet 4.5 via Claude Code