This article explains how to send notifications in Telegram using the message-sending method via the Telegram API.
If the bot has not been started by the user in Telegram, it will not be able to send notifications.
Set up variables
1.1. Add the Result block.
1.2. Add the following variables:
{messengerUserId} variable to retrieve the current bot user's ID.Create a request to the Telegram API:
2.1. Add the Server Request block.
2.2. Open the block's parameters and click Open Request Editor.
2.3. Navigate to the cURL tab.
2.4. Insert the following request:
curl 'https://api.telegram.org/bot{bot_token}/sendMessage?' -X 'POST' -H 'Content-Type: application/json' --data-raw '{"chat_id":"{chat_id}","text":"{text}"}'
When sending messages via the Telegram API, text formatting is supported. Specify the parse_mode parameter to avoid display errors.
HTML formatting:
parse_mode=HTML
Markdown formatting:parse_mode=MarkdownV2
To use HTML formatting in messages, send the following request:
curl 'https://api.telegram.org/bot{bot_token}/sendMessage?parse_mode=HTML' -X 'POST' -H 'Content-Type: application/json' --data-raw '{"chat_id":"{chat_id}","text":"{text}"}'
For more details on HTML formatting in Telegram, refer to the article Formatting in Telegram.
To use Markdown formatting in messages, send the following request:
curl 'https://api.telegram.org/bot{bot_token}/sendMessage?parse_mode=MarkdownV2' -X 'POST' -H 'Content-Type: application/json' --data-raw '{"chat_id":"{chat_id}","text":"{text}"}'
For more details on Markdown formatting in Telegram, refer to the article Formatting in Telegram.