Telegram Notifications

This post will provide instructions on how to get NodePing notifications via Telegram using NodePing Webhooks and Telegram Bots.  Webhooks are available in our Business and Provider plans.

The Telegram Bot system is very useful for integrating with Telegram. Nodeping webhooks work seamlessly with the Telegram Bot to send ‘down’ and ‘up’ notifications. It’s a great alternative to SMS that is also cross-platform.

First, you will need to set up a Telegram account for yourself if you haven’t already. This can be done by getting the app on your mobile device or computer (there are Windows/macOS/Linux clients, as well as unofficially supported for FreeBSD). A working phone number will be required to set up an account.

Next, you need to create your own Telegram Bot.  To do this, you’ll have to to chat with Telegram’s own BotFather (a bot that creates other bots – the end is nigh!) You can find it by typing “@BotFather” into the user search bar in Telegram. Once you have started a chat with it, you will be prompted with a message from the BotFather.

Create your own bot by simply typing “/newbot” and following the instructions that are given. Here is a screenshot of what setting up a new bot setup looks like:

That long token is important.

Now that you have your new Telegram Bot and token, you’ll need to get the ChatID for the user or channel you want to send notifications to. This can be done by starting a chat with your new bot inside Telegram. You would start the chat like you did with BotFather, by typing in @nameofyourbot followed by sending “/start” to the bot. With that done, you can get the ChatID by visting the URL that shows your bot’s updates.  That URL will look like:

https://api.telegram.org/bot<your-secret-bot-token>/getUpdates

Plop that in your browser and you’ll get back some text – JSON formatted text.

The reply is the updates for your Telegram bot, which should only include the chat your telegram user started with the bot a few seconds ago. Look through the JSON response for the ChatID. It will be a random looking number thing.

Now that you have the ChatID, you’ll need to configure a new Webhook in NodePing. Log in and go to the Contacts tab. Add a new contact and give it a name – like “Telegram Bot”. Select the “Webhook” notification type and change the action to “POST”. Enter the following value in the URL field (replacing <your-secret-bot-token> with… you know, your bot token):

https://api.telegram.org/bot<your-secret-bot-token>/sendMessage

Next, in the Headers section add a new key called “Content-Type” and the value of “application/json”. It should look like this:

Then click on the the Body section.  In the text area, you need to add the following JSON.

{“chat_id”:<your-ChatID>,”text”:”NodePing: – {label}: {type} is {event}”}

Then save your newly minted webhook.  It’s ready to be added to the notification section of your checks.

Now you can receive NodePing notifications via Telegram!

Your alerts will look something like this.

Telegram bots have a lot more functionality that you can read about.  NodePing webhooks can also do a lot more, like templating and conditional statements, which you can read about.

If you need help getting things working right, please let us know at support@nodeping.com.  If you don’t yet have a NodePing account, please sign up for our free 15-day trial.

About NodePing
Server monitoring for the masses.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: