GO version: https://github.com/nopp/alertmanager-webhook-telegram-go
├── app/
│ ├── __init__.py # app factory (create_app)
│ ├── config.py # config from env vars
│ ├── alerts.py # alert message builder
│ ├── telegram.py # Telegram HTTP client
│ └── routes.py # Flask blueprint (/alert)
├── wsgi.py # gunicorn / dev entrypoint
├── requirements.txt
└── docker/
├── Dockerfile
└── run.sh
- Python 3.11+
- pip packages: see
requirements.txt
All config via environment variables — no hardcoded secrets.
| Variable | Required | Default | Description |
|---|---|---|---|
TELEGRAM_BOT_TOKEN |
✅ | — | Bot token from @BotFather |
TELEGRAM_CHAT_ID |
✅ | — | Target chat/group ID |
BASIC_AUTH_USERNAME |
❌ | "" |
HTTP basic auth username |
BASIC_AUTH_PASSWORD |
❌ | "" |
HTTP basic auth password |
BASIC_AUTH_FORCE |
❌ | true |
Set false to disable auth |
SECRET_KEY |
❌ | random | Flask secret key |
MAX_RETRIES |
❌ | 3 |
Telegram send retries |
pip install -r requirements.txt
export TELEGRAM_BOT_TOKEN=your_token
export TELEGRAM_CHAT_ID=your_chat_id
export BASIC_AUTH_USERNAME=admin
export BASIC_AUTH_PASSWORD=secret
# dev
python wsgi.py
# production
gunicorn -w 4 -b 0.0.0.0:9119 wsgi:appcd docker/
docker build -t alertmanager-webhook-telegram .
docker run -d --name telegram-webhook \
-e TELEGRAM_BOT_TOKEN=your_token \
-e TELEGRAM_CHAT_ID=your_chat_id \
-e BASIC_AUTH_USERNAME=admin \
-e BASIC_AUTH_PASSWORD=secret \
-p 9119:9119 \
alertmanager-webhook-telegramreceivers:
- name: telegram-webhook
webhook_configs:
- url: http://your-host:9119/alert
send_resolved: true
http_config:
basic_auth:
username: admin
password: secret- Go to https://web.telegram.org/
- Open the target chat
- Copy the numeric ID from the URL (e.g.
https://web.telegram.org/#/im?p=g1234567→ ID is-1234567for groups)
curl -XPOST \
-u admin:secret \
-H 'Content-Type: application/json' \
--data '{
"status": "resolved",
"alerts": [{
"status": "resolved",
"labels": {
"alertname": "instance_down",
"instance": "i-0d7188fkl90bac100",
"name": "prod-server"
},
"annotations": {
"summary": "Instance i-0d7188fkl90bac100 down",
"description": "Host has been down for more than 2 minutes."
},
"endsAt": "2024-01-01T16:16:19Z",
"startsAt": "2024-01-01T16:02:19Z"
}]
}' \
http://localhost:9119/alert