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

  1. フラッシュ ゲーム

    It’s going to be end of mine day, but before ending I
    am reading this impressive post to increase my know-how.

  2. 빅카지노

    I need to to thank you for this very good read!!
    I absolutely enjoyed every bit of it. I have got you bookmarked to check out new stuff you post…

  3. 제왕카지노

    This post is invaluable. Where can I find out more?

  4. genesis casino login

    Hello, I think your blog might be having browser compatibility issues.
    When I look at your website in Safari, it looks fine but when opening in Internet Explorer,
    it has some overlapping. I just wanted to give you a quick heads up!
    Other then that, fantastic blog!

  5. European

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

  6. Naughty America

    Hello would you mind stating which blog platform you’re working with?
    I’m planning to start my own blog in the near
    future but I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most blogs and I’m looking for something completely unique.
    P.S Apologies for getting off-topic but I had to ask!

  7. 더킹카지노

    I enjoy, result in I discovered exactly what I was having a
    look for. You’ve ended my four day lengthy hunt! God Bless you man. Have a great day.
    Bye

  8. abandoned buildings station

    Why viewers still use to read news papers when in this technological globe all is available on web?

  9. カジノ 日本

    Quality articles is the important to invite the people to go to
    see the website, that’s what this web site is providing.

  10. bet365 cricket

    I don’t even understand how I finished up right here, but I assumed this post
    used to be great. I do not recognize who you might be however definitely you are going to a well-known blogger in the event you are not already.
    Cheers!

  11. w88 mobile login

    hello there and thank you for your info – I have
    definitely picked up anything new from right here. I did however expertise a
    few technical points using this web site, as I experienced to reload
    the site many times previous to I could get it to load correctly.
    I had been wondering if your web hosting is OK? Not
    that I’m complaining, but sluggish loading instances
    times will often affect your placement in google and can damage your quality score if advertising and marketing with Adwords.
    Well I’m adding this RSS to my e-mail and could look out
    for a lot more of your respective intriguing content.
    Ensure that you update this again very soon.

  12. Payday loans

    Heya i’m for the primary time here. I found this board
    and I find It really helpful & it helped me out much.
    I am hoping to offer something again and help others like
    you aided me.

  13. 코인카지노

    It is really a nice and useful piece of information. I’m glad that you
    simply shared this useful information with us.
    Please keep us informed like this. Thank you for sharing.

  14. 빅카지노

    Excellent web site. Plenty of useful information here.
    I am sending it to several pals ans also sharing in delicious.
    And of course, thank you in your sweat!

  15. artist resume

    Hello my family member! I wish to say that this article is awesome, great written and come with approximately all important infos.
    I’d like to see extra posts like this .

  16. 007카지노

    What’s up, after reading this remarkable piece of writing i
    am as well delighted to share my familiarity here with mates.

  17. 최초의 포르노 동영상

    Wonderful work! That is the kind of info that should be shared around the net.
    Disgrace on the search engines for not positioning this publish higher!
    Come on over and discuss with my website . Thanks =)

  18. 즐길 수 있는 4

    Hi there would you mind stating which blog platform you’re using?
    I’m going to start my own blog in the near future but I’m having
    a hard time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most
    blogs and I’m looking for something unique.
    P.S My apologies for being off-topic but I had to ask!

  19. 1Xbet

    Hi there are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get
    started and create my own. Do you need any html coding knowledge to make your own blog?
    Any help would be really appreciated!

  20. 爆乳

    Howdy! This is my first visit to your blog! We are a team 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 wonderful job!

  21. mau binh

    Hmm is anyone else having problems with the images on this blog loading?

    I’m trying to determine if its a problem on my end or if it’s
    the blog. Any suggestions would be greatly appreciated.

  22. capital of michigan

    Everything is very open with a clear explanation of the issues.
    It was truly informative. Your website is extremely helpful.
    Many thanks for sharing!

  23. Titanium watch

    Heya i’m for the first time here. I found this board and
    I find It really helpful & it helped me out much. I hope to offer one thing back and aid others
    like you aided me.

  24. 솔레어카지노

    I need to to thank you for this excellent read!! I certainly loved every
    little bit of it. I’ve got you saved as a favorite to check out new
    things you post…

  25. escorts colorado springs

    Wonderful post however , I was wondering if you could write
    a litte more on this topic? I’d be very thankful if
    you could elaborate a little bit further. Bless you!

  26. 코인카지노

    Why visitors still make use of to read news papers when in this technological globe all is existing on net?

  27. 메리트카지노

    Wonderful blog! I found it while surfing around on Yahoo News.
    Do you have any tips on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get
    there! Appreciate it

Leave a Reply

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