I’ve been maintaining a TIL (Today I Learned) page for a while now, and while the idea is great, I have had some issues updating the sheet daily. The manual workflow was becoming a bottleneck in my learning documentation process.
The Problem with Manual TIL Management
My original flow looked like this:
- Discovery: Whenever I find a link or factoid interesting, I save them in a WhatsApp group where I’m the only member for later record
- Manual Transfer: Add these to the TIL page whenever I could find time
- Reality: Lately, I’ve not been able to keep up with the manual updates
The problems with this approach were numerous:
- Too Manual: This is against everything I believe in - I automate everything I can
- Poor Searchability: Finding links is hard unless I’m using
ripgrep
on a non-mobile device - Difficult Maintenance: Categorizing things and updating the look of my TIL page is cumbersome
- Mobile Unfriendly: Hard to update when away from my development machine
I had been meaning to leverage a Telegram bot for this task for quite some time, but never got around to actually building it. This weekend, as I prepped myself to shift my body clock to attend David Beazley’s RAFT Course, I decided to use the midnight oil to write my own bot.
Why Discord Over Telegram?
I’ve been using Discord to talk to friends and communities lately, and I’ve found its integration with Linux to be amazing. Here’s why I chose Discord:
Platform Benefits
- Cross-Platform: Excellent web UI, desktop app that works well everywhere
- Mobile Support: Great mobile app for phones and tablets
- Linux Integration: Seamless experience on my primary development platform
- API Quality: Robust Python library with comprehensive documentation
Developer Experience
- Rich API: Discord’s API is well-designed and feature-complete
- Python Library:
discord.py
provides excellent abstractions - Community: Large developer community with good examples and support
Development Resources
I relied on several key resources for building Sarathi:
- Real Python Discord Bot Tutorial - Excellent starting point
- Discord Official Documentation - Comprehensive API reference
discord.py
Documentation - Library-specific guidance
discord.py
documentation leaves something to be desired. However, users of click
will really understand how this library is architected - the patterns are very similar.
Bot Goals and Features
I wanted Sarathi to handle the complete TIL workflow automatically:
Core Functionality
- Input Processing: Parse arbitrary commands for URLs or factoids
- Content Extraction: Extract titles from URLs automatically
- Data Management: Maintain a time-based JSON file in my blog’s GitHub repository
- Git Integration: Automatically commit the JSON to GitHub
- Site Generation: Regenerate the
til.md
file using Jinja2 templates - Auto-Deploy: Push code to GitHub for instant blog updates
- Search API: Query the knowledge base with simple search functionality
Smart Features
- Duplicate Detection: Prevent adding the same TIL on the same date
- Repetition Tracking: Track when I encounter previously recorded information
- Category Management: Organize TILs with space-separated category tags
- Mobile-First: Designed for easy use from Discord mobile app
Bot in Action
Let me show you how Sarathi works in practice:
Help Command
The bot uses /
as a command prefix and provides comprehensive help:
Command: /til add https://example.com/article python automation
Result: Sarathi extracts the page title, adds it to the JSON database with today’s date, commits to GitHub, regenerates the TIL page, and confirms the addition.
Duplicate Prevention
If you try adding the same TIL on the same date, Sarathi provides intelligent feedback:
- Same Day: “You just learned this today!”
- Different Day: Adds to
repeated_added_on
field for learning pattern analysis - Future Analysis: Could help identify gaps in my learning retention
Factoid Support
Not all TILs are links - sometimes they’re just interesting facts:
Sarathi handles both URLs and plain text factoids seamlessly.
Search Functionality
Query your accumulated knowledge instantly:
The search matches against:
- Categories: Tagged topics and themes
- Content: URL titles and factoid text
- Context: Any metadata associated with entries
Technical Architecture
Core Technologies
- Python: Primary development language
- discord.py: Discord API integration
- Beautiful Soup: Web scraping for URL title extraction
- Jinja2: Template engine for TIL page generation
- Git/GitHub: Version control and hosting
- JSON: Simple, readable data storage format
Workflow Automation
- Discord Input → Parse command and extract data
- Content Processing → Fetch URL titles, validate input
- Database Update → Add to JSON with timestamps and categories
- Git Operations → Commit changes with descriptive messages
- Site Regeneration → Use Jinja2 templates to rebuild TIL page
- Deployment → Push to GitHub for instant site updates
Data Structure
|
|
Learning and Development Experience
Building Sarathi taught me several important lessons:
Discord Bot Development
- Command Patterns: How to structure bot commands effectively
- Async Programming: Working with Discord’s async/await patterns
- Error Handling: Graceful failure and user feedback
- State Management: Handling persistent data across bot restarts
Workflow Automation
- Git Integration: Programmatic commits and pushes
- Template Systems: Dynamic content generation with Jinja2
- Web Scraping: Reliable title extraction from diverse websites
- Data Validation: Ensuring data integrity in automated systems
Future Improvements
Several enhancements are planned for Sarathi:
Immediate Roadmap
- TODO Bot: Manage my TODO list with VSCode-compliant TODO files
- Book Bot: Interface with my bookshelf’s API for reading tracking
- Reading Progress: Track book reading progress and notes
- Anki Integration: Generate Anki cards from TIL entries for spaced repetition
Advanced Features
- Regex Search: More powerful search with regular expression support
- Notes Integration: Interface with my notes repository for learning packages
- Analytics: Learning pattern analysis and knowledge gap identification
- Export Options: Multiple output formats (PDF, Markdown, etc.)
Impact and Results
Sarathi has dramatically improved my learning documentation workflow:
Quantitative Improvements
- Speed: From manual updates taking 10-15 minutes to instant Discord commands
- Consistency: No more missed or forgotten TIL entries
- Accessibility: Can update from anywhere using Discord mobile app
- Organization: Automatic categorization and searchable knowledge base
Qualitative Benefits
- Reduced Friction: Learning documentation is now effortless
- Better Retention: Searchable format helps reinforce past learning
- Pattern Recognition: Duplicate tracking reveals learning gaps
- Motivation: Seeing accumulated knowledge encourages continued learning
Source Code and Learning
The complete source code for Sarathi is available on GitHub: stonecharioteer/sarathi
While very specific to my personal workflow, the codebase demonstrates several useful patterns:
- Discord bot command structure and async patterns
- Git automation with Python subprocess calls
- Web scraping with Beautiful Soup and requests
- Template systems with Jinja2 for content generation
- JSON data management for simple persistent storage
Reflection on Automation
This project reinforces a core principle I hold: automate the boring stuff. By removing the friction from learning documentation, I’ve made it more likely that I’ll actually capture and retain new knowledge.
Sarathi proves that sometimes the best solutions are the ones we build ourselves, tailored exactly to our personal workflows and preferences.
Building Sarathi was a weekend project that turned into a daily productivity multiplier. It demonstrates how automation can transform tedious manual processes into effortless habits, ultimately supporting better learning and knowledge retention.