7

I want to develop a bot for a business! I don't know that using getUpdates method for develop a windows desktop application and run that on vps (by https://github.com/MrRoundRobin/telegram.bot library) or using setWebhook method to develop bot with php!

Which one is better in terms of speed and etc? And what are some other differences?

2 Answers 2

7

It does not matter you want to use which kind of server side applications. Typically getUpdates used for debugging. For publishing your bots, you need to using the Webhook. See this.

getUpdates is a pull mechanism, setWebhook is push. There are some advantages of using a Webhook over getUpdates:

  1. Avoids your bot having to ask for updates frequently.
  2. Avoids the need for some kind of polling mechanism in your code.
2

A popular library python-telegram-bot builds most examples around polling through getUpdates and later moves on to webhooks, cautiously:

You should have a good reason to switch from polling to a webhook.

https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks

My personal take is that webhook is a cleaner way to receive event information form Telegram API (POST request goes from Telegram right after after the event, no need for idle looping), but it needs more infrastructure:

  • expose a public API endpoint
  • application must be ready to porcess this call to an endpoint

Most tutorials focus on how to get a bot example running quickly and do that on a local machine, so getUpdates is a natural choice for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.