mikrotik send message to telegram

hi guys
my mikrotik v 6.49.4
I want to send message to telegram but there is a problem when sending
This is a message that shows the problem



[admin@rb951 home] > tool fetch url="https://api.telegram.org/bot5171614564:AAEJf0UpJpM68Axs-EGb4hPlx5twhtlf3ko/sendMessage


address –
as-value –
ascii – ftp transfer type
check-certificate – https certificate validation
dst-path –
duration –
host –
http-data – POST or PUT request body data
http-header-field – add http header fields
http-method –
keep-result – depracated, use ‘output’ argument
mode –
once –
output – where to output data, works for all protocols
password –
port –
src-address – source address for HTTP, HTTPS only
src-path –
upload – ftp and tftp transfer direction
user –
without-paging –


[admin@rb951 home] > tool fetch url=“https://api.telegram.org/bot5171614564:AAEJf0UpJpM68Axs-EGb4hPlx5twhtlf3ko/sendMessagechat_id=169231
9314&text=azoz”
status: failed

failure: closing connection: <404 Not Found> 149.154.167.220:443 (4)
[admin@rb951 home] >

:frowning: :frowning: :frowning: :frowning: :frowning: :frowning: :frowning: :frowning: :frowning: :frowning:

Try other solutions already posted on the forum http://forum.mikrotik.com/t/tlgrm-combined-notifications-script-launch-of-commands/155702/5

Wow normis, that is a lot of code for a simple api call :slight_smile:

TS, this works fine:

/tool fetch url="https://api.telegram.org/bot123456789:abcdef/sendMessage?chat_id=123456789&text=testMsg" as-value output=user

note that the ? between sendMessage and chat_id is missing in your example.

My method in case it helps you.

First:
Buid module called “MyTGBotSendMessage” (is a simple script)

:local BotToken "XXXXXXXXXX:XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXX";
:local ChatID "XXXXXXXXX";
:local parseMode "HTML";
:local SendText $MessageText;
/tool fetch url="https://api.telegram.org/bot$BotToken/sendMessage\?chat_id=$ChatID&parse_mode=$parseMode&text=$SendText" keep-result=no;
:log info "Send Telegram message";

Second:
Module inside each script

# START Send Telegram Module
:local DeviceName [/system identity get name]
:local MessageText "\E2\9A\A0 $DeviceName: <Text or variables to send to telegram>";
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]]; 
$SendTelegramMessage MessageText=$MessageText;
# END Send Telegram Module

Good luck!

quite useful, thank you.

Also you can check videos of this guy https://www.youtube.com/c/ErionDemiri