How to put a Telegram bot on Node.js (Telegraf) online
Your Node.js bot is built: Telegraf answers commands, npm start brings the project up, and everything works locally. Then comes the usual question — where to keep it so it answers around the clock, not only while your laptop is open. The usual answer is to rent a VPS, install Node.js on the server, set up a process manager like pm2 and autostart. For a small bot that is disproportionately much.
A bot built with Telegraf or node-telegram-bot-api can go online without a server too. Let's walk through how to prepare a Node.js project and put it online so it runs on its own, without your computer and without manual setup.
Check your package.json and start command
Make sure package.json lists your dependencies (Telegraf or node-telegram-bot-api and everything else) and defines a start script — usually start. You do not need to put the node_modules folder in the archive: the platform installs dependencies from package.json and package-lock.json itself.
Move the bot token into an environment variable
Do not leave the token from BotFather in your code and do not commit it to the repository. Read it from process.env, for example process.env.BOT_TOKEN. When you set up the project, Netrun asks for this value and injects it as a secret outside your code.
Keep long polling mode
For a simple bot it is easier to run it in long polling mode — bot.launch() in Telegraf does exactly that. Then you do not need to run a web server, set up a webhook or open a port. This is the most trouble-free mode for hosting, and Telegraf uses it by default.
Remove hard-coded paths and ports
If your bot also brings up a web part, take the port from an environment variable rather than a hard-coded number. A pure long polling bot needs no port at all — the main thing is to not leave any paths or values in the code that are tied to your computer.
Upload the project to Netrun
Upload the code as a ZIP archive or by importing a GitHub repository — a private one works too. Netrun detects that this is Node.js, installs the dependencies and starts the bot. You do not need to pick a server, a Node.js version or a process manager by hand.
Start and check the bot
After the build the bot starts and begins answering in Telegram. The logs are visible in the dashboard in real time — if the bot stays silent, the reason will be clear. On the Free plan the bot runs around the clock: incoming messages keep it active, and you do not need to turn on a computer for that.
A Node.js bot needs neither pm2 on a rented VPS nor a laptop that is always on. Upload the code to Netrun, move the token into a secret — and your Telegraf bot will answer around the clock. One such bot runs on the Free plan at no cost.
Common questions
Where can you put a Node.js Telegram bot online?
On the Netrun Free plan you can keep one Node.js bot at no cost. The platform detects the language from package.json, installs the dependencies and starts the bot, which runs around the clock on Netrun servers rather than on your computer.
Does this work for Telegraf and node-telegram-bot-api?
Yes. Netrun runs any Node.js project regardless of the library. The main thing is to list the dependencies and the start script in package.json, move the token into an environment variable and keep long polling mode.
Do you need to set up pm2 and autostart?
No. The platform takes care of keeping the process alive and restarting it on failure. You do not need to install pm2, set up systemd or autostart the way you would on a VPS.
Should you put node_modules in the archive?
No. You do not need to upload the node_modules folder — Netrun installs the dependencies from package.json and package-lock.json during the build. This keeps the archive smaller and the build cleaner.
Will the bot keep working when your computer is off?
Yes. After you put it online the bot lives on Netrun servers, so it answers no matter whether your laptop is on, and it restarts itself if it crashes.