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.

6.534 comments

  1. 카지노사이트

    hello there and thank you for your information – I’ve
    definitely picked up something new from right here. I did however expertise some technical points using this website, as I experienced to reload the website
    many times previous to I could get it to load correctly.
    I had been wondering if your web host is OK? Not that
    I am complaining, but slow loading instances times will very frequently affect your placement in google and can damage your quality score if
    ads and marketing with Adwords. Anyway I am adding this RSS to my e-mail and could look
    out for much more of your respective interesting content.
    Ensure that you update this again soon.

  2. dG0G9vO3fP3

    May I simply say what a comfort to find someone who truly knows what they’re talking about on the web.
    You definitely realize how to bring an issue to light and make it
    important. A lot more people have to look at this and understand this side
    of the story. I can’t believe you are not more popular because you definitely
    possess the gift.

  3. travel agency honolulu

    Everything is very open with a clear explanation of the challenges.
    It was definitely informative. Your website is extremely helpful.
    Thank you for sharing!

  4. 바카라 더킹

    My brother recommended I might like this web site. He was once totally right.
    This put up truly made my day. You can not believe simply how so much time I had spent for this information! Thanks!

  5. online casino in india

    Definitely consider that which you stated. Your favorite reason seemed to be on the internet
    the easiest thing to consider of. I say to you, I definitely get irked whilst other people think about concerns
    that they plainly don’t understand about. You controlled to hit the nail upon the highest as neatly
    as defined out the whole thing without having side-effects , other folks could
    take a signal. Will probably be again to get more. Thank you

  6. ポーカー

    Fascinating blog! Is your theme custom made or did you download it from
    somewhere? A theme like yours with a few simple adjustements would
    really make my blog stand out. Please let me
    know where you got your design. Kudos

  7. lO5L9jA2tN3

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

  8. 메리트카지노

    Thank you for the good writeup. It in fact was a amusement
    account it. Look advanced to far added agreeable from you!
    By the way, how could we communicate?

  9. 바카라

    Excellent post. I was checking continuously this blog and I am impressed!
    Very useful information specifically the last part 🙂 I care
    for such information a lot. I was looking for this particular info for a long time.
    Thank you and best of luck.

  10. ‎ベラジョンカジノ

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

  11. andar bahar game

    What’s up Dear, are you really visiting this website daily, if
    so then you will definitely take pleasant know-how.

  12. porno carioca

    Today, I went to the beachfront with my children. I found a sea shell
    and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.

    There was a hermit crab inside and it pinched
    her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!

  13. dafabet casino

    Spot on with this write-up, I truly believe that this website needs
    much more attention. I’ll probably be returning to see more, thanks for the information!

  14. 카지노

    I’m really impressed together with your writing skills and also with the structure in your blog.
    Is this a paid subject or did you customize it yourself? Anyway keep
    up the nice quality writing, it’s uncommon to look a great weblog like this one nowadays..

  15. dQ1sG6xZ6T7

    Hi there I am so delighted I found your webpage, I really found you by error, while
    I was researching on Bing for something else, Anyways I am here now
    and would just like to say kudos for a remarkable post and a all round interesting blog (I also love
    the theme/design), I don’t have time to look over it all at the moment but I have book-marked 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.

  16. fQ1D0gM8fO3

    Greetings! I know this is kind of 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 problems finding one?

    Thanks a lot!

  17. 10cric app login

    Hello Dear, are you really visiting this website daily, if so then you will without doubt obtain nice knowledge.

  18. xQ7kV3gY0I2

    Hi are using WordPress for your blog 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 greatly appreciated!

  19. wR6gI5oD1C0

    With havin so much content do you ever run into any problems
    of plagorism or copyright infringement? My website has a lot of completely unique content I’ve either written myself or outsourced but it looks like
    a lot of it is popping it up all over the internet without my permission. Do you know any techniques to help protect against content from being ripped off?
    I’d definitely appreciate it.

  20. keno

    Hi colleagues, how is all, and what you want to say concerning this post,
    in my view its truly remarkable for me.

  21. roulette sites

    What a information of un-ambiguity and preserveness of valuable know-how
    regarding unpredicted emotions.

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *