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.

293 comments

  1. zortilonrel

    What¦s Happening i am new to this, I stumbled upon this I have found It positively helpful and it has aided me out loads. I’m hoping to contribute & assist different customers like its helped me. Great job.

  2. Xmltv url

    I do not know if it’s just me or if perhaps everybody else experiencing issues
    with your blog. It seems like some of the written text in your content are running off the screen. Can someone else please provide feedback and let me know
    if this is happening to them as well? This may
    be a issue with my internet browser because I’ve had this happen previously.
    Thanks

  3. ed meds

    I’m commenting to let you be aware of of the awesome discovery my child developed browsing the blog. She came to find a good number of details, including how it is like to have a great coaching character to get a number of people clearly completely grasp a number of advanced issues. You actually did more than her desires. I appreciate you for churning out such effective, dependable, edifying and cool guidance on that topic to Emily.

  4. luvox cheap

    I’m also commenting to let you be aware of of the excellent discovery my cousin’s child enjoyed checking your blog. She discovered a wide variety of details, most notably how it is like to have a marvelous coaching heart to get many more easily fully understand certain complicated matters. You actually did more than my desires. I appreciate you for delivering such great, healthy, educational and also cool guidance on that topic to Evelyn.

  5. nortriptyline price

    I simply wished to thank you very much yet again. I do not know what I would have undertaken without those tips shown by you relating to this theme. Previously it was the terrifying setting in my view, nevertheless understanding your well-written technique you treated the issue took me to weep with joy. Now i’m thankful for your support as well as trust you recognize what an amazing job you were undertaking training the others via your website. Most probably you haven’t met any of us.

  6. paroxetine price

    I am only writing to make you understand what a superb experience our princess undergone viewing yuor web blog. She picked up such a lot of things, with the inclusion of what it is like to possess an ideal teaching style to make the others without hassle thoroughly grasp specified tricky topics. You undoubtedly surpassed visitors’ expected results. Thanks for showing those valuable, trustworthy, revealing not to mention unique tips on your topic to Sandra.

  7. paroxetine no rx

    I’m also commenting to let you be aware of of the beneficial discovery my child encountered checking the blog. She came to understand a lot of details, including how it is like to have a marvelous coaching character to get certain people completely comprehend a variety of complex issues. You actually did more than her desires. I appreciate you for coming up with such essential, dependable, edifying and cool guidance on that topic to Ethel.

  8. sinequan prices

    I precisely needed to appreciate you once again. I am not sure the things that I might have handled in the absence of the entire pointers provided by you on such a problem. It had been a very frightening difficulty in my circumstances, however , looking at the skilled manner you processed that made me to jump over fulfillment. I am happier for your support and thus trust you really know what an amazing job you were putting in training the mediocre ones via your webpage. Most probably you haven’t met any of us.

  9. venlor cheap

    I enjoy you because of all of your efforts on this site. Ellie enjoys doing internet research and it’s easy to see why. All of us hear all concerning the compelling manner you deliver functional ideas by means of the blog and as well cause contribution from other people about this concept plus my daughter is being taught a lot. Enjoy the remaining portion of the new year. You’re the one carrying out a first class job.

  10. sinequan online

    I precisely had to appreciate you all over again. I’m not certain the things I might have followed in the absence of the actual information documented by you directly on such field. It became a real distressing crisis for me personally, but encountering a new professional form you managed it forced me to jump for delight. I’m just happier for the guidance and even have high hopes you find out what a powerful job you’re doing instructing most people through your blog post. I am sure you’ve never encountered all of us.

  11. wellbutrin price

    I am commenting to let you know of the fine encounter my friend’s daughter found reading your site. She figured out many issues, not to mention what it’s like to have a wonderful giving mindset to have men and women quite simply have an understanding of selected hard to do subject areas. You really exceeded our expectations. Many thanks for giving the insightful, safe, explanatory and as well as easy thoughts on the topic to Jane.

  12. home 2020 Porsche Taycan Turbo S

    Hi, this weekend is good in support of me, as this moment i am reading this great educational paragraph here at my residence.

  13. Best Site Porsche Taycan Price

    Hi, this weekend is nice designed for me, since this point in time i am reading this wonderful
    informative article here at my residence.

  14. browse around this website Porsche Taycan Deposit

    Howdy! I understand this is kind of off-topic however I needed to
    ask. Does building a well-established blog such as yours take a lot of
    work? I am brand new to blogging however I do write in my diary every
    day. I’d like to start a blog so I will be
    able to share my experience and views online. Please let me know if you
    have any kind of recommendations or tips for new aspiring bloggers.
    Thankyou!

  15. www.google.ac

    I get pleasure from, result in I found just what
    I was looking for. You’ve ended my four day long hunt!
    God Bless you man. Have a great day. Bye

  16. google.com.sl

    Hi there, I log on to your blogs on a regular
    basis. Your humoristic style is awesome, keep up the good work!

  17. Resources Porsche Taycan Render

    Very good site you have here but I was wondering if you knew of any user discussion forums that cover the same topics discussed here?

    I’d really love to be a part of group where I can get feedback from other knowledgeable people that share the same interest.

    If you have any recommendations, please let me know. Cheers!

  18. www.google.co.zw

    It’s really a cool and useful piece of information. I am happy
    that you just shared this helpful information with us. Please keep us informed like this.

    Thanks for sharing.

  19. www.google.com.np

    Great site you have got here.. It’s difficult to find
    high-quality writing like yours nowadays.

    I seriously appreciate people like you! Take care!!

Leave a Reply

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