Webhooks on flask
- What OS are you using? ubuntu 17.10
- What version of python are you using? 3.6
Hello! I used your example (https://github.com/eternnoir/pyTelegramBotAPI/blob/master/examples/webhook_examples/webhook_flask_echo_bot.py) of installing the bot on the server, but for some reason my bot does not respond to the sent commands. I'm working on the digitalocean servers.
When going to the site:port/token page, an error is displayed: Method Not Allowed The method is not allowed for the requested URL.
Please tell me how to solve this issue.
Thanks in advance!
When going to the site:port/token page, an error is displayed: Method Not Allowed The method is not allowed for the requested URL.
- You should see nothing when you manually touch this address: this is the URL for telegram server to contact your bot.
2.
@app.route(WEBHOOK_URL_PATH, methods=['POST'])
The "POST" here should give you the hint that this application waits for POST request. Touching this address you make "GET" request. That's why you see "Method Not Allowed".
Well, then why doesn't the bot react to commands?
It depends. Did you set breakpoints or print() to see if your program at least receives the POST requests from telegram? At least between lines 44-45, 50-51, 51-52, 56-57?
Additionally set the debug level to DEBUG here:
telebot.logger.setLevel(logging.INFO) ->telebot.logger.setLevel(logging.DEBUG)
to see what's going on in interaction between bot and Telegram.
2018-07-26 11:14:04,339 (apihelper.py:55 MainThread) DEBUG - TeleBot: "The server returned: 'b'{"ok":true,"result":true,"description":"Webhook was set"}''"
Seems that Telegram cannot connect to you server with the given URL. Maybe something is wrong with server settings/certificates etc.
As far as I remember you need the web-server (like nginx) to route queries to given /url:
location /url {
proxy_pass http://127.0.0.1:xxxx;
}
where url is the WEBHOOK_URL_PATH and port is the WEBHOOK_PORT I'm not shure that it is the best way but in that way it starts work for me...
it is possible more in detail?
I have such certificate on the domain

first check get_webhook_info
Hello! Everything works, but there is one problem. I run the flask application in the supervisor and it works. But after 2 days the bot stops responding. In the supervisor, the process is listed as running. Help, please, to understand.