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.

267 comments

  1. steam product codes generator

    Woah! I’m really digging the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between user friendliness and
    appearance. I must say that you’ve done a excellent job with this.
    In addition, the blog loads extremely quick for me on Firefox.

    Excellent Blog!

  2. Rafaela

    It’s enormous that you are getting ideas from this paragraph
    as well as from our argument made at this time.

  3. Jerry

    Wonderful site. A lot of useful information here. I am sending
    it to some buddies ans also sharing in delicious. And naturally, thank
    you on your sweat!

  4. 回国行李寄送

    I’m not sure where you are getting your info, however great topic.
    I must spend a while learning more or working out more.
    Thanks for wonderful info I used to be looking for this information for my mission.

  5. Kindra

    Simply want to say your article is as surprising. The clarity on your publish is just
    nice and that i could think you are an expert on this subject.
    Fine along with your permission allow me to snatch your RSS
    feed to keep updated with imminent post. Thanks 1,000,000 and please carry on the gratifying work.

  6. ver instagram privado sin encuesta 2020

    This is very interesting, You’re a very skilled
    blogger. I have joined your rss feed and look
    forward to seeking more of your fantastic post. Also, I’ve
    shared your web site in my social networks!

  7. ver instagram privado en línea gratis

    Good day! Would you mind if I share your blog with my twitter group?
    There’s a lot of people that I think would really enjoy your content.

    Please let me know. Many thanks

  8. Aleida

    You can definitely see your enthusiasm in the work you write.
    The world hopes for even more passionate writers like you who are not
    afraid to say how they believe. At all times go after your heart.

  9. https://www.ctiparty.dk/

    Write more, thats all I have to say. Literally, it seems
    as though you relied on the video to make your point.
    You obviously know what youre talking about, why waste your intelligence on just posting videos
    to your weblog when you could be giving us something informative to read?

  10. Marietta

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

  11. Leticia

    You really make it appear so easy with your presentation however I find this matter to be really one thing that I feel I would by no
    means understand. It sort of feels too complicated and very huge
    for me. I am taking a look ahead in your subsequent publish,
    I will try to get the grasp of it!

  12. en koleji

    Thank you, I’ve recently been looking for info about this topic for a long time and yours
    is the greatest I’ve discovered so far. But, what about the conclusion? Are you certain about the supply?

  13. Hermelinda

    hi!,I really like your writing so so much! proportion we keep in touch extra approximately your post on AOL?
    I require a specialist in this space to resolve my
    problem. May be that’s you! Having a look forward to peer you.

  14. Christina

    We stumbled over here by a different web page and thought I may
    as well check things out. I like what I see so i am just following you.
    Look forward to looking into your web page for a second
    time.

  15. Andy

    For the reason that the admin of this web site is working, no question very soon it
    will be well-known, due to its feature contents.

  16. Vivien

    What’s up to every body, it’s my first visit of this web site;
    this webpage carries awesome and really good data in support of readers.

  17. Otilia

    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 could do with some pics to drive the message
    home a bit, but instead of that, this is fantastic
    blog. A fantastic read. I will definitely be back.

  18. Roseanna

    I like it when people come together and share thoughts.
    Great blog, continue the good work!

  19. Seo backlinks

    After I originally commented I appear to have clicked on the -Notify me when new comments are added- checkbox and now every time a comment is added I get 4
    emails with the exact same comment. Perhaps there is a way you
    can remove me from that service? Thanks!

  20. Gordon

    I’m gone to say to my little brother, that he should also
    pay a quick visit this weblog on regular basis to take
    updated from most recent gossip.

  21. Ella

    you are actually a just right webmaster. The website loading pace is incredible.

    It seems that you are doing any distinctive trick. Also,
    The contents are masterpiece. you’ve done a wonderful activity on this matter!

  22. Darcy

    Awesome site you have here but I was wanting to know if you knew
    of any discussion boards that cover the same topics discussed in this article?
    I’d really like to be a part of online community where I can get suggestions from other knowledgeable people that share the same interest.
    If you have any recommendations, please let me know.
    Thanks!

  23. Gerard

    of course like your website but you need to check the spelling
    on several of your posts. Several of them are rife with spelling problems and I to find
    it very troublesome to inform the reality nevertheless I will surely come back again.

  24. Christian

    Nice weblog right here! Also your web site loads up very fast!
    What host are you using? Can I get your associate link for
    your host? I wish my website loaded up as quickly as yours lol

  25. Salvador

    Fantastic items from you, man. I’ve keep in mind your stuff prior to and you are simply extremely wonderful.
    I actually like what you have obtained right here, really like
    what you’re saying and the way in which in which you assert it.
    You are making it enjoyable and you continue to take care of to stay
    it smart. I cant wait to read much more from you.

    That is really a tremendous site.

  26. Norris

    Fastidious answers in return of this issue with solid arguments and describing all regarding that.

  27. agen poker

    Hi there, all is going sound here and ofcourse every one is sharing information, that’s genuinely excellent, keep
    up writing.

  28. fifa player card generator

    Hey there, You have done an excellent job. I will
    definitely digg it and personally suggest to my friends.
    I am sure they’ll be benefited from this site.

  29. badoo pro apk free download

    Howdy, I do think your website could be having browser compatibility issues.
    Whenever I take a look at your blog in Safari,
    it looks fine but when opening in Internet Explorer, it’s got some
    overlapping issues. I simply wanted to provide you
    with a quick heads up! Apart from that, excellent blog!

Leave a Reply

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