A powerful, configurable automation hub for monitoring emails and handling webhooks with Telegram notifications
This project implements comprehensive security and code quality measures:
- ๐ Static Code Analysis - golangci-lint, gosec, CodeQL
- ๐ต๏ธ Secret Detection - TruffleHog, GitLeaks, Semgrep
- ๐ Vulnerability Scanning - govulncheck, Nancy, Trivy
- ๐ค Automated Dependency Updates - Dependabot
- ๐ Code Coverage - Codecov integration
- ๐ CI/CD Pipeline - Automated testing and security checks
- ๐ง Real-time email monitoring - IMAP-based email processing with configurable polling
- ๐ง Dynamic service configuration - Add new email processors without code changes
- ๐ค Telegram notifications - Organized notifications with custom formatting per service
- ๐ Configurable webhook support - Handles qBittorrent and other webhook integrations with custom messages
- ๐๏ธ Modular architecture - Clean, extensible, and maintainable codebase
- ๐ Docker ready - Optimized for Raspberry Pi 5 and cloud deployment
Component | Version | Notes |
---|---|---|
Go | 1.24.5+ | For local development |
Docker | 20.10+ | Required for deployment |
Docker Compose | 2.0+ | Orchestration |
Supported Platforms: ARM64 (Raspberry Pi 5), AMD64
# Copy example configuration
cp configs/config.yaml.example configs/config.yaml
The new dynamic service system allows you to add email processors through configuration only:
server:
address: ":8080"
email:
host: "imap.gmail.com"
port: 993
username: "your-email@gmail.com"
password: "your-app-password"
polling_interval: 30 # Seconds between email checks
# ๐ Dynamic service configuration - Add any email processor here!
services:
- name: "cloudflare"
config:
email_from: "noreply@notify.cloudflare.com"
email_subject:
- "your-domain.com"
telegram_chat_id: "YOUR_CLOUDFLARE_CHAT_ID"
telegram_message: "๐ก๏ธ Cloudflare Code: ```%s```"
# code_pattern: "\\b\\d{6}\\b" # Optional: custom regex
- name: "perplexity"
config:
email_from: "team@mail.perplexity.ai"
email_subject:
- "Sign in to Perplexity"
telegram_chat_id: "YOUR_PERPLEXITY_CHAT_ID"
telegram_message: "๐ฎ Perplexity Code: ```%s```"
# โ Add more services here without touching code!
# ๐ Webhook Configuration
hook:
- name: "qbittorrent"
config:
telegram_chat_id: "YOUR_QBITTORRENT_CHAT_ID"
telegram_message: "๐ฅ **Download completed successfully!** ๐ฌ \n๐ **Name:** \n%s\n๐ **Path:** \n%s"
# Add more webhooks here:
# - name: "sonarr"
# config:
# telegram_chat_id: "YOUR_SONARR_CHAT_ID"
# telegram_message: "๐บ Serie descargada: %s"
telegram:
bot_token: "YOUR_BOT_TOKEN"
chat_ids:
torrent: "YOUR_TORRENT_CHAT_ID"
- Create a bot: Message @BotFather โ
/newbot
- Get bot token: Save the token from BotFather
- Get chat IDs:
- Add your bot to the desired chats
- Send a message, then visit:
https://api.telegram.org/bot<TOKEN>/getUpdates
- Find the
chat.id
values
# Clone repository
git clone <your-repo-url>
cd automation-hub
# Configure
cp configs/config.yaml.example configs/config.yaml
# Edit configs/config.yaml with your credentials
# Deploy
docker-compose up -d
# View logs
docker-compose logs -f automation-hub
# Build for your platform
docker build -f deployments/docker/Dockerfile -t automation-hub .
# Run with volume mount
docker run -d \
--name automation-hub \
--restart unless-stopped \
-v $(pwd)/configs/config.yaml:/root/configs/config.yaml:ro \
automation-hub
# Install dependencies
go mod download
# Run application
go run cmd/automation-hub/main.go
# Run tests
go test ./...
Endpoint | Method | Description |
---|---|---|
/webhook/qbitorrent |
POST | qBittorrent completion notifications |
Configure qBittorrent to send webhooks on completion. The webhook now supports custom messages configured in your config.yaml
:
Tools โ Options โ Downloads โ Run external program on torrent completion:
curl -X POST http://your-server:8080/webhook/qbitorrent \
-H "Content-Type: application/json" \
-d '{"torrent_name":"%N","save_path":"%F"}'
๐ Custom Message Configuration:
You can customize the notification message in your config.yaml
:
hook:
- name: "qbittorrent"
config:
telegram_chat_id: "YOUR_CHAT_ID"
telegram_message: "๐ฌ Your custom message! \n๐ File: %s\n๐ Location: %s"
The %s
placeholders will be replaced with:
- First
%s
โ Torrent name - Second
%s
โ Save path
The system now supports configurable webhooks! Add new webhook handlers without coding:
hook:
- name: "qbittorrent"
config:
telegram_chat_id: "TORRENT_CHAT_ID"
telegram_message: "๐ฅ Download complete: %s in %s"
- name: "sonarr"
config:
telegram_chat_id: "SONARR_CHAT_ID"
telegram_message: "๐บ New series: %s"
- name: "radarr"
config:
telegram_chat_id: "RADARR_CHAT_ID"
telegram_message: "๐ฌ New movie: %s"
Each webhook can have:
- โ Custom chat destination
- โ Personalized message format
- โ Multiple parameter placeholders
The magic โจ of this system is that you can add new email processors without writing any code:
# Just add to your config.yaml:
email:
services:
- name: "github"
config:
email_from: "noreply@github.com"
email_subject: ["verification code"]
telegram_chat_id: "YOUR_CHAT_ID"
telegram_message: "๐ GitHub Code: ```%s```"
code_pattern: "\\b\\d{6}\\b" # Custom regex for 6-digit codes
That's it! The system will automatically:
- โ Monitor emails from the specified sender
- โ Match subject patterns
- โ Extract codes using the pattern
- โ Send formatted Telegram notifications
- Enable 2FA: Go to Google Account Security
- Generate App Password:
- Security โ 2-Step Verification โ App passwords
- Select "Mail" and generate password
- Use App Password: Use the generated password in
config.yaml
- Tools โ Options โ Downloads
- Run external program on torrent completion:
curl -X POST http://localhost:8080/webhook/qbitorrent \ -H "Content-Type: application/json" \ -d '{"torrent_name":"%N","save_path":"%F"}'
๐ Message Customization:
- Edit
telegram_message
in yourconfig.yaml
- Use
%s
placeholders for torrent name and save path - Supports Markdown formatting for rich notifications
- All example messages have been translated to English; customize freely.
# Docker Compose
docker-compose logs -f automation-hub
# Docker
docker logs -f automation-hub
# Local development
# Logs output to stdout with structured JSON format
- Docker: Logs rotate automatically with size and time limits
- Local: Standard output with structured logging
- Production: JSON format for easy parsing and monitoring
๐ง IMAP Connection Failed
# Check your config.yaml:
email:
host: "imap.gmail.com" # Correct IMAP server
port: 993 # Correct port (usually 993 for SSL)
username: "your-email@gmail.com"
password: "app-password" # Use app password, not regular password!
Solutions:
- โ Use app password for Gmail (not your regular password)
- โ Enable 2FA and generate app password
- โ Check firewall settings
- โ Verify IMAP is enabled in email provider
๐ค Telegram Notifications Not Working
Check the basics:
- โ Bot token is correct
- โ Chat IDs are correct (including negative sign for groups)
- โ Bot has permission to send messages
- โ Bot is added to the target chat/group
Get chat ID:
# Send a message to your bot, then:
curl https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
๐ Webhooks Not Received
Debugging steps:
- โ Check if port 8080 is accessible
- โ
Verify JSON payload format matches expected:
{"torrent_name":"...", "save_path":"..."}
- โ
Verify webhook configuration exists in
config.yaml
- โ Check application logs for errors
- โ
Test with curl manually:
curl -X POST http://localhost:8080/webhook/qbitorrent \ -H "Content-Type: application/json" \ -d '{"torrent_name":"Test Movie","save_path":"/downloads/movies/"}'
๐จ Webhook Message Not Formatting
Check your config:
hook:
- name: "qbittorrent"
config:
telegram_chat_id: "123456789" # Correct chat ID
telegram_message: "Download: %s in %s" # Two %s placeholders
Common issues:
- โ
Ensure you have exactly 2
%s
placeholders for qBittorrent - โ
Check that the webhook name matches exactly (
"qbittorrent"
) - โ Verify chat ID is correct (including negative sign for groups)
PX1 - devidence.dev ยฉ
This project is licensed under the MIT License - see the LICENSE file for details.