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.

2,681 comments

  1. how to play andar bahar

    I don’t even know how I ended up here, but I thought this post was great.
    I don’t know who you are but definitely you’re going to a famous blogger if you aren’t already
    😉 Cheers!

  2. social video sites

    We are a group of volunteers and opening a new scheme in our community.

    Your site provided us with valuable information to work on. You’ve done a
    formidable job and our entire community will be thankful to you.

  3. slot games

    I have been browsing online greater than three hours these days,
    but I by no means found any fascinating article like yours.

    It’s pretty price sufficient for me. Personally, if all web owners and
    bloggers made just right content as you probably did,
    the net will probably be a lot more useful than ever before.

  4. ネットカジノ

    I think this is one of the most vital information for me. And i’m glad reading your article.
    But wanna remark on few general things, The site style is perfect, the articles is
    really nice : D. Good job, cheers

  5. 우리카지노

    Spot on with this write-up, I really feel this amazing site needs far more attention. I’ll probably be returning to read through more,
    thanks for the information!

  6. 사무엘라 saacute_nchez mejor cola

    Do you mind if I quote a few of your articles as long as I provide credit and sources back to your webpage?
    My blog site is in the exact same niche as yours and my users would certainly benefit from a lot of the information you
    provide here. Please let me know if this ok with you.
    Cheers!

  7. titanium armor

    I don’t even understand how I ended up here, but I believed this put up
    used to be good. I don’t know who you are however
    definitely you are going to a well-known blogger if
    you are not already. Cheers!

  8. vsp employer login

    Hi, just wanted to say, I enjoyed this blog post.

    It was practical. Keep on posting!

  9. a written testimony

    Just desire to say your article is as astonishing.
    The clearness for your post is simply spectacular and that i can suppose you’re a professional in this subject.
    Well with your permission let me to seize your feed to keep updated with impending post.

    Thank you one million and please continue
    the gratifying work.

  10. William Hill

    These are really fantastic ideas in about
    blogging. You have touched some nice factors here.
    Any way keep up wrinting.

  11. 패디 파워

    Howdy just wanted to give you a quick heads
    up and let you know a few of the pictures aren’t loading correctly.

    I’m not sure why but I think its a linking issue.
    I’ve tried it in two different browsers and both show the same
    results.

  12. 메리트카지노

    You’re so cool! I don’t suppose I’ve truly read a single thing like this before.
    So good to discover another person with unique thoughts on this issue.
    Really.. many thanks for starting this up. This web site is something that’s needed on the
    web, someone with a bit of originality!

  13. 1xbet 한국

    I’ve read a few good stuff here. Certainly price bookmarking for revisiting.

    I wonder how much attempt you set to create the sort of
    wonderful informative site.

  14. 원엑스벳

    Hi there, its nice post on the topic of media print,
    we all be aware of media is a impressive source of information.

  15. ゴッドオブウォー攻略

    Have you ever thought about creating an ebook or guest authoring on other websites?
    I have a blog centered on the same subjects you discuss and would really like to have you
    share some stories/information. I know my
    audience would appreciate your work. If you’re even remotely interested, feel free
    to send me an e-mail.

  16. types of music

    Hey there! Someone in my Facebook group shared this site with us so I came to
    give it a look. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers!
    Exceptional blog and fantastic design and style.

  17. http local server

    Highly descriptive post, I loved that a lot.
    Will there be a part 2?

  18. 우리카지노

    Ahaa, its good conversation concerning this piece of writing here at this website, I have read all that, so at this time me also commenting at this place.

  19. 7Bit Casino

    Link exchange is nothing else except it is just placing
    the other person’s website link on your page at suitable place and other person will also do
    similar for you.

  20. xo so keno minh chính

    It’s an remarkable article designed for all the internet viewers; they will get
    benefit from it I am sure.

  21. 아름다운 성숙한 61 세

    Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your weblog?

    My website is in the exact same niche as yours and my visitors would truly benefit from a lot of the information you
    present here. Please let me know if this ok with you.
    Thanks!

  22. Dafabet

    What’s up friends, good piece of writing and nice arguments commented at this place, I am really
    enjoying by these.

Leave a Reply

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