<!-- canonical: https://hostdc.xyz/host/telegram · last updated 2026-10-23 · HostDC, Hosting for Discord, Stoat and Telegram bots and other always-on apps. -->

# Host a Telegram bot

HostDC runs Telegram bots written in Python or Node.js. The bot asks Telegram for new messages by long polling, so it needs no webhook, no domain and no open port.

## Three steps

**1. Get a token from BotFather.** In Telegram open a chat with @BotFather and send `/newbot`. After two questions it sends you the bot's token. `/token` shows the token of a bot you already have.

**2. Bring your project.** The quickest start is a template: [Telegram bot (Python)](/templates/telegram-bot-py) or [Telegram bot (JavaScript)](/templates/telegram-bot-js). Both greet you on `/start` and answer `ping` with `pong`. To write your own, two files are enough:

```
requirements.txt
main.py
```

```python
import os
from telegram.ext import Application, MessageHandler, filters


async def ping(update, context):
    await update.message.reply_text("pong")


app = Application.builder().token(os.environ["TELEGRAM_BOT_TOKEN"]).build()
app.add_handler(MessageHandler(filters.Regex(r"(?i)^ping$"), ping))
app.run_polling(allowed_updates=["message"])
```

Put `python-telegram-bot` in `requirements.txt`. The same bot with grammY is `index.js` plus a `package.json` that lists `grammy`:

```js
const { Bot } = require("grammy");

const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN);
bot.hears(/^ping$/i, (ctx) => ctx.reply("pong"));
bot.start();
```

**3. Add the token and press Deploy.** On the Secrets tab, add an environment variable named `TELEGRAM_BOT_TOKEN` with the token as its value. We store it AES-256-GCM encrypted and never show it again. Press Deploy and we install your packages, start the entry file and stream the console.

## Libraries

- **Python:** python-telegram-bot, aiogram and pyTelegramBotAPI (imported as `telebot`) all install from PyPI like any package.
- **Node.js:** grammY, Telegraf and node-telegram-bot-api install from npm.

## Polling and webhooks

Long polling works on every plan and is what the templates use. With a webhook Telegram calls your bot instead of the bot asking, and that needs a public HTTPS address. Only Pro and Max bots get a web address, so on the other plans use polling.

Only one process can poll a token at a time. If your bot answers on your computer while you test, stop it there before you deploy, or Telegram rejects the second poller with a conflict error.

In groups, Telegram hides ordinary messages from a bot while its privacy mode is on. Send `/setprivacy` to @BotFather to switch it off.

## Limits you should know

The free plan gives a 256 MB RAM pool, 0.25 CPU and 1 GB storage, and needs reactivating every 30 days. Mini, Lite, Pro and Max are the paid plans: Lite is $1.69 a month and Pro is $2.79 a month. The [pricing page](/pricing) lists what each one changes.

## Related

- [Host a Python bot](/host/python)
- [Host a Node.js bot](/host/node)
- [Host a Stoat bot](/host/stoat)
- [Environment variables and tokens](/guides/environment-variables-and-tokens)

## FAQ

### Why does the token go in an environment variable?
The Bot token box on the Secrets tab fills `DISCORD_TOKEN`, which only Discord bots read. A Telegram bot reads `TELEGRAM_BOT_TOKEN`, so you add it as an ordinary variable in the list below that box.

### What if my token leaks?
Send `/revoke` to @BotFather. It issues a new token and the old one stops working. Put the new one in `TELEGRAM_BOT_TOKEN` and restart the bot.

### Which Python version should I pick?
3.13 unless a dependency of yours is not ready for it. python-telegram-bot 22 needs Python 3.10 or newer.
