How to Connect Telegram with PRTG for Notification Alerts

From wiki.baghirzade.pro
Jump to navigation Jump to search

Step 1: Create a Telegram Bot

  1. Open BotFather in Telegram.
  2. Type /start and send. (Screenshot 1)
  3. Type /newbot to create a new bot.
  4. Choose a name for your bot (e.g., azsmart_bot).
  5. Choose a username ending with _bot (e.g., azsmartm_bot).
Screenshot 1

Step 2: Configure Bot Settings

  1. Use /help to see available commands.
  2. Set the bot's description using /setdescription. (Screenshot 1)
  3. Add an about section with /setabouttext (e.g., Hello Admin).
  4. Optionally, set a profile picture using /setuserpic.
Schreenshot 2

Step 3: Get the HTTP API Token

  1. After creating the bot, you will receive an HTTP API Token. (Screenshot 2)
  2. Copy the API Token (e.g., 8111611674:AAGW9ylV8qj0OV2ehmezV_kB6Qv8ICjRoak).
Schreenshot 3




Step 4: Test the Bot

  1. Open a browser and use the following URL:
https://api.telegram.org/bot<API-access-token>/getUpdates?offset=0

2.Replace <API-access-token> with your token:

https://api.telegram.org/bot8111611674:AAGW9ylV8qj0OV2ehmezV_kB6Qv8ICjRoak/getUpdates?offset=0

3. Find the chat_id in the response (e.g., 6294319603). (Screenshot 3)

Step 5: Send a Test Message

  1. To send a test message to your bot:
https://api.telegram.org/bot<API-access-token>/sendMessage?chat_id=<chat_id>&text=Hello

2. Replace <API-access-token> and <chat_id> with your data:

https://api.telegram.org/bot8111611674:AAGW9ylV8qj0OV2ehmezV_kB6Qv8ICjRoak/sendMessage?chat_id=6294319603&text=Hello

Step 6: Create a Group and Add Bots

  1. Create a Telegram group.
  2. Add your bot and the IDBot to the group.
  3. Promote both to Admin.
  4. Use GetIDsBot to retrieve the group ID.

Step 7: Send a Message to the Group

  1. Use the following link to send a message:
https://api.telegram.org/bot<API-access-token>/sendMessage?chat_id=<group_id>&text=Hello

2. Replace <group_id> with the ID you received.

Step 8: Configure PRTG for Telegram Alerts

Screenshot 4
  1. Go to Setup → Notification Templates → Add Notification Template. (Screenshot 4)
  2. Configure the notification as follows:
  • URL: https://api.telegram.org/bot<API-access-token>/sendMessage
  • HTTP Method: POST
  • Payload:
chat_id=-4794387273&text=
There’s a *%status* sensor in your PRTG!
[%sensor](%linksensor)*Device* %device
*Last Message* %lastmessage
*Down since* %since
*Group* %group
*%down*&parse_mode=Markdown

3. Test the notification to ensure it is working correctly.

Final Step: Test and Monitor

  1. Test the configuration by triggering a PRTG sensor alert.
  2. Verify that the message is sent to your Telegram group.