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.

3,401 comments

  1. 더킹카지노

    Excellent blog you have here but I was wanting to know if you knew of any community forums that cover the same topics talked
    about in this article? I’d really like to be a part of community where I can get
    responses from other knowledgeable individuals that share the same interest.
    If you have any recommendations, please let
    me know. Bless you!

  2. IIa2epm3U/MhF2fH6F1

    This design is spectacular! You obviously know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really loved what you had to say, and more than that,
    how you presented it. Too cool!

  3. poringa

    It’s actually very complex in this busy life to listen news on Television, therefore I just use internet for that reason,
    and obtain the hottest information.

  4. 빅카지노

    Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something.
    I think that you can do with some pics to drive the message home a bit,
    but other than that, this is fantastic blog. A fantastic read.

    I’ll certainly be back.

  5. 1xBet

    I have been browsing online more than 3 hours today, yet I never found
    any interesting article like yours. It is pretty
    worth enough for me. In my opinion, if all website owners and bloggers made good content as you did, the
    web will be a lot more useful than ever before.

  6. Casino Trực Tuyến

    Hi there, You’ve done a great job. I will definitely digg it and personally suggest to my
    friends. I am confident they will be benefited from this website.

  7. festool vacuum

    I blog quite often and I seriously thank you for your information. Your article has truly peaked my interest.
    I am going to bookmark your site and keep checking for new details about
    once per week. I opted in for your RSS feed as well.

  8. 카지노

    Excellent beat ! I would like to apprentice whilst you amend your site,
    how can i subscribe for a weblog website? The account helped me a acceptable deal.
    I had been a little bit acquainted of this your broadcast provided vibrant transparent concept

  9. slot 777

    You’ve made some really good points there. I checked on the
    net for more info about the issue and found
    most individuals will go along with your views on this site.

  10. underwater hotel

    You can certainly see your enthusiasm within the article you write.
    The world hopes for even more passionate writers like you who are not afraid to say how they believe.

    At all times follow your heart.

  11. bA7X5qG8uL6

    I am sure this piece of writing has touched all the internet viewers, its really
    really pleasant piece of writing on building up new blog.

Leave a Reply

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