Telegram Integration with Catchpoint Alert

Prev Next

Introduction

Telegram is a freeware, cross-platform, cloud-based instant messaging software and application service.

Catchpoint’s flexible alerting webhook feature can send alerts to Telegram.

Telegram Setup

  1. Open the Telegram Client
  2. Do a search for “BotFather” and select @BotFather
  3. Click on Start Conversation
    Tele_1.png
  4. Type in the following to create a new bot:
    /newbot
  5. Give the bot a name (in our example, CatchpointAlert is the name)
  6. Give the bot a unique username.
    NOTE: The username much end with “bot”. (In our example CatchpointAlert_bot is the name)
    tele_2.png
    Once the bot is created, you will get a token to access the Telegram API. The token is a string that is required to authorize the bot and send requests to the Telegram API, e.g. 4334584910:AAEPmjlh84N62Lv3jGWEgOftlxxAfMhB1gs**
    Capture this token as it will be needed when configuring Catchpoint.
  7. Start a conversation with the Bot by searching for the Bot name that was just created, and then enter the following. /start
    tele3.png
  8. Get the Chat ID by open the following URL in your web browser: https://api.telegram.org/bot<TOKEN>/getUpdates (replace <TOKEN> with your bot token)
    tele4.png

Catchpoint Setup

  1. Go into the Catchpoint portal and navigate to Settings > API
    api1.png
  2. Create an Alert Webhook entry.
  3. URLencode the token (Replace the semicolon “:” with “%3A”)
    For example, the URL: https://api.telegram.org/bot1363564166443:AAHHA3j8snFDw4ZmXN1FzYsipWKvmV4y7Kc/sendMessage
    becomes:
    https://api.telegram.org/bot1363564166443%3AAAHHA3j8snFDw4ZmXN1FzYsipWKvmV4y7Kc/sendMessage
  4. URL to be placed in the Alertwebhook on the Catchpoint portal will follow the below format. 
    https://api.telegram.org/bot<URL Encoded TOKEN>/sendMessage

In the Template put in Format as Text.

tele5.png

In the Template field, enter the $CHAT_ID and what you’d like to see in the message..

chat_id=$CHAT_ID text=’<your message>’

Here is an example template:

chat_id=<chat_ID>&text='
"Test Name [Test ID]": "${TestName} [${TestId}]",
"Test Information": [{
    "name": "Test Type",
    "value": "${switch("${testTypeId}","0","WEB","1","TRANSACTION","2","HTML      CODE","3","FTP","4","TCP","5","DNS","6","PING","7","SMTP","8","UDP","9","API","10","STREAMING","11","SSH","12","TRACEROUTE","13","WEBSOCKET")}"
    },
    { "name": "Monitor",
    "value": "${switch("${MonitorTypeId}","0","IE","2","OBJECT","18","CHROME","3","Emulated")}"
    }
],
"Notification Level":"${switch('${notificationLevelId}','0','warning','1','critical','2','recovery','3','recovery')}",
"timestamp":${AlertInitialTriggerDateUtcEpoch},
"Node(s) location": "${nodeDetails(${nodeName}, ) }",
"outage Information": "alert type is ${AlertType}. The URL is ${TestUrl}. waterfall URL is ${waterfallChartURL}"

Here is a list of Alert Macros you can use Alert Webhook Macro Index – Catchpoint Help

  • Next, click on Add API Header Request and input the following header.
    tele6.png

Content-Type : application/x-www-form-urlencoded
tele7.png

  • Click Save at the top of the page.

tele8.png

This will result in Alerts going into Telegram once Tests have been assigned the Telegram Alert Webhook.

tele9.png

Results

tele10.png