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

  1. discontinued 90s snacks

    Piece of writing writing is also a fun, if you be familiar
    with afterward you can write otherwise it is difficult to write.

  2. 원엑스벳

    Greetings! Very useful advice within this article!
    It’s the little changes that produce the greatest
    changes. Thanks for sharing!

  3. waterx water purifier

    Somebody essentially help to make severely articles I might state.
    This is the first time I frequented your web page and up to now?
    I amazed with the analysis you made to create this actual publish amazing.

    Excellent process!

  4. Payday loans

    Valuable information. Fortunate me I discovered your website by accident, and I am surprised why this twist of fate did not took place earlier!

    I bookmarked it.

  5. เกมส

    What’s up friends, how is everything, and what you want to say about this article, in my view its really awesome for me.

  6. texas holdem poker

    I was suggested this web site by my cousin. I’m not sure whether this post is
    written by him as no one else know such detailed about my trouble.
    You are wonderful! Thanks!

  7. M88

    Howdy I am so grateful I found your website, I really found you by
    mistake, while I was looking on Bing for something else, Nonetheless I am here now and would just like to say many thanks for a incredible post and a
    all round exciting blog (I also love the theme/design), I don’t have time to look over it all at the minute but
    I have bookmarked it and also included your RSS feeds, so when I have time
    I will be back to read more, Please do keep up the awesome
    work.

  8. LuckyNiki

    Oh my goodness! Amazing article dude! Many thanks, However I am having difficulties with your RSS.
    I don’t understand why I am unable to join it.

    Is there anybody getting similar RSS problems?
    Anybody who knows the answer will you kindly respond? Thanks!!

  9. 카지노사이트

    Hi there, its good piece of writing about media print, we all understand media is a wonderful source of
    facts.

  10. pcie cable

    Hello, I enjoy reading through your article post.
    I wanted to write a little comment to support you.

  11. カジ旅 入金

    Hi, just wanted to say, I enjoyed this article. It was funny.

    Keep on posting!

  12. free photo prints

    Thanks for finally talking about > Basic Concept of Telegram Bot API – Dryan Christoph Personal Website < Liked it!

  13. 우리카지노

    Howdy! This post couldn’t be written much better! Looking through this
    post reminds me of my previous roommate! He continually kept talking about this.
    I will forward this article to him. Pretty sure he’s going
    to have a very good read. I appreciate you for sharing!

  14. haggen pharmacy

    It’s awesome for me to have a web page, which is good in favor of my knowledge.
    thanks admin

  15. 빅카지노

    May I simply say what a relief to discover somebody who truly understands
    what they’re talking about on the web. You actually realize how
    to bring a problem to light and make it important. More and more people ought to check this out and understand
    this side of the story. I was surprised that you aren’t more popular since you most certainly possess
    the gift.

  16. カジノオンライン

    Oh my goodness! Incredible article dude! Many thanks, However I am experiencing troubles with your RSS.
    I don’t understand the reason why I cannot subscribe
    to it. Is there anybody having similar RSS problems?
    Anyone who knows the solution will you kindly
    respond? Thanx!!

  17. Titanium Trim

    Tremendous things here. I’m very satisfied to look your article.
    Thank you so much and I am taking a look forward to contact you.
    Will you kindly drop me a e-mail?

  18. bk8

    Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed surfing around your blog posts.

    After all I’ll be subscribing to your rss feed and I hope you write again soon!

  19. treatment process

    Hi there, just became alert to your blog through Google,
    and found that it’s truly informative. I am going to watch out for brussels.
    I will appreciate if you continue this in future.
    Lots of people will be benefited from your writing.

    Cheers!

    Here is my web site … treatment process

  20. 메리트카지노

    Howdy! Do you know if they make any plugins to safeguard against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on. Any recommendations?

  21. immigration lawyer phoenix

    Howdy! I realize this is kind of off-topic but I had
    to ask. Does operating a well-established website like yours take a large amount
    of work? I’m completely new to writing a blog but I do write in my journal
    every day. I’d like to start a blog so I can easily share my personal experience and
    feelings online. Please let me know if you have any recommendations or tips for
    new aspiring blog owners. Appreciate it!

  22. 10cric app

    Wow! Finally I got a web site from where I be able to truly take helpful facts regarding my
    study and knowledge.

  23. all problem solution

    Good information. Lucky me I found your website by chance (stumbleupon).
    I have bookmarked it for later!

  24. xo 카지노

    This is a topic that is near to my heart… Best wishes!
    Exactly where are your contact details though?

  25. 우리카지노

    Greetings! Very helpful advice in this particular
    article! It is the little changes that produce
    the largest changes. Thanks for sharing!

  26. カジノゲーム

    This is a topic which is close to my heart…
    Thank you! Where are your contact details though?

  27. 인터넷 바카라

    I love what you guys tend to be up too. This type of
    clever work and reporting! Keep up the great works guys I’ve included you guys to my own blogroll.

Leave a Reply

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