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)
- Open Telegram, create new group, add new human member.
- Search @BotFather in Telegram search column.
- Type /start to BotFather, wait for his reply.
- Type /newbot, then give your bot a name.
- Look for token HTTP API in BotFather message. Paste the token in your favorite text editor. Mine is 6342848463:AAG04h_yVRK9s7plReAWRDgFVGXsiBfVnEI
- Add your bot to the group you created in step 1.
- 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.
- 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.
- As admin or root, login to your Mikrotik via Winbox.
- 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
- 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