Host a Telegram bot 24/7
A Telegram bot either polls Telegram for updates or receives them on a public HTTPS webhook. Polling needs a process that never stops; a webhook also needs a stable HTTPS address. An EnvHaven workspace gives you both.
Updated November 23, 2026
Telegram offers bots two ways to receive messages, and the choice decides what hosting they need.
| Mode | How it works | What hosting it needs |
|---|---|---|
| Long polling | The bot asks Telegram for new updates in a loop | A process that runs continuously |
| Webhook | Telegram sends each update to your HTTPS URL | A server with a public HTTPS address that stays up |
Polling is the simplest to start with, since it needs no public address. A webhook is lighter on the machine and reacts faster, but the URL must be reachable over HTTPS with a valid certificate.
Hosting it on a workspace
An EnvHaven workspace covers both modes:
- Polling: run the bot in a terminal window. There is no idle shutdown, so it keeps polling after you close the tab.
- Webhook: bind the bot’s server to
0.0.0.0:3000. It is reachable athttps://preview-<workspace>.envhaven.app, which already has HTTPS, so you can register that address with Telegram’ssetWebhook.
Save the token as TELEGRAM_TOKEN in the workspace’s Vars pane first; it stays write-only and reaches every new shell. Then choose an agent from the Launch menu and let it write the bot, register the webhook and keep it running. A prompt such as “Write a python-telegram-bot bot that summarizes links sent to it; read the token from TELEGRAM_TOKEN; use a webhook on port 3000” is enough to start.
After a workspace restart or update, start the bot again, since a process in the terminal does not come back by itself. On a server you manage yourself, polling runs the same way under tmux or a service (the SSH guide covers both), and a webhook also needs a reverse proxy with a certificate in front of the bot’s port.
Bots that are themselves agents
If what you want is an AI assistant you message from Telegram, the assistant gateways in the workspace already speak to messaging apps. Choose Hermes Agent or OpenClaw from the Launch menu and Sign in runs its setup; from then on it answers from the workspace, around the clock.