Hi,
I have a simple python telegram bot that works ok running from my computer. I’m trying to launch it as an app with fly.io, but I have hit a wall trying to get it to work.
My app seems to build correctly, but it’s no longer connecting with Telegram. I’m trying to use webhooks (code below).
I’ve triend to satisfy the Telegram Bot API’s SSL/port requirements by issuing a certificate for my app’s domain. It runs via port 443, which Telegram accepts.
I can’t load the app itself at the url Fly.io has provided, however, so I think there is some more fundamental issue. Google Chrome still loads an info/warning about the page’s when I try to load it., despite Fly.io saying its certificates are valid.
Any ideas?
Here’s my webhook code (in an app.py file):
from flask import Flask
from telegram_bot import setup_webhook
app = Flask(name)
@app.route(‘/’)
def index():
return ‘Hello, world!’
if name == ‘main’:
setup_webhook()
app.run(host=‘0.0.0.0’, port=443, ssl_context=‘adhoc’)
Here’s a function from my telegram_bot.py file that should create the webhook:
def setup_webhook():
bot_token = ‘TOKEN’
webhook_url = ‘https://my-app.fly.dev/’ *this is a placeholder URL - real thing is in the proper code
response = requests.get(f’https://api.telegram.org/bot{bot_token}/setWebhook?url={webhook_url}')
print(response.json())
Here’s my .toml file:
app = ‘my-app’ *This is a placeholder, the real app is in the proper code
primary_region = ‘sin’
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = false
auto_start_machines = true
min_machines_running = 1
processes = [‘app’]
[[http_service.handlers]]
protocol = “tls”
port = 443
handler = “app”
[[http_service.handlers.forwarding]]
destination = “app”
port = 8080
[[http_service.handlers.redirects]]
from = “http://$HTTP_HOST/*”
to = “https://$HTTP_HOST/$1”
status = 301
[[vm]]
cpu_kind = ‘shared’
cpus = 1
memory_mb = 1024
[build]
builder = “paketobuildpacks/builder:base”
buildpacks = [“paketo-community/python”]