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. dave money app

    I was curious if you ever thought of changing the structure of your blog?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so
    people could connect with it better. Youve got an awful lot
    of text for only having one or 2 pictures. Maybe you could space it out
    better?

  2. bracelet oeil de faucon bleu

    I always used to study article in news papers but
    now as I am a user of net so from now I am using net for posts, thanks to web.

  3. Güvenlik Soruşturması Ahlaki Durum Avukat

    I do not know whether it’s just me or if everyone else experiencing problems
    with your blog. It appears as if some of the text in your
    posts are running off the screen. Can someone else please comment and
    let me know if this is happening to them as well?
    This may be a problem with my browser because I’ve had this happen before.
    Kudos

  4. Errol

    Pretty section of content. I just stumbled upon your website and in accession capital to assert that I get actually enjoyed account
    your blog posts. Any way I’ll be subscribing to your feeds and even I achievement
    you access consistently rapidly.

  5. aventurine perle

    Hi there to every one, it’s actually a good for me to pay a visit this web page,
    it includes important Information.

  6. Eileen

    What’s up to all, how is the whole thing, I think every one is getting more from
    this web page, and your views are nice in support of new visitors.

  7. perle agate mousse

    Hello there! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest authoring a blog article or vice-versa?
    My site covers a lot of the same topics as yours and I think we could greatly benefit from each other.
    If you might be interested feel free to shoot me an e-mail.
    I look forward to hearing from you! Superb blog by the way!

  8. 바카라사이트

    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 require any coding expertise to make your
    own blog? Any help would be greatly appreciated!

  9. apatite bleu

    This piece of writing will help the internet
    people for building up new web site or even a weblog from start to end.

  10. perle malachite

    What’s up, this weekend is fastidious designed for me, as this time i am reading this impressive educational article here at my home.

  11. just click for source

    Heya i am for the first time here. I found this board and I find It truly useful & it
    helped me out much. I hope to give something back and help
    others like you helped me.

  12. buy instagram followers

    Have you ever thought about including a little bit more than just your
    articles? I mean, what you say is fundamental and all.
    But imagine if you added some great pictures or videos to give your posts more,
    “pop”! Your content is excellent but with pics and video clips, this site could undeniably be one of the very best in its niche.
    Terrific blog!

  13. perle d ambre

    Good site you’ve got here.. It’s hard to find good quality writing like yours nowadays.
    I honestly appreciate individuals like you! Take care!!

  14. travelers

    Hi there, I do think your blog could be having web browser compatibility problems.
    When I look at your site in Safari, it looks fine however when opening in I.E., it’s got some
    overlapping issues. I just wanted to give you a quick heads up!
    Other than that, great blog!

  15. free classifieds websites

    Hello to every body, it’s my first go to see of this website; this blog consists
    of awesome and in fact fine stuff for visitors.

  16. Free article writing submission websites

    May I simply just say what a relief to uncover somebody who truly
    knows what they’re talking about on the web. You certainly
    know how to bring a problem to light and make it important.

    A lot more people should read this and understand this side of your story.
    It’s surprising you’re not more popular since you most certainly possess
    the gift.

  17. see here now

    Hello there! This post couldn’t be written much better!

    Looking through this article reminds me of my previous roommate!
    He constantly kept talking about this. I’ll forward this post to him.
    Pretty sure he’s going to have a great read. Thank you for sharing!

  18. Followers

    Touche. Solid arguments. Keep up the great work.

  19. TàI chính

    It’s really very difficult in this busy life to listen news on TV, thus I only use world wide
    web for that purpose, and take the latest information.

  20. Constipation Treatment

    I am really loving the theme/design of your website.
    Do you ever run into any browser compatibility issues?

    A number of my blog audience have complained about my blog not working correctly in Explorer but looks
    great in Opera. Do you have any recommendations to help fix this problem?

  21. Phonepe customer care number quora

    I was suggested this web site by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my
    difficulty. You’re amazing! Thanks!

  22. rebirth mr wang

    I am truly grateful to the owner of this website who has shared this impressive
    paragraph at here.

  23. Pes 2014 indir

    Hey there, You’ve done an excellent job. I’ll definitely digg it and personally suggest to my friends.

    I’m confident they will be benefited from this website.

  24. best porn

    hello there and thank you for your information – I have
    certainly picked up something new from right here.
    I did however expertise several technical points using this website, since I experienced to reload the site lots of times previous to I could get it
    to load correctly. I had been wondering if your
    hosting is OK? Not that I am complaining, but sluggish loading
    instances times will often affect your placement in google and can damage your high quality score if ads and marketing with Adwords.
    Anyway I’m adding this RSS to my email and can look out for much more of
    your respective intriguing content. Make sure you
    update this again very soon.

  25. Merrie Liebherr

    Greetings! I’ve been following your site for a while now and finally got the courage to go ahead and give you a shout out from Austin Texas! Just wanted to say keep up the fantastic work!

  26. zortilo nrel

    F*ckin’ awesome things here. I’m very happy to see your article. Thanks so much and i’m taking a look ahead to contact you. Will you please drop me a mail?

  27. PHP Classifieds

    I like the valuable info you provide in your articles.
    I will bookmark your weblog and check again here regularly.
    I’m quite sure I’ll learn many new stuff right here!
    Good luck for the next!

Leave a Reply

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