Telegram Bot Webhook Issue on Heroku

My Telegram bot, hosted on Heroku via GitHub and using a webhook, isn’t receiving messages. Revised sample code:

import os
from flask import Flask, request
import custom_telegram as ct

app = Flask(__name__)
API_KEY = "your_token_here"
bot_instance = ct.Bot(API_KEY)

@app.route(f"/{API_KEY}", methods=["POST"])
def handle_update():
    data = request.get_json(force=True)
    bot_instance.process_update(data)
    return "OK", 200

if __name__ == "__main__":
    port = int(os.environ.get("PORT", 5000))
    app.run(host="0.0.0.0", port=port)

hey finn, maybe ur webhook isnt regd correctly at telegram end. check heroku logs if the post request is coming thru. small typos in route or token can screw it up. cheers

I have encountered a similar issue when deploying a Telegram bot on Heroku. In my case, carefully verifying the webhook registration ensured that incoming messages were correctly forwarded. I discovered that occasionally minor configuration details, such as URL encoding or SSL certificate issues, can prevent correct routing of the POST request. Additionally, utilizing Heroku logs to inspect each incoming request helped isolate whether the problem stemmed from Heroku or the Telegram server. A thorough review of your deployment settings and webhook registration process is recommended.