Telegram Bot API &how to use it?

Ever thought of connecting your IoT device to social media platforms like Facebook, Instagram, Twitter, etc, and wondering how to do it?? Let’s find out below!

(Source:https://unsplash.com/photos/fNMRpUnInH8)

IoT has already captured the business and economic world with its tremendous application. It’s almost in use by every company we see today to improve their marketing strategy.

We may wonder that social media marketing was in practice for over a decade now, marketers have been using these platforms at their best to launch and publicize a product. So what’s new in it??

The answer is yes, social media marketing has been in use for a long time, but IoT has added a new edge to these platforms. Here’s how!!

  •  IoT has redefined social media strategies by focusing more on individual preferences and personal needs.
  • When you notice your social media profiles carefully, you will get advertisements of your preferences which you are most likely to buy.
  • As social media platforms have become more personalized due to the tracking and well-structured analysis of IoT, you get recommendations of products you like on e-commerce sites like Snapdeal, Flipkart, Amazon, etc

Hence we can now surely say that IoT has captured and will be capturing all the possible industries in a few coming years.

Having seen the uses of IoT being connect up to such platforms, Let’s try our hands on one such platform “TELEGRAM”.

WHAT IS TELEGRAM?

Telegram is a messaging app similar to WhatsApp where we can exchange messages and files. It can access via IOS/Android/Windows phone or also your PC.

(Source:https://pixabay.com/illustrations/telegram-app-logo-icon-application-5662082/)

SOME TELEGRAM TERMINOLOGIES

What is a telegram channel?

Channel in telegram is similar to groups in WhatsApp. It is a way of broadcasting your message to a large number of people. These channels can be make public with an unlimited number of people joining the group(subscribing to the channel).

What is the Bot?

Bots are the third party application which runs inside telegram. Users can interact with Bots by sending requests, commands, messages. Bots help send the alert message on our channel.

Requirements to set-up Telegram Bot API!

  • An Android/iOS/Windows phone with internet connectivity.
  • A Telegram account.
  • Access to Ubuntu OS via puTTY or virtual machine.

SET-UP TELEGRAM for Telegram Bot API

  •  Go to the play store and install the Telegram application.
  • Create an account on Telegram for Telegram Bot API.
  • Verify your account.

To demonstrate the work, I will be considering a small project to measure the intensity of light for a particular range. If this limit exceeds, it will send the alert on our channel! Sounds interesting?? Let’s get started.

CREATE A CHANNEL

Below are the steps to create a channel

  • Open home screen of Telegram app.
  • Click on the top left icon, or just swipe left.
  • Find the option of New channel. Click on that.

Give the name and description of your channel. You can give the name and describe it according to the project required. Click on (✔ ) which is present in the top right corner.

In the next slide make the channel public. You have also been asked to give a permanent link to your channel(Link name is global, and hence it should be unique. You will be able to create it only if the given name is available). The name must be lowercase and numbers can be added from 0-9.                               

Keep a note of your channel’s permanent link. The channel name in the below screenshot is “light-sensor”.

Yay!! You have created your first channel.

HOW WILL ALERT MESSAGE REACH US?

Telegram is an application used for messaging. It has a third-party interference Bot that helps executes our request.

 So, if we want to send a message to our channel, we need to request a telegram to instruct the Telegram Bot API to send the message.

API KEYS

API stands for- Application Programming Interface Keys. It is a unique key used to authenticate a user. In simple words, it is used to identify a user or calling application. These are used for security purposes.

CODE!

Below are the images of the code written in python and ran on the Ubuntu operating system via virtual box.

 HOPE YOU FOUND THIS ARTICLE USEFUL. HAPPY READING!!!

Written By: Apeksha Bagrecha

Reviewed By: Vishal Rathod

If you are Interested In Machine Learning You Can Check Machine Learning Internship Program
Also Check Other Technical And Non Technical Internship Programs

Leave a Comment

Your email address will not be published. Required fields are marked *