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.

347 comments

  1. Malik Cardish

    Sweet 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! Thank you

  2. perceraian non muslim

    Hello there, just became aware of your blog through Google, and found
    that it is truly informative. I’m going to watch out for brussels.
    I will be grateful if you continue this in future.
    A lot of people will be benefited from your writing.

    Cheers!

  3. fireplace Review

    Hello, its pleasant piece of writing on the topic of media print, we all understand
    media is a fantastic source of facts.

  4. Enterprise App Development Company

    Excellent beat ! I would like to apprentice while you amend your
    website, how could i subscribe for a blog site? The account helped me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast provided bright clear idea

  5. dual whatsapp apk

    Hi there Dear, are you really visiting this web page regularly,
    if so then you will absolutely get good knowledge.

  6. bioniche pharma trena med a

    Hola! I’ve been following your weblog for some time now and finally got the courage to go ahead and give you
    a shout out from Atascocita Texas! Just wanted to tell you keep up the great job!

  7. Know More

    Good – I should definitely pronounce, impressed with your website. I had no trouble navigating through all the tabs as well as related information ended up being truly simple to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or anything, site theme . a tones way for your client to communicate. Excellent task..

  8. Fast Dispatch Home Loan in Pune

    you are actually a just right webmaster. The website loading speed is amazing. It kind of feels that you are doing any distinctive trick. In addition, The contents are masterpiece. you’ve performed a excellent process on this topic!

  9. Website Authority

    Admiring the persistence you put into your site and in depth information you present. It’s awesome to come across a blog every once in a while that isn’t the same outdated rehashed information. Excellent read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

  10. important site

    You actually make it seem so easy with your presentation but I find this topic to be really something that I think I would never understand. It seems too complicated and extremely broad for me. I am looking forward for your next post, I’ll try to get the hang of it!

  11. more helpful hints

    I was just looking for this information for a while. After 6 hours of continuous Googleing, at last I got it in your website. I wonder what’s the lack of Google strategy that don’t rank this type of informative websites in top of the list. Normally the top websites are full of garbage.

  12. how much does it cost to go to a chiropractor

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

  13. kedai semenax malaysia

    Hello this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding skills so I wanted to get advice from someone with experience. Any help would be enormously appreciated!

  14. semenax kopen

    Excellent post however I was wanting to know if you could write a litte more on this subject? I’d be very grateful if you could elaborate a little bit more. Appreciate it!

Leave a Reply

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