Setting up webhooks with telegram-bot-ruby ?
thibauld opened this issue ยท 11 comments
From the examples, it looks like telegram-bot-ruby supports only the polling method for getting updates. Does it support also the webhook method ?
Unfortunately, gem doesn't support webhooks at the moment. I think it would be easier to handle webhooks by setting up your own simple web app (using Sinatra, for example). You still may use this gem for making api calls or whatever from there.
Ok, I will do that and provide you with an example that you can include in your README if you want.
Yes @thibauld, a webhook example could help, yes, maybe a very simple sinatra example in README would be really helpfull!
BTW, generally speaking, the HTTP long polling seems to me a not great solution in terms of resources efficency; maybe a SSE (Server Sent Events) could be better... anyway the choice is between HTTP long polling ( https://core.telegram.org/bots/api#getting-updates ) vs HTTP webhooks ( https://core.telegram.org/bots/api#setwebhook ). This last case fit maybe better for a bot that could manage a very high troughtput (messages/sec). Telegram Bot API webhooks settings iare not too clear in documentation at my first glance...
Thanks @atipugin atipugin for your code here!
@Solyaris I agree that webhooks might be a better solution in terms of performance. We definitely need an example of this in docs.
yes :-) maybe with http://cuba.is/ microframework for high speed performances, BTW see: http://www.madebymarket.com/blog/dev/ruby-web-benchmark-report.html I'm joking! I'm a Sinatra lover. Asap I'll study me too the point and I'd propose you something, but reading your code, I see you are a step forward. Thanks
Hi Alexander!
I'm glad to share with you a possible way to close the "issue" (a feature request indeed):
I just published my project BOTServer: https://github.com/solyaris/BOTServer
Again, I thank you for your help in our mails. If you enjoy my project, I appreciate if you star BOTServer. Viceversa, please let me know your possible criticisms.
Stay in tune
respect
giorgio
Thanks, Giorgio! Added a section about webhooks to README (https://github.com/atipugin/telegram-bot-ruby#webhooks). Now i think we can close the issue.
+1
I'd like to refresh this old thread.
I think it might be helpful for people using this gem and wanting to migrate from polling to webhooks, to update the docs and show a minimal webhooks example. Maybe based on Sinatra like #102 does in a PR.
The webhooks technique is important and this gem should acknowledge this. IMHO a simple reference to https://github.com/solyaris/BOTServer might not be the best solution for people who already have a rails or sinatra app running and want to integrate telegram.
Just my 2 cents :-)
Christian
Hi Christian,
in facts I wrote BOTServer two years ago;
since then, does something changed in Telegram webhooks management?
In BOTServer I used rack directly for "performance reasons".
I supplied also the sinatra solution.
@Solyaris Yes, I know and I appreciate your work on this. Webhooks are clearly superior compared to polling.
I just wanted to point out, that I think that this gem should offer a simple alternative webhooks approach in the docs/examples for integration into an existing sinatra or rails app.