Telegram Your Devices

[Erhan] has been playing around with the Telegram instant messaging service. Initially, he worked out how to turn on and off LEDs from his cell phone: he sent commands from the phone through the Telegram bot API, to a computer that’s connected over serial to an MSP430 board that actually controlled the LEDs.

But that’s a little bit complicated. Better to cut out the middleman (err…microcontroller) and implement the Telegram reception and LED blinking on a Raspberry Pi. For a project that’s already using a Pi, using the instant messaging service’s resources is a very simple way to interface to a cellphone.

The code for both the standalone RPi project and the MSP430-based microcontroller application are available at [Erhan]’s GitHub. You’re going to be installing Node.js for their telegram-bot-api and jumping through the usual OAuth hoops to get your bot registered with Telegram. But once you’ve done that all on the Raspberry Pi (or target computer of your choice) it’s all just a few lines of fairly high-level code.

We’ve only seen one other Telegram application on Hackaday.io and we’re wondering why. It looks pretty slick, and with the bot’s ability to send a custom “keyboard” to the phone along with the message, it could make cell-phone-based control interfaces a cinch. Anyone else using Telegram for bots?

18 thoughts on “Telegram Your Devices

  1. The answer to the question at the end of this post is it’s simply not needed and a lot of overhead if you are using other platforms. My Particle Photon can just initiate and receive web calls to any service without being physically connected to a computer. The Particle Electron can do it over cellular networks. It’s very quick and simple to create something like this. App and website integration can be done via a rest call.

    1. I agree, without the need to consider Telegram’s worth, I’d also say that for many tasks nodemcu on an ESP gives you all of the functionality that many projects need. Storage is not an issue either, or even computational power because the scripts and resources the client needs can be on a web server and the heavy lifting can be done on the client too, with the nodemcu server just providing and receiving the encrypted parameters for those scripts running on the client.

      However if you need to punch through firewalls, cross multiple network types and or need message caching, group communications etc. then Telegram may be appropriate.

        1. And by fixed keys I meant fixed certs as only the computer connecting needs to be trusted without any CA. At least is I understood right, I’m not a security expert and therefore I don’t want to make a new implementation.

          1. How much data traffic will you have? Assuming you are just transmitting tag and variable pairs. i.e. setX:YY GetX:

            Do you need to push a notification at the client, or can the client regularly interrogate your project for a status change in a variable? That status does not need to be secured, it is just a flag that says a buffer is not empty, the transmission of the buffered variables would be secured.

            How important is security? What level do you need? I ask because absolutely unbreakable security with very little computational overhead is possible even on an AVR level project, for the price of the storage (SD card) required for a 1 time pad and if you are prepared to compromise that to a certain degree you can reuse the pad data via a random walk and a shared seed value.

            If none of the above makes a lot of sense to you then perhaps you should just go with using the higher level APIs that Telegram offers you.

  2. I’ve set up a telegram bot on my server to monitor it, i can send command such “Free Ram” to receive a message containing ram informations, also disk space usage, process list, uptime, vnc server start & stop, reboot and other, bot replies only to me. On raspberry i’ve added commands like “picture” or “video” associated with the output of a usb web cam, supporting v4l, recycled from an old portable computer. Everythings is easy to get working thanks to python and subprocess & telepot modules.

  3. For these purposes you should really look into the ‘keyboards’ feature of a bot. It allows your bot to send custom keyboards (for example with a whole menu structure) to your smart phone. No more typing, just tapping the right buttons.

    I quite liked the API when I was playing with it. I’d just like that the Telegram server could prevent access for random people to my bot.

Leave a Reply to Dan#734348956945785Cancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.