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,403 comments

  1. 원엑스벳

    Wow that was unusual. I just wrote an incredibly long comment but
    after I clicked submit my comment didn’t appear.
    Grrrr… well I’m not writing all that over again. Regardless,
    just wanted to say superb blog!

  2. カジノ ディーラー

    An outstanding share! I have just forwarded this onto
    a coworker who had been doing a little homework on this.
    And he actually bought me lunch simply because I stumbled upon it for him…
    lol. So let me reword this…. Thanks for the meal!!

    But yeah, thanks for spending some time to talk about this issue here on your web site.

  3. 솔레어카지노

    Pretty section of content. I just stumbled upon your site and
    in accession capital to assert that I get in fact enjoyed account your
    blog posts. Anyway I’ll be subscribing to your feeds and even I achievement you access consistently quickly.

  4. ネットカジノ

    Every weekend i used to visit this web page, as i want enjoyment,
    since this this web site conations in fact good funny stuff
    too.

  5. チェリー カジノ 入金 不要 ボーナス

    I’m really loving the theme/design of your weblog.
    Do you ever run into any web browser compatibility issues?
    A couple of my blog visitors have complained
    about my website not working correctly in Explorer but looks great in Opera.
    Do you have any ideas to help fix this problem?

  6. 더킹카지노

    Pretty element of content. I simply stumbled upon your web site and in accession capital to claim that I acquire actually
    loved account your weblog posts. Any way I’ll be subscribing for your feeds or even I success you get entry
    to constantly quickly.

  7. โหลด w88

    Excellent beat ! I would like to apprentice while you amend your website, how
    could i subscribe for a blog site? The account helped
    me a appropriate deal. I have been a little bit familiar
    of this your broadcast provided brilliant clear idea

  8. 카지노사이트

    May I simply just say what a relief to uncover somebody that really knows
    what they’re discussing on the net. You actually realize how to bring a problem to light and make it important.

    More and more people must read this and understand this side of your story.
    I was surprised that you are not more popular because you
    certainly have the gift.

  9. 빅카지노

    You really make it seem so easy with your presentation but I find this topic to be actually
    something that I think I would never understand.
    It seems too complex and very broad for me.
    I’m looking forward for your next post, I’ll try to get the hang of it!

  10. furniture keystone mall

    Pretty nice post. I just stumbled upon your blog and wished to say that I have truly enjoyed surfing around your blog posts.
    In any case I will be subscribing to your rss feed
    and I hope you write again soon!

  11. video poker

    Do you mind if I quote a few of your posts as long as I provide
    credit and sources back to your website? My website is in the exact same niche
    as yours and my users would truly benefit from some of the information you present here.
    Please let me know if this alright with you. Regards!

  12. 우리카지노

    Hi! I know this is kind of off topic but I was wondering if
    you knew where I could find a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having trouble finding one?
    Thanks a lot!

  13. royal panda app download

    Hello are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and create my
    own. Do you require any coding expertise
    to make your own blog? Any help would be greatly appreciated!

  14. สล็อต

    I need to to thank you for this fantastic read!! I definitely enjoyed every little bit of it.

    I have you book marked to check out new stuff you post…

  15. 007카지노

    When I initially commented I clicked the “Notify me when new comments are added” checkbox
    and now each time a comment is added I get four e-mails with the same comment.
    Is there any way you can remove me from that service?

    Thank you!

  16. Bwin

    With havin so much written content do you ever run into any problems of plagorism or copyright infringement?
    My site has a lot of unique content I’ve either written myself or outsourced but it seems a lot of it
    is popping it up all over the web without my authorization. Do you know any solutions
    to help reduce content from being ripped off? I’d genuinely appreciate it.

  17. vwin casino

    Excellent way of telling, and nice piece of writing to obtain facts regarding my presentation focus, which i am going to convey in university.

  18. 우리카지노

    I have read so many articles regarding the blogger lovers but this piece
    of writing is really a pleasant paragraph, keep
    it up.

  19. 빅카지노

    Its such as you read my mind! You seem to understand a lot about this, like you wrote the e-book in it or something.

    I believe that you simply can do with some percent to force the message home a
    little bit, however other than that, this is fantastic blog.

    A great read. I will certainly be back.

  20. 샌즈카지노

    Very descriptive article, I enjoyed that a lot.
    Will there be a part 2?

  21. slot games

    I’m not that much of a internet reader to be honest but your
    blogs really nice, keep it up! I’ll go ahead and bookmark your website to come back down the road.
    All the best

  22. e commerce kaufen

    My partner and I absolutely love your blog and find a lot of your
    post’s to be exactly I’m looking for. can you offer guest writers to write content
    to suit your needs? I wouldn’t mind producing a post or elaborating on many of the subjects you write related to here.
    Again, awesome website!

  23. wispy curtain bangs

    Hi there this is kind of of off topic but I was wondering
    if blogs use WYSIWYG editors or if you have to
    manually code with HTML. I’m starting a blog soon but have no coding expertise so
    I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

  24. mr chopsticks denton

    Hey I am so thrilled I found your web site, I really found you by error, while I was looking on Yahoo for something else, Nonetheless I am here
    now and would just like to say cheers for a remarkable post and a
    all round exciting blog (I also love the theme/design), I don’t have time to read it all at the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the
    excellent work.

  25. dafabet

    Your style is unique in comparison to other people I have read stuff from.
    Thanks for posting when you have the opportunity, Guess I’ll just bookmark this web site.

  26. high point academy

    Thanks for the auspicious writeup. It in truth used to
    be a amusement account it. Look complex to far delivered agreeable from you!

    By the way, how can we keep up a correspondence?

  27. online casinos

    My spouse and I absolutely love your blog and find most of your post’s to be
    precisely what I’m looking for. can you offer guest writers
    to write content for you? I wouldn’t mind creating a post or elaborating on many of the subjects you
    write in relation to here. Again, awesome blog!

  28. Titanium inife

    Fantastic goods from you, man. I have understand your stuff previous to
    and you’re just too fantastic. I actually like what you have acquired here, certainly like
    what you are saying and the way in which you say it.
    You make it entertaining and you still care for to keep it wise.
    I cant wait to read much more from you. This is actually
    a tremendous site.

Leave a Reply

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