- create bot by messaging @botfather (/newbot)
- save a token in env var:
export token="yourtokenfrombotfather"
. If you need to re-issue a token, use /revoke command to botfather. - add your bot to a channel you intend for alerts
- Send some message into that channel using telegram client. A simple "test" will do.
- get chat id: curl https://api.telegram.org/bot${token}/getUpdates | grep test
- send a test message: curl https://api.telegram.org/bot${token}/sendMessage --data '{"chat_id":${chat_id},"text": "message"}' -H "Content-type: application/json"
- codify the above experience.
#!/bin/bash
set -eu -o pipefail