Sending telegram bot message

An example for sending a group or a single private message using a telegram bot.

:do { 
	:local telegramBotToken "xxxxxxxxx:secondpartOfTheToken";
	:local destination "Number";
	:local requestUrl "https://api.telegram.org/bot$telegramBotToken/sendMessage";
	:local httpData "{\"chat_id\": \"$destination\", \"text\": \"This is a test from fetch\"}";
	/tool fetch url=$requestUrl http-data=$httpData http-header-field=content-type:application/json http-method=post  keep-result=no
} on-error={
	/log info "finished with error";
}
/log info "finished";

Another example

/tool fetch "https://api.telegram.org/bot<yourtokencode>/sendMessage\?chat_id=<botcode>&text=Router"

Note: Any spaces in the text portion of the URL, the message you wish to send should contain no gaps.
Use the ‘+’ symbol for spaces!!

You can add time for example.

:local sub1 ([/system clock get time])
:local sub2 ([/system clock get date])
/tool fetch "https://api.telegram.org/bot<yourtokencode>/sendMessage\?chat_id=<botcode>&text=Router+went+offline+at+@sub1+on+$sub2"

QUESTION: How do I also use keep-result=no in the script, as is done in the first example? I tried it after the word fetch and at the end after the last entry, neither worked and both prevented the script from working.

As I stated before… A message from an offline router…

This script works well for me for internal interfaces at the moment and for system/cpu temperature and if you go to my other thread, trying to do so for UPS log entry!
http://forum.mikrotik.com/t/get-log-line-from-memory-log/147720/5

The one thing I would like to add from the first example to my script is this
How do I also use keep-result=no in the script, as is done in the first example? I tried it after the word fetch and at the end after the last entry sub2" - neither worked and both prevented the script from working.

I use this statement to send Telegrams with that option included:

:local botId "7217xxxxxxxx"
:local chatId "yyyyyyyy"
:local site [/system identity get value-name=name]

/tool fetch url="https://api.telegram.org/bot$botId/sendMessage?chat_id=$chatId&text=MikroTik $site info:%0AIPSec phase2 error" keep-result=no

So the url is quoted and after that I use the option keep-result and it simply works

paste here the whole script.
I cannot say anything without understanding what you are doing.

Hello

I am a new user here. So please forgive me if im posting in the wrong topic / section but:
I have a set of servers behind my Mikrotik RB2011UiAS-2HnD-IN. On top of that i have UPS with USB connection.
I would like to connect the UPS to the Mikrotik and when there is battery critical (low) event then the RouterOs will send pakets to all the servers informing them to shutdown gracefully and when power is back on mains, send them wake-on-lan magic packets.

I do know about Mikrotik UPS package however its functionality is pretty limited.
Any suggestions / help is more than welcome.
Also i do not know about scripting in RouterOS - maybe some good articles / tutorials would also help a lot.
(I am a programmer by profession).

Many thanks in advance for any guidance provided!