Basic Concept of Telegram Bot API

Telegram is one of the best chat application in 2019. Its stability, reliability, and server-based chat data makes everything works very seamlessly in everyday use. More interestingly, there is an API to work with Telegram bot, so that we can make a very powerful bot to help us create many beneficial things, like sending report automatically, setting parameters via bot, and sending a broadcast message to users.

In this article, I will tell you the basic concept of telegram bot. Currently, two of the most popular event management tools in telegram bot are Long Polling and Webhook. These two methods are explained in telegram official website, but I will simplify the explanation in the hope of you guys can understand the basic principles better.

1. Long Polling

The concept of polling is very simple: your server continuously checking at a predetermined frequency (e. g : every 2 seconds) to check if there is someone sending a chat to your bot. If the result is empty, then you can simply do nothing. Otherwise, you will get an array of request data, such as chat id, sender id, group id (if chat is sent via group), the raw text sent by user, timestamp, and so on. Afterwards, the data is yours. You can process is and then reply to the chat based on chat id.

Telegram Bot Long Polling Concept

This method is very simple, yet requires continuous checking and creates more delay between request and response of the bot. Moreover, if the internet connection is unstable, your scheduler can pile up and creates a heavy load to the server. Therefore, Telegram BOT api provides second option which is more efficient for servers.

2. Webhook

Unlike long polling, webhook relies on speed and reliability. Using webhook, we don’t need to check every predetermined frequency whether or not there is someone chatting our bot. Instead, we only have to place our code in our hosted network, register the link to Telegram with our bot token code, so that whenever someone chats our bot, Telegram will send it to the webhook link we provided before. This is somehow a passive approach, but more efficient and doesn’t consume a lot of internet bandwidth.

Telegram Bot Webhook Concept

The downside is that we have to provide a hosted site and technically we can not put our code in non hosted local server. But if you really want to use webhook and you don’t have a hosted website, there is a workaround using ngrok. I will make a separate post about this later on.

So that’s it about basic concept of Telegram bot API. For more technical details about how to make a Telegram bot, I will make a post about this in a few days.

368 comments

  1. Political News

    Great write-up, I am normal visitor of one’s web site, maintain up the nice operate, and It is going to be a regular visitor for a lengthy time.

  2. Business News

    Excellent site. A lot of useful information here. I am sending it to a few friends ans additionally sharing in delicious. And obviously, thank you on your sweat!

  3. Trinh Bisel

    Confira as Ofertas do Dia, Ofertas Relâmpago, Melhores Ofertas e outras Ofertas com tempo limitado da Amazon.com.br

  4. Jesusita Bradford

    Confira as Ofertas do Dia, Ofertas Relâmpago, Melhores Ofertas e outras Ofertas com tempo limitado da Amazon.com.br

  5. Onion Exporters in Nashik

    Hi! I’ve been following your weblog for some time now and finally got the courage to go ahead and give you a shout out from New Caney Texas! Just wanted to mention keep up the fantastic job!

  6. Annelle Dejoseph

    I’m extremely impressed with your writing skills neatly as with the format on your blog. Is this a paid subject matter or did you customize it yourself? Anyway keep up the nice high quality writing, it is uncommon to peer a nice blog like this one nowadays.

  7. cbd gummies florida

    Good Morning everybody ! can anyone advise where I can buy Boost CBD Gel Capsule 1000mg By Select?

  8. Bula Charan

    Some times its a pain in the ass to read what blog owners wrote but this internet site is really user genial ! .

Leave a Reply

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