Simple Telegram notification framework with plugin support
Project description
Telegrify
Simple, powerful Telegram notification framework with plugin support
Telegrify receives HTTP webhooks and forwards them as formatted Telegram messages. Perfect for alerts, order notifications, monitoring, CI/CD pipelines, and any system that needs to notify users via Telegram.
Features
- 🚀 Simple - Install, configure, run in under 5 minutes
- 🔌 Plugin System - Custom formatters without touching core code
- 📱 All Chat Types - Private chats, groups, supergroups, channels
- 📢 Broadcast - Send to multiple chats simultaneously
- 🖼️ Rich Media - Single images, photo galleries (up to 10)
- 🎹 Inline Keyboards - Interactive buttons with dynamic templates
- 🤖 Command Handlers - Respond to /start, /help, etc.
- 🏷️ Custom Labels - Map
order_id→🆔 Order ID - 🔀 Field Mapping - Map nested JSON fields with dot notation
- 📝 Jinja2 Templates - Conditionals, loops, filters
- 🎨 Formatters - Plain text, Markdown, or custom plugins
- 🔒 Secure - API key authentication
- ♻️ Reliable - Automatic retries with exponential backoff
- 🐳 Docker Ready - Easy containerized deployment
Quick Start
1. Install
pip install telegrify
2. Create Project
telegrify init my_notifier
cd my_notifier
3. Configure
Edit config.yaml:
bot:
token: "${TELEGRAM_BOT_TOKEN}"
endpoints:
- path: "/notify/orders"
chat_id: "-1001234567890"
formatter: "plain"
4. Run
export TELEGRAM_BOT_TOKEN="your-bot-token"
telegrify run
5. Send Notification
curl -X POST http://localhost:8000/notify/orders \
-H "Content-Type: application/json" \
-d '{"message": "New order received!", "order_id": 123}'
Documentation
Configuration Reference
Bot Configuration
bot:
token: "${TELEGRAM_BOT_TOKEN}" # Bot token (supports env vars)
test_mode: false # Log instead of sending (for testing)
webhook_url: "${WEBHOOK_URL}" # Public URL for receiving updates
webhook_path: "/bot/webhook" # Webhook endpoint path
Templates
templates:
order_received: |
🛒 *New Order \#{{ order_id }}*
Customer: {{ customer }}
Total: {{ total }}
Endpoint Configuration
endpoints:
- path: "/webhook/orders" # HTTP endpoint path
chat_id: "8345389653" # Single chat ID
chat_ids: # Or multiple chat IDs
- "8345389653"
- "-1001234567890"
- "@my_channel"
formatter: "markdown" # plain, markdown, or plugin name
template: "order_received" # Use template instead of formatter
parse_mode: "MarkdownV2" # Telegram parse mode
labels: # Custom display labels
order_id: "🆔 Order"
customer: "👤 Customer"
field_map: # Map incoming fields
image_url: "product.photo" # Supports dot notation
image_urls: "product.gallery"
Server Configuration
server:
host: "0.0.0.0"
port: 8000
api_key: "${API_KEY}" # Optional authentication
logging:
level: "INFO" # DEBUG, INFO, WARNING, ERROR
CLI Commands
telegrify init <name> # Create new project
telegrify run # Start server
telegrify run --reload # Start with auto-reload (dev)
telegrify validate # Validate config file
telegrify webhook setup # Register webhook with Telegram
telegrify webhook info # Show webhook status
telegrify webhook delete # Remove webhook
telegrify --version # Show version
Custom Plugins
Create plugins/my_formatter.py:
from telegrify import IPlugin
class MyFormatter(IPlugin):
@property
def name(self):
return "my_formatter"
def format(self, payload: dict, config: dict) -> str:
prefix = config.get("prefix", "📢")
return f"{prefix} {payload.get('message', '')}"
Use in config:
endpoints:
- path: "/notify"
chat_id: "123456789"
formatter: "my_formatter"
plugin_config:
prefix: "🔔 Alert:"
API Response
Success:
{
"status": "sent",
"message_id": 123,
"chat_id": "8345389653"
}
Error (structured JSON):
{
"detail": {
"error": "invalid_api_key",
"message": "Invalid or missing API key"
}
}
Error codes: invalid_api_key, formatter_not_found, send_failed
Getting Your Chat ID
- Message @userinfobot on Telegram
- Or send a message to your bot and check:
curl https://api.telegram.org/bot<TOKEN>/getUpdates
License
MIT License - see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telegrify-0.9.0.tar.gz.
File metadata
- Download URL: telegrify-0.9.0.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9719dd18b5ea57910047bdc766c81fede4fee976b7a42843cb02a5bf7e2f33a
|
|
| MD5 |
1a8a890f0f98c57c53cd02cc4ce6fab4
|
|
| BLAKE2b-256 |
4bd96d6211ec74a5a2741aa0a21caaf2eb9193df83be05df21042e8753082943
|
File details
Details for the file telegrify-0.9.0-py3-none-any.whl.
File metadata
- Download URL: telegrify-0.9.0-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faff9a63ce7dbabc24c86b03e7c970e1bc2ce09afea5530ced3165d7ec063c21
|
|
| MD5 |
d4c5f5c0ccbe822cf5ca5a3525a0a18c
|
|
| BLAKE2b-256 |
cd9de92f133b7e2321e3daf7c9163ec3ce924e0b96aeca4554f940445012e097
|