Use a Telegram Bot to receive data from a Thingspeak channel

Use a Telegram Bot to receive data from a Thingspeak channel

Python + Botfather

Use a Telegram Bot to receive data from a Thingspeak channel

Lately I've been playing around Telegram and its infinite functions, as, the very interesting one of the Bots.
Having, in the past, linked an Arduino UNO to a Thingspeak channel, I wanted to write a script on my RPI Zero to program a Telegram Bot to allow it to respond some simple commands. 
Not finding any guide around (or at least that I seen) I decided to post a little guide on my own here.


  • That you have a Public or Private channel on Thingspeak where to retrieve data from.
  • That you have a machine where Python 3 runs Ex RPI

What You Need: 

  • A Telegram Account and a Bot on it
  • Thingspeak Account
  • Raspberry Pi 

To create a bot you'll need to add "@BotFather" to Telegram and send him a message "/newbot", once all data needed is inserted (it is very easy just follow BotFather's instructions) he will send a message with the TOKEN of your Bot in it, select it and copy as we will need this later.

For a more accurate guide on the creation of a bot follow this guide clicking here.


Let's Write The Script

Being Telegram open source it is possible to access the API from this link.
As previously mentioned Python will come in my support for this task, there are a lot of modules around the web which allows you to simplify the job, in this case Telepot (Github o Official Site) is the one used which make it very simple to build a bot. 

The following is the code:

I'm not going explain more about the code as I tried to comment as much I could in the code, trying to keep it dry too.

Save the script in a local folder with the extension .py open it with IDLE paste your Bot TOKEN and the link to a Thingspeak channel and finally modify your Menu inline, save it and run it in a Python Shell.

Bot in action


The possibilities are infinite with the Telegram Bots, a search on Google will show you all the available modules for the creation of a Bot.
At the above script we could add few automatic functions which react to the data received so to automate other things via chat!  

I Know, I know is not the best but it works!

I hope you enjoyed the post if you have questions just write a comment below!

And Dont Forget To Subscribe!😇

A noob like me


  1. This comment has been removed by a blog administrator.


Post a comment

Potrebbe interessarti anche:

Show Temperate and Humidity on an OLED screen 128x64 pi

Control a Relay with Arduino according to the Temperature

Build a DIY IR Remote Controlled Arduino Lego Car

Home Made Weather station with Arduino