N
N
nakem2021-11-26 03:03:16
API
nakem, 2021-11-26 03:03:16

What to choose for a telegram bot? Webhooks or long polling?

I didn't write telegram bots. The task is this. You need to write a bot in Go, to which you send a voice message, and it processes this audio and responds with text. For audio processing, I will contact another service via grpc.
I have a question. What to use? If the Internet does not lie, then there are two options. Longpolling or webhooks. As I understand it, 100% of tasks are better than webhooks. But I suspect I'm wrong. What is best for my case?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Mamonov, 2021-11-26
@nakem

"Long polling" periodically polls the telegram server, due to this it will seem to the user that the bot is "slowing down", because. there will be pauses between sending a message from the user and receiving a response.
At least that's how it was for me.
It is also worth mentioning that "Long polling" will not work when it comes to loads.
After switching to WebHooks, everything immediately worked very quickly.
Also, using WebHooks, you will be able to horizontally scale the bot in case of increased loads.
If I had such a task, I would use WebHooks.

E
Eatric, 2021-11-26
@Eatric

Best of all, webhooks because it guarantees delivery and less need to think about how messages are received, they themselves come to your server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question