A complete system for automatically converting Telegram bot messages into blog posts using Hugo static site generator, with manual approval workflow and GitHub Pages hosting.
- Daily Message Processing: Automated polling of Telegram messages once per day
- Manual Approval Workflow: Web interface for reviewing and approving messages
- Image Support: Automatic download and integration of images from messages
- Tag Management: Add custom tags to organize blog posts
- Automated Deployment: GitHub Actions automatically builds and deploys the Hugo site
- Archive System: Automatic archiving of old messages to keep data manageable
- Hugo Static Site: Fast, SEO-friendly blog generation
- Python Script: Daily polling of Telegram Bot API updates
- GitHub Pages: Free static site hosting with CDN
- GitHub Actions: Automated CI/CD pipeline and message fetching
- GitHub Repository: Central data storage and version control
- Telegram Bot: Create a bot via @BotFather
- GitHub Repository: Public repository for GitHub Pages hosting
- GitHub Personal Access Token: For approval interface
- Fork or clone this repository to your GitHub account
- Enable GitHub Pages in repository settings:
- Go to Settings β Pages
- Source: Deploy from a branch
- Branch:
gh-pages(will be created automatically)
- Update configuration:
- Edit
config.yamlwith your repository URL and details - Update
README.mdwith your project information
- Edit
- Create a new bot with @BotFather:
/newbot - Save the bot token (you'll need it for GitHub Secrets)
- Create GitHub Secrets (Settings β Secrets and variables β Actions):
TELEGRAM_BOT_TOKEN: Your bot token from BotFather- Note:
GITHUB_TOKENis automatically provided by GitHub Actions
- Verify workflows are enabled (Actions tab in GitHub repository)
- Test the fetch workflow by triggering it manually (Actions β Fetch Telegram Updates β Run workflow)
- Verify scheduled run will occur daily at midnight UTC
- Create GitHub Personal Access Token:
- Go to GitHub Settings β Developer settings β Personal access tokens
- Generate token with
reposcope
- Access approval interface:
- Visit:
https://npujol.github.io/tblog/admin/ - Enter your GitHub token to connect
- Visit:
- Send messages to your Telegram bot (text and/or images)
- Wait for daily sync (automatic at midnight UTC) or trigger manually via GitHub Actions
- Review pending messages in the admin interface
- Add tags and approve messages for publication
- Monitor published posts in the blog
- Visit your GitHub Pages URL to read the blog
- Posts are organized chronologically with tag filtering
- RSS feed available at
/index.xml
βββ content/ # Hugo content
β βββ posts/ # Generated blog posts
β βββ _index.md # Homepage content
βββ data/ # Message storage
β βββ pending-messages.json
β βββ approved-messages.json
β βββ published-messages.json
β βββ last-update-id.json # Track last processed update
β βββ schema.json # Data structure schema
βββ scripts/ # Content processing
β βββ fetch_telegram_updates.py # Fetch messages from Telegram
β βββ generate-content.js # Message β Hugo post conversion
β βββ archive-messages.js # Archive management
βββ static/ # Static assets
β βββ admin/ # Approval interface
β βββ images/ # Message images
βββ .github/workflows/ # GitHub Actions
β βββ fetch-telegram-updates.yml # Daily message fetching
β βββ hugo.yml # Hugo build and deploy
βββ config.yaml # Hugo configuration
βββ package.json # Node.js dependencies
- Telegram Bot Token: Stored securely in GitHub Secrets
- GitHub Token: Automatically provided by GitHub Actions with limited scope
- API Access: Read-only access to Telegram updates
- Input Validation: Message content sanitization
-
Install dependencies:
npm install
-
Install Hugo:
# macOS brew install hugo # Or download from https://gohugo.io/installation/
-
Run Hugo development server:
hugo server -D
-
Test Telegram fetcher locally (optional):
export TELEGRAM_BOT_TOKEN="your_token" export GITHUB_TOKEN="your_token" export GITHUB_OWNER="your_username" export GITHUB_REPO="your_repo" python scripts/fetch_telegram_updates.py
- Add test data to
data/pending-messages.json - Open admin interface at
http://localhost:1313/admin/ - Connect with GitHub token and test approval workflow
- GitHub Actions: Workflow logs for message fetching, build and deployment
- GitHub Pages: Site analytics and performance
- Browser Console: Client-side debugging for approval interface
- Data Files: Check
data/last-update-id.jsonfor sync status
- Default theme: Ananke (fast and simple)
- Change theme: Update
config.yamland install inthemes/directory - Custom layouts: Add overrides in
layouts/directory
- Modify data structure: Update
data/schema.jsonand processing scripts - Custom post format: Edit
scripts/generate-content.js - Change fetch schedule: Modify cron expression in
.github/workflows/fetch-telegram-updates.yml - Additional filters: Enhance message processing in
scripts/fetch_telegram_updates.py
- UI customization: Modify
static/admin/style.css - Feature additions: Extend
static/admin/script.js - Workflow changes: Update approval logic and GitHub API calls
The system uses the Telegram Bot API getUpdates method to poll for new messages daily.
pending-messages.json: Messages awaiting approvalapproved-messages.json: Messages ready for publicationpublished-messages.json: Successfully published postsrejected-messages.json: Rejected messages (for audit)last-update-id.json: Last processed Telegram update ID
| Variable | Description | Required |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Bot token from BotFather | Yes |
GITHUB_TOKEN |
Personal access token | Yes |
GITHUB_OWNER |
Repository owner username | Yes |
GITHUB_REPO |
Repository name | Yes |
-
Messages not being fetched:
- Verify
TELEGRAM_BOT_TOKENis set in GitHub Secrets - Check GitHub Actions workflow logs for errors
- Ensure the workflow is enabled and scheduled correctly
- Test manual trigger via Actions tab
- Verify
-
GitHub Actions failing:
- Check Hugo version compatibility
- Verify repository permissions
- Review action logs for specific errors
-
Approval interface not loading:
- Verify GitHub Pages is enabled
- Check browser console for errors
- Confirm GitHub token permissions
-
Images not displaying:
- Verify image paths in generated posts
- Check GitHub repository for uploaded files
- Ensure Hugo static file processing
# Test content generation locally
npm run generate
# Check Hugo build
npm run build
# Verify data files
cat data/pending-messages.json | jq .
# Check last update ID
cat data/last-update-id.json | jq .
# Test Telegram fetcher locally
python scripts/fetch_telegram_updates.pyMIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: This README and inline code comments
Built with β€οΈ using Hugo, Python, and GitHub