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

  1. fun88+vin

    Definitely believe that which you stated. Your favorite reason appeared to be on the web the easiest thing to be aware of.
    I say to you, I definitely get irked while people consider worries that
    they plainly don’t know about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people can take a signal.
    Will probably be back to get more. Thanks

  2. Titanium earrings

    It’s really a nice and useful piece of info. I’m glad that
    you shared this useful info with us. Please
    stay us up to date like this. Thanks for sharing.

  3. 우리카지노

    When I originally commented I appear to have clicked
    on the -Notify me when new comments are added- checkbox and from now on whenever
    a comment is added I recieve 4 emails with the exact same comment.
    Is there a means you are able to remove me from that service?
    Many thanks!

  4. poker rankings

    Thanks for sharing your thoughts on leo vegas casino app.

    Regards

  5. 더나인카지노

    Hello there, I believe your site could possibly be having web browser compatibility problems.
    Whenever I look at your site in Safari, it looks fine however when opening in Internet Explorer, it has some
    overlapping issues. I simply wanted to give you a quick heads up!
    Other than that, great blog!

  6. ブックメーカーとは

    Hello! I know this is kinda off topic but I was wondering if you knew where I could locate 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!

  7. casino games online

    Hi there I am so glad I found your weblog, I really found you by mistake, while
    I was researching on Yahoo for something else, Nonetheless I am here now and would just like to say thanks a lot for a
    remarkable post and a all round entertaining blog (I also love the theme/design), I don’t have time
    to browse 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 a lot more, Please do keep up the fantastic work.

  8. 솔레어카지노

    I’m really loving the theme/design of your web
    site. Do you ever run into any web browser compatibility problems?
    A small number of my blog readers have complained about my site not working correctly in Explorer but
    looks great in Chrome. Do you have any solutions to
    help fix this problem?

  9. 메리트카지노

    This is my first time visit at here and i am actually happy to read all
    at single place.

  10. 올리비아 빌어 먹을 trina rush

    My coder is trying to persuade me to move to .net
    from PHP. I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using Movable-type
    on a number of websites for about a year and am anxious about switching to another platform.
    I have heard great things about blogengine.net.

    Is there a way I can import all my wordpress posts into it?
    Any kind of help would be greatly appreciated!

  11. asset tags

    I got this site from my friend who informed me on the
    topic of this web site and now this time I am visiting
    this web page and reading very informative articles at this
    place.

  12. sports betting

    I would like to thank you for the efforts you’ve put in writing this website.
    I’m hoping to check out the same high-grade content from you later
    on as well. In fact, your creative writing abilities has motivated me to get my very own blog now 😉

  13. konicasino.com

    Hey! I just wanted to ask if you ever have any trouble with hackers?
    My last blog (wordpress) was hacked and I ended up losing
    several weeks of hard work due to no data backup. Do you have any methods to prevent hackers?

  14. casino games

    This design is incredible! 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 enjoyed what you had to say, and more than that,
    how you presented it. Too cool!

  15. カジノ オンライン

    Someone necessarily assist to make seriously articles I
    would state. That is the very first time I frequented your website page and up to now?
    I amazed with the research you made to create this actual publish extraordinary.
    Great task!

  16. la seo service

    Hello, everything is going nicely here and ofcourse every one
    is sharing information, that’s in fact fine, keep up writing.

  17. カジノX

    What’s up, for all time i used to check weblog posts here in the early hours
    in the morning, since i love to gain knowledge of more and more.

  18. new laptop

    Great blog here! Also your website so much up
    very fast! What web host are you the use of? Can I get your
    affiliate hyperlink on your host? I want my website loaded up as quickly as yours lol

  19. 영화인가요

    Right now it sounds like Expression Engine is the top blogging platform available right now.
    (from what I’ve read) Is that what you’re using on your blog?

  20. เข้า แทง บอล

    Link exchange is nothing else but it is just placing the other person’s weblog link on your page at proper
    place and other person will also do same in favor of you.

  21. Titanium Trim

    Excellent web site you have got here.. It’s difficult to
    find good quality writing like yours these days. I truly appreciate people like you!
    Take care!!

  22. カジノゲーム

    I loved as much as you’ll receive carried out right here.
    The sketch is attractive, your authored material stylish.
    nonetheless, you command get got an shakiness over that you wish be delivering the
    following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield
    this increase.

  23. 우리카지노

    I was wondering if you ever thought of changing the layout of your website?
    Its very well written; I love what youve got to say. But maybe
    you could a little more in the way of content so people could connect with it better.
    Youve got an awful lot of text for only
    having 1 or 2 images. Maybe you could space it
    out better?

  24. clean key

    This article will help the internet visitors for creating new web site or even a
    blog from start to end.

  25. Payday loans

    My developer is trying to persuade me to move to .net from PHP.
    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using
    WordPress on numerous websites for about a year and am nervous about switching to another
    platform. I have heard great things about blogengine.net.
    Is there a way I can transfer all my wordpress content into it?
    Any help would be really appreciated!

  26. astrid and stranger 근처 오락거리

    Hey there! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in trading links or maybe guest authoring
    a blog article or vice-versa? My blog addresses a lot of the
    same topics as yours and I think we could greatly benefit from each
    other. If you happen to be interested feel free to
    send me an e-mail. I look forward to hearing from you!

    Terrific blog by the way!

  27. oker

    Hi Dear, are you actually visiting this site daily, if so after that you
    will definitely obtain nice experience.

  28. ジパングカジノ ボーナス

    Hey there! Do you know if they make any plugins to safeguard against
    hackers? I’m kinda paranoid about losing everything
    I’ve worked hard on. Any recommendations?

Leave a Reply

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