Featured image of post Send multi-line Telegram messages using cURL

Send multi-line Telegram messages using cURL

It's really easy and useful

Not much context behind this one, I have been messing with stuff like this recently while doing some scripting and found it worth enough bringing it here. The solution is fairly simple, declare the needed variables:

BOT_API_TOKEN='<your bot token here>'
CHAT_ID='<your chat ID here>'
MSG='
This is a simple
multiline message
'

Then just build the requests like this:

curl --data "chat_id=${CHAT_ID}" --data-urlencode "text=${MSG}" 'https://api.telegram.org/bot'${BOT_API_TOKEN}'/sendMessage'
                                 ------------------------------

Stay safe!

Built with Hugo