Answer the question
In order to leave comments, you need to log in
Webhook on https but without the certificate .pem file itself?
Good afternoon!
I'm trying to set up a telegram bot to work through a webhook, but it doesn't work. I am using pyTelegramBotAPI.
Through the interface of my host, I made SSL certificates for the domain, the rating https://www.ssllabs.com/ssltest/ gives A.
I don’t fully understand how exactly I need to register a webhook via setwebhook in telegram. Everything seems to have gone well. Here is my setwebhook function:
WEBHOOK_URL_BASE = "https://%s:%s" % (WEBHOOK_HOST, WEBHOOK_PORT)
WEBHOOK_URL_PATH = "/%s/" % (API_TOKEN)
@app.route('/set_webhook', methods=['GET', 'POST'])
def set_webhook():
s = bot.set_webhook(url=WEBHOOK_URL_BASE+WEBHOOK_URL_PATH)
if s:
print(s)
return "webhook setup ok"
else:
return "webhook setup failed"
# Process webhook calls
@app.route(WEBHOOK_URL_PATH, methods=['POST'])
def webhook():
if flask.request.headers.get('content-type') == 'application/json':
json_string = flask.request.get_data().decode('utf-8')
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return ''
else:
flask.abort(403)
Answer the question
In order to leave comments, you need to log in
You configure a webhook on HTTPS and you cannot attach SSL. So it can't work.
1. Try to make your bot work over HTTP if it's allowed
2. Change hoster, get VDS, install your own SSL (I can recommend DigitalOcean or FirstVDS
made SSL certificates for the domain
Your daemon is listening on port 8443.
WEBHOOK_PORT = 8443
And there is no certificate there. There's a simple http. Generate a certificate and add it to app.run and bot.set_webhook
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question