How to deploy a Telegram bot to hosting
Updated · 5 min read
In short
A Telegram bot runs on 67hosting as an app. For free, the bot works via webhook: Telegram sends updates to the app's address and wakes it if it was asleep. A bot that polls Telegram itself (long polling) needs always-on mode — without incoming requests a free app goes to sleep after 15 minutes.
A bot running on your home computer stops answering when the computer is off. To keep it running all the time, you host it on a server. On 67hosting a bot is a regular app: upload the code, set the token, and the bot is live.
Webhook or long polling
Telegram delivers messages to a bot in two ways, and that decides which hosting mode to choose:
| Method | How it works | Mode on 67hosting |
|---|---|---|
| Webhook | Telegram itself sends every update to your bot's address | Free — the bot wakes up on Telegram's request |
| Long polling | The bot keeps asking Telegram for new messages | Always-on — needs a container running around the clock |
Why. A free app sleeps after 15 minutes without incoming HTTP requests and wakes on the next one. With a webhook, every update is an incoming request, so the bot wakes up by itself. With long polling there are no incoming requests, so the bot falls asleep and stops answering.
If you're just starting out, build the bot on a webhook: it's free. Most libraries (aiogram, python-telegram-bot, grammY, Telegraf) support both methods.
Step 1. Prepare the bot
- Create a bot with @BotFather and get its token.
- Make sure the bot:
- reads the token from an environment variable such as
BOT_TOKENinstead of keeping it in the code; - starts an HTTP server on the port from the
PORTvariable; - answers a request to
/(with any status — this is the start-up check); - receives Telegram updates on a separate path such as
/webhook.
A Python example with aiohttp and aiogram 3 — just the skeleton, no handlers:
import os
from aiohttp import web
from aiogram import Bot, Dispatcher
from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application
bot = Bot(os.environ["BOT_TOKEN"])
dp = Dispatcher()
async def health(request):
return web.Response(text="ok")
app = web.Application()
app.router.add_get("/", health)
SimpleRequestHandler(dispatcher=dp, bot=bot).register(app, path="/webhook")
setup_application(app, dp, bot=bot)
web.run_app(app, port=int(os.environ.get("PORT", 8080)))
Step 2. Create the app and deploy the code
- In the dashboard, click “Create a site” → the “App” card.
- Set the address, for example
mybot— the bot will be atmybot.host67.com. - Choose Free for a webhook or Always-on for long polling. You only need a database if the bot stores data.
- Upload the code with
git push, the API or an AI agent — see the guide on deploying an app.
Pass the bot token as the BOT_TOKEN environment variable when deploying: via the X-App-Env header in the API, or ask your AI agent to set the variable.
Step 3. Set the webhook
Tell Telegram where to send updates. You do this once — open this link in your browser with your token and address filled in:
https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://mybot.host67.com/webhook
A response with "ok": true means you're done. Message the bot — it should reply. If the bot was asleep, the first reply comes with a short delay.
Waking up must take less than 30 seconds. If your bot takes longer to start (for example, it loads a large model), switch on always-on mode. Telegram retries delivery if the bot doesn't answer, so the message isn't lost.
Long polling: switch on always-on
If your bot uses long polling, choose the Always-on plan when creating the app, or switch it on later on the “Apps” tab with “Enable always-on”. The price depends on memory size and region — see pricing. It's charged from your balance every 30 days.
Even a long-polling bot should answer an HTTP request to / on the PORT port — otherwise the dashboard shows it as not running.
FAQ
Can I host a Telegram bot for free?
Yes, if the bot works via webhook: a free app sleeps without requests, but every message from Telegram wakes it up. A long-polling bot needs paid always-on mode.
Why did my bot stop answering after 15 minutes?
Most likely the bot uses long polling on the free plan: without incoming HTTP requests the app sleeps after 15 minutes. Switch the bot to a webhook or turn on always-on mode.
Which region should I choose for a bot?
If the bot calls the OpenAI or Anthropic API, choose Europe or the US. Otherwise pick the region closest to your users.
Can the bot store data in a database?
Yes. Tick “Postgres database” when creating the app — the database address will be in the DATABASE_URL variable.
Try it on your own site
Free, no card: a site on a *.host67.com address with SSL in a couple of minutes.
Start for free