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.

1,091 comments

  1. 카지노사이트

    Hello friends, how is all, and what you want to say regarding this piece of writing, in my view its in fact awesome for me.

  2. link m88 mới nhất 2020

    Genuinely when someone doesn’t be aware of afterward its up to other viewers that they will help, so here it occurs.

  3. BJ

    Its not my first time to visit this web page, i am visiting this web page dailly and obtain good data from here everyday.

  4. ポーカー

    I love your blog.. very nice colors & theme. Did you create this website yourself or did
    you hire someone to do it for you? Plz reply as I’m looking to design my own blog and would like to know where
    u got this from. thanks

  5. 국산신작

    Somebody essentially lend a hand to make seriously posts I’d state.
    That is the first time I frequented your website page and
    up to now? I amazed with the research you made to make this actual submit amazing.
    Fantastic task!

  6. 우리카지노

    I know this if off topic but I’m looking into starting
    my own weblog and was curious what all is required to
    get set up? I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very internet savvy so I’m not 100% sure. Any tips or advice would
    be greatly appreciated. Thanks

  7. Barry Schaumberg

    My partner and I really like your blog and find Nearly all of your article’s for being precisely what I’m on the lookout for. is it possible to give visitor writers to write articles for you? I wouldn’t head producing a put up or elaborating on some the subjects you publish relating to here. Once more, wonderful weblog!

  8. 우리카지노

    Hi my friend! I want to say that this article is awesome,
    great written and include almost all significant infos.
    I would like to see more posts like this .

  9. カスモカジノ

    Hello! This is my first visit to your blog!
    We are a group of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us valuable information to work on. You have done a extraordinary job!

  10. ป๊อกเด้ง

    Hi there, just wanted to tell you, I enjoyed this article.
    It was helpful. Keep on posting!

  11. 일본신작

    I believe this is one of the so much important information for me.
    And i am satisfied studying your article.
    But should statement on some general issues, The website taste
    is perfect, the articles is in point of fact great : D.
    Good activity, cheers

  12. ‎ベラジョン イカサマ

    After exploring a few of the blog posts on your website, I truly appreciate your way of blogging.

    I book marked it to my bookmark website list and will be
    checking back soon. Please check out my web site too and tell me what you think.

  13. 에비앙카지노

    Howdy, I do believe your blog could be having internet browser compatibility issues.
    Whenever I take a look at your website in Safari, it
    looks fine however, when opening in IE, it’s got some overlapping issues.
    I just wanted to give you a quick heads up! Other than that,
    excellent blog!

  14. cách tính chi mậu binh

    I all the time used to read article in news papers but
    now as I am a user of web thus from now I am
    using net for articles, thanks to web.

  15. cialis powder for sale

    you’re truly a good webmaster. The site loading pace is amazing.
    It sort of feels that you are doing any distinctive trick.
    Furthermore, The contents are masterpiece. you’ve done a great activity in this topic! https://tadalafili.com/

  16. w88 casino

    Hi there! I know this is kinda off topic but I was wondering which blog platform are you using for this website?

    I’m getting sick and tired of WordPress because
    I’ve had issues with hackers and I’m looking at alternatives for another platform.
    I would be fantastic if you could point me in the direction of a good platform.

  17. chơi mậu binh

    Hi mates, its wonderful paragraph regarding cultureand completely explained, keep it
    up all the time.

  18. クイーンカジノ

    Every weekend i used to go to see this site, for the reason that
    i want enjoyment, for the reason that this this web site conations in fact pleasant funny stuff too.

  19. 카지노사이트

    I really like reading through a post that can make people think.
    Also, many thanks for allowing me to comment!

  20. 매춘

    Hey there! Quick question that’s entirely off topic.
    Do you know how to make your site mobile friendly? My site looks weird when viewing from my iphone 4.
    I’m trying to find a template or plugin that might be able to correct
    this issue. If you have any recommendations, please share.
    Appreciate it!

  21. Titanium Glasses

    Very nice article. I absolutely love this site. Continue the
    good work!

  22. ag bong88

    I’m gone to say to my little brother, that he should also go to see this blog on regular basis to obtain updated
    from most recent news update.

  23. ワイルドジャングル

    Thank you a bunch for sharing this with all folks you really understand
    what you are talking approximately! Bookmarked.
    Kindly also discuss with my website =). We can have a link change agreement between us

  24. 더킹 카지노

    Do you have any video of that? I’d want to find out more details.

  25. カジノ スロット

    First of all I would like to say excellent blog! I had
    a quick question that I’d like to ask if you don’t mind.
    I was curious to know how you center yourself and clear your head prior to writing.
    I have had trouble clearing my mind in getting my thoughts out.
    I do enjoy writing but it just seems like the first 10 to 15 minutes
    are wasted simply just trying to figure out how to begin. Any ideas
    or tips? Many thanks!

  26. 우리카지노

    I’m not sure where you are getting your info, but great topic.
    I needs to spend some time learning more or understanding more.

    Thanks for wonderful info I was looking for this information for
    my mission.

Leave a Reply

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