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.

2.910 comments

  1. hair dye with coffee

    Sereni Capelli An exceptional product. PRO: I don’t have
    white hair anymore and it doesn’t wash. It leaves no traces like paint and
    is easy to apply.

  2. Psychiatry

    Title

    […]very few internet sites that take place to become in depth beneath, from our point of view are undoubtedly very well worth checking out[…]

  3. カジノシークレット 入金

    Thank you for the good writeup. It in fact was a amusement
    account it. Look advanced to more added agreeable from
    you! However, how could we communicate?

  4. 샌즈카지노

    Good day very nice blog!! Guy .. Excellent .. Amazing
    .. I’ll bookmark your web site and take the feeds additionally?

    I’m satisfied to seek out so many useful info right here in the
    post, we want develop extra strategies in this regard, thank you for sharing.

    . . . . .

  5. women in tight booty shorts

    I think this is among the most important info for me.

    And i am glad studying your article. But should remark on some general things, The web site taste is wonderful, the articles is truly nice :
    D. Good activity, cheers

  6. uh library database

    Hi there! Quick question that’s completely off topic.
    Do you know how to make your site mobile friendly?
    My weblog looks weird when viewing from my iphone. I’m trying to
    find a template or plugin that might be able to resolve this issue.

    If you have any recommendations, please share. Thanks!

  7. 퍼스트카지노

    Hey there! This is my first visit to your blog! We are a team
    of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us useful information to work on. You have done a marvellous job!

  8. glysolid cream

    Title

    […]although internet sites we backlink to below are considerably not connected to ours, we feel they are actually worth a go by means of, so possess a look[…]

  9. 원엑스벳

    It’s going to be finish of mine day, however before finish I am reading this enormous article to improve my knowledge.

  10. garden accessories

    Really when someone doesn’t know after that its up to other visitors that
    they will help, so here it happens.

  11. cialis 60

    buy cialis online cheap

    viagra cialis levitra

  12. โปรสล็อต

    Do you have a spam problem on this website; I also am a blogger, and I was wondering your situation; many of us have developed some nice practices and we are looking to trade strategies
    with other folks, please shoot me an email if interested.

  13. Alba

    Hmm is anyone else having problems with the pictures on this blog loading?

    I’m trying to find out if its a problem on my end or if it’s the
    blog. Any suggestions would be greatly appreciated.

  14. インター カジノ 入金 ボーナス

    Do you mind if I quote a few of your articles as long as I provide credit and sources back to your site?
    My blog is in the very same niche as yours and my visitors would really
    benefit from a lot of the information you present here.
    Please let me know if this ok with you. Many thanks!

  15. para kazanma yollari

    Title

    […]The facts talked about inside the post are a number of the top accessible […]

  16. Pool Supply

    Title

    […]very couple of web sites that take place to become detailed beneath, from our point of view are undoubtedly very well really worth checking out[…]

  17. childrens curtains for bedroom

    Hi just wanted to give you a brief heads
    up and let you know a few of the images aren’t loading properly.
    I’m not sure why but I think its a linking issue.
    I’ve tried it in two different browsers and both show the same outcome.

  18. jobsinmysore

    Title

    […]that will be the end of this post. Here you will come across some websites that we feel you will appreciate, just click the links over[…]

  19. v9bet

    I’ve learn sߋme ցood stuff here. Definitely worth bookmarking foг revisiting.
    І wοnder how so much effort ʏou set to maҝe one
    of these excellent informative web site.

  20. v9bet

    This page truly has all of the informɑtion I neeⅾeԁ aЬout this subject аnd ɗidn’t know
    whо tߋ ask.

  21. best gifts for her amazon

    Title

    […]please go to the websites we follow, like this a single, as it represents our picks in the web[…]

  22. Windows POS

    Title

    […]Wonderful story, reckoned we could combine a couple of unrelated data, nonetheless truly worth taking a look, whoa did one learn about Mid East has got extra problerms as well […]

  23. golden hoyeah slots

    Wow, incredible blog layout! How long have you been blogging
    for? you made blogging look easy. The overall look of your web site is great, as well
    as the content!

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *