A lightweight Rust HTTP server that relays messages to Telegram via a bot. Useful as a simple push notification service — point any webhook, CI pipeline, or script at it and get messages straight to your phone.
| Method | Path | Description |
|---|---|---|
| POST | / |
Send a Telegram message |
| GET | /health |
Returns {"status": "ok"} |
If path_prefix is set in the config (e.g. "path_prefix": "secret"), all endpoints move under that prefix: POST /secret, GET /secret/health.
- Create a bot with @BotFather and grab the token.
- Copy the sample config and fill it in:
cp config.sample.json config.json
- Build and run:
cargo build --release ./target/release/telegram-relay # or: cargo run --release -- /path/to/config.json - On first run the app waits for you to send
/startto your bot in Telegram. Once it sees a message from the configured username it resolves and caches thetelegram_chat_idin your config file.
The body is sent directly as the message text. JSON is also supported.
# plain text (shortest form)
curl -d 'deploy finished' http://127.0.0.1:3000
# JSON
curl -H 'Content-Type: application/json' \
-d '{"message": "deploy finished"}' http://127.0.0.1:3000Set the telegram-parse-mode header to enable Telegram formatting:
# MarkdownV2
curl -H 'telegram-parse-mode: markdown' \
-d '*bold* _italic_' http://127.0.0.1:3000
# HTML
curl -H 'telegram-parse-mode: html' \
-d '<b>bold</b> <i>italic</i>' http://127.0.0.1:3000| Field | Required | Description |
|---|---|---|
listen_addr |
yes | Address to bind (e.g. 127.0.0.1:3000) |
telegram_bot_token |
yes | Bot token from BotFather |
telegram_username |
yes | Telegram username to resolve chat ID for |
telegram_chat_id |
no | Resolved automatically on first run |
path_prefix |
no | Prefix for all routes (e.g. "secret" → /secret) |