Skip to content

How can I run my bot using webhooks instead of polling #1672

Answered by MKRhere
SimaTheCoder asked this question in Q&A
Discussion options

You must be logged in to vote

Example: https://github.com/telegraf/telegraf/blob/v4/docs/examples/webhook-bot.js

Is there really a difference in performance/speed

This should only really be a concern if you're running a bot with a high amount of traffic per second. Most bots will not need to worry about setting up webhooks.

Which port is recommended?

Very similar to running a webserver (because this is a webserver), you can listen on any localhost port, and reverse-proxy it with a server like nginx. If you really wish to your bot directly on the internet, then you must use port 443 and pass TLS options like so: bot.launch({ webhook: { ..., port: 443, tlsOptions: { ... } } }). tlsOptions are the same as node's http…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@alexey-sh
Comment options

Answer selected by SimaTheCoder
Comment options

You must be logged in to vote
2 replies
@MKRhere
Comment options

@SimaTheCoder
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants