1

My question is very similar to this one: How to use telegram webhook on google cloud functions?

I have the same identical problem but I want to deploy it on Google App Engine. I have set up my bot using the python-telegram-bot library (code below) and actually it is hosted on Heroku and works well.

import os

TOKEN = "TOKEN"
PORT = int(os.environ.get('PORT', '8443'))
updater = Updater(TOKEN)

# add example handler

def start(update, context):
        context.bot.send_message(chat_id=update.message.chat_id, text="Hello, I am dice bot and I will roll some tasty dice for you.")

start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)

# start webhook polling

updater.start_webhook(listen="0.0.0.0",
                      port=PORT,
                      url_path=TOKEN)
updater.bot.set_webhook("https://<appname>.appspot.com/" + TOKEN)
updater.idle()

My Bot is not responding and if I try to browse my app I get 502 ERORR Bad Gateway. Of course I deleted the previous webhook on my Bot.

mostr
  • 39
  • 2
  • Hello @mostr, welcome to Stack Overflow, isn't the accepted answer on the link you shared exactly what you are looking for? Since it is mentioned that App Engine should be the tool used for that. – Ralemos Jul 24 '20 at 13:29
  • Hello @ralemos, thank you. That accepted answer links an old github example not working anymore. First of all the app.yaml file has many fields like "application" that are not used anymore. Second it use the webapp2 library while the question was asking about the integrated webhook in the python-telegram-bot library. – mostr Jul 24 '20 at 14:06
  • ok, but what have you tried so far and what problems have you encountered while deploying your app that uses the webhook to App Engine? I could not find any step by step tutorial for that specific case so I more details to be able to help you. – Ralemos Jul 27 '20 at 16:16
  • You are right. I just edited my question with more information. – mostr Jul 28 '20 at 15:35
  • 502 Bad Gateway is usually an error on the Nginx side, but this is a bit too broad still, do you have any additional logs? You can check how to set it up [here](https://cloud.google.com/appengine/docs/flexible/nodejs/writing-application-logs) Also, I have found this [Community Post](https://stackoverflow.com/questions/49370552/cant-setup-a-webhook-for-a-telegram-bot) with a similar issue, not sure if this helps in any way but thought I'd share. – Ralemos Jul 31 '20 at 16:02

0 Answers0