Create Telegram Bots for Mikrotik

One day in April 2024, my boss told me to create a bunch of Telegram Bots so he could check the network right from Telegram without the need to log in to Mikrotik.

Requirements:
1. Admin privilege on Mikrotik.
2. Telegram Desktop
3. Browser (duh)

Read more: Create Telegram Bots for Mikrotik
  1. Open Telegram, create new group, add new human member.
  2. Search @BotFather in Telegram search column.
  3. Type /start to BotFather, wait for his reply.
  4. Type /newbot, then give your bot a name.
  5. Look for token HTTP API in BotFather message. Paste the token in your favorite text editor. Mine is 6342848463:AAG04h_yVRK9s7plReAWRDgFVGXsiBfVnEI
  6. Add your bot to the group you created in step 1.
  7. It’s time to find out your group chat id. Use this template and adjust it to your token in step 5: https://api.telegram.org/bot(TOKEN_BOT)/getUpdates. Mine is https://api.telegram.org/bot6342848463:AAG04h_yVRK9s7plReAWRDgFVGXsiBfVnEI/getUpdates. The paste that URL in your browser. Mine is -4179390964. The group chat id is always number with minus sign.
  8. You’re done on Telegram. It would be useful if you paste all those number in your favorite text editor. It’s time to move to Mikrotik.
  9. As admin or root, login to your Mikrotik via Winbox.
  10. Go to Tools —> Netwatch, click + sign (create new netwatch). Keep the default values on Interval and Timeout. On Host tab, type your server’s IP in Host column, then add this in Up tab: /tool fetch url=”https://api.telegram.org/bott6342848463:AAG04h_yVRK9s7plReAWRDgFVGXsiBfVnEI/sendMessage?chat_id=-4179390964&text=Server One connect” keep-result=no
  11. On Down tab: /tool fetch url=”https://api.telegram.org/bott6342848463:AAG04h_yVRK9s7plReAWRDgFVGXsiBfVnEI/sendMessage?chat_id=-4179390964&text=Server One down” keep-result=no

References:
https://citraweb.com/artikel/401/
https://core.telegram.org/bots/api
https://www.reddit.com/r/TelegramBots/comments/7px8o4/bot_not_sending_messages_in_group_chat_or_channel/?rdt=47857

Work till death do me part.

Leave a Reply