Node.js

Free Node.js Telegram bot hosting.

Telegraf, grammY, or the raw Bot API over fetch. Upload a package.json, name your entry file, and it polls for updates around the clock.

Libraries

Libraries that run here

Telegraf

The long-established Node framework for the Bot API. Middleware, scenes and sessions, and the library most Node Telegram tutorials assume.

grammY

A newer take with first-class TypeScript types and a plugin system. Lighter than Telegraf and clearer about what it does at runtime.

node-telegram-bot-api

A thinner wrapper for people who want the API surface and none of the framework. Fine choice if your bot is a handful of commands.

Deploying

Getting it running

  1. 1

    Upload your project

    Drag the folder into the file manager or push it over SFTP. Leave node_modules behind — it is installed for you on deploy and would waste your disk quota.

  2. 2

    Dependencies install themselves

    Your package.json is read and installed before the bot starts. A Telegram library is a small dependency tree, so this is quick.

  3. 3

    Point us at your entry file

    Usually index.js. Your BotFather token goes into an environment variable and is read from process.env, so it never sits in a file you might commit.

Memory

What actually fits in 256 MB

Far more than you will need. Node's baseline is small, a Telegram library caches nothing on your behalf, and long polling is one open request at a time. A bot serving thousands of daily users typically sits in tens of megabytes, not hundreds.

The way a Node Telegram bot runs out of memory is almost always session storage. The in-memory session middleware every framework ships with is a plain object keyed by chat id, and it keeps every conversation forever, including the ones from people who messaged the bot once in March. Give it a TTL, or move it to a file-backed store on your 512 MB of disk.

The other one is media. Downloading a file into a Buffer holds the whole thing in memory at once; streaming it to disk and back out does not. On a bot that forwards video, that difference is the difference between running and being killed.

FAQ

Questions

Telegraf or grammY?

grammY if you are writing TypeScript or starting fresh — the types are better and the runtime is lighter. Telegraf if you are following an existing tutorial or porting code, because there is far more of it written against Telegraf. Both poll happily on this allocation.

Do I need to upload node_modules?

No. Upload your source and your package.json and the dependencies install on deploy. A Telegram bot's dependency tree is small, so this takes seconds rather than the minutes a Minecraft bot needs.

Can I write it in TypeScript?

Yes, and grammY in particular is built for it. Compile to JavaScript before uploading and point us at the compiled entry file — what runs on the server is the output, not the TypeScript.

How do I keep sessions between restarts?

Write them to disk rather than holding them in a variable. Your server keeps its files across restarts and crashes, so a small JSON file or a SQLite database in your project directory survives everything an in-memory object does not.

Will one process handle several thousand users?

Comfortably, if your handlers do not block. Node is single-threaded, so one slow synchronous operation stalls every other user's update behind it. Keep the work asynchronous and 25% of a core goes a long way.

More on Telegram bots

Hosting something else?