I've dabbled with Telegram in the past and heard good things, so I thought I'd give it another go. The API is a lot more open than the previous instant messenger I was using (Google Hangouts) so I wondered to how 'hackable' it was. After some research I stumbled upon the ability to send notifications from Tasker (A 'scripting' type app for Android) to Telegram
Click 'read more' to see how to get Tasker to send notifications to Telegram
It's assumed you already have Telegram and Tasker installed, and you have some idea of how to use both. The instructions below are for getting things setup on Android. As Tasker is only available on Android, this shouldn't cause any issues.
Setting up 'BotFather'
BotFather is a tool for setting up your own bot. First of all you will need to send the bot a message by sending a message to @BotFather and then pressing start, which will then reply with a list of instructions-
Then enter the following to create the new bot-
You will then get prompted to set the name. You can set it to anything-
You will then get promoted to set the username of your bot. It must be unique. You will then get some helpful information, and the API key. You'll need this!-
Creating a channel for notifications
Your bot can only send notifications to a channel. Initially you must configure it to be 'Public' but we can change this later.
Create the channel by clicking on the 'settings' icon in the top right corner on your home page, and then selecting 'New Channel'. You will then be prompted to enter a name, and optional description. Click the tick, and then select 'Public Channel' and enter a suitable link-
You will then get prompted to add members. Skip this and go to your newly created channel. Click the channel name at the top and then Administrators, and search for your newly created Bot. Select the bot, and click 'Ok' when prompted if you want to make the Bot an Administrator-
Testing the bot
It's possible to check the bot is working using curl. The format is below-
For my example this should look like the below-
Which should return the following. Make a note of the 'id' including the hypen if there is one-
And you should see the message in Telegram-
Making the channel private
Now you have the chat id, we can make the channel private, by clicking the 'settings' icon in the top right corner, then edit > channel type > private -
Now retest the bot with curl, this time using a chat id instead of the channel name-
You should see the message appear in the now private channel-
Sending messages from Tasker to Telegram
Add a new Task and give it a Name-
Then add an 'action' and click on 'Variables' > 'Variable Set'
Fill in the action as per below-
It should then look something like this-
Then add a new action, click 'Net', and then 'HTTP Post'-
Fill it in with the details below, remembering to update your Key and Channel ID-
Once the task is completed you should have something that resembles the following-
You can then press the 'Play' button in the bottom left corner to test your Telegram message.
And that's all there is too it. You can now add custom Tasker profiles to trigger notifications to Telegram. I use them to let my Wife know when I'm on my way home, or when my mobile battery is running out, but I'm sure I will think of more uses in the future