You can connect the PRTG Network Monitor to a Telegram bot to create notifications sent to a group when Mikrotik devices go down or back up. PRTG will monitor your devices, and when it detects a change in the device status, it will trigger notifications to be sent to the group via Telegram. This guide will show you how to create notifications sent to the Telegram group when devices are down and up.
Here’s how you can set this up:
Prerequisites
- PRTG Network Monitor is installed and configured to monitor your Mikrotik devices.
- A Telegram Bot was created (you can create one using BotFather on Telegram).
- The Telegram Group or Channel ID where you want to receive notifications.
Step 1: Create a Telegram Bot
- Open Telegram and search for BotFather.
- Start a chat with BotFather and create a new bot by using the command
/newbot.
This is the first step in how to create notifications sent to the Telegram group when devices are down and up. - Follow the prompts to give your bot a name and a username.
- After creating the bot, BotFather will give you a bot token (a string that looks like
123456789:ABCDEF1234ghIkl-zyx57W2v1u123ew11
).
Step 2: Get the Telegram Group ID
- Add the bot to the Telegram group where you want to send the notifications.
- Use this API call to get the Group ID:
- Send a message to the group and retrieve the ID by visiting the URL below in your browser:
https://api.telegram.org/bot
. Gathering the proper Group ID is critical for how to create notifications sent to the Telegram group when devices are down and up./getUpdates - Replace with the token from BotFather.
- Look for
"chat": {"id": -123456789}
in the response. The number with a negative sign is your Group ID (e.g.,-123456789
).
Step 3: Set Up Notifications in PRTG
- Log into your PRTG instance and go to Setup > Account Settings > Notification Templates.
- Click Add Notification Template to create a new template for your Telegram alerts.
- Name the template (e.g., Telegram Device Status Alert).
- Under Send HTTP Request settings:
- URL: Use the Telegram Bot API with the following URL:
https://api.telegram.org/bot
/sendMessage - Replace with the token you got from BotFather.
- Request Type: Set this to
POST
. - Content-Type: Set this to
application/x-www-form-urlencoded
. - POST Data: Here’s where you set the data to be sent in each notification:
chat_id=-123456789&text=Device %device with IP %deviceip is now %status
- Replace
-123456789
with your Group ID. %device
,%deviceip
, and%status
PRTG placeholders will dynamically display the device name, IP address, and current status (up or down).
- Replace
Step 4: Configure the Notification Triggers
- In PRTG, go to the device or sensor for your Mikrotik routers.
- Under Notification Triggers, set a new trigger for the State:
- When the sensor state is: Down and up.
- Latency: Optional, depending on how quickly you want the alert sent.
- Notification Template: Select the Telegram template you created.
- This will ensure how to create notifications sent to the Telegram group when devices are down and up without missing any states.
Step 5: Test the Setup
- Manually take down a device or simulate a failure to see if you receive a notification in your Telegram group.
- When the device returns online, PRTG should also send an “up” notification.
With this setup, PRTG will notify your Telegram group whenever a monitored Mikrotik device goes down or comes back up, effectively showing you how to create notifications sent to the Telegram group when devices are down and up.
Discover more from How To Got
Subscribe to get the latest posts sent to your email.