Order

Help

How to run a Telegram bot on a server so that it works 24/7

A bot started on a laptop goes off together with the laptop. On a server it runs around the clock and comes back by itself after a failure. All it needs is the code in a repository.

What to prepare

  1. A GitHub repository with the bot's code. It may be private.
  2. A dependency file: requirements.txt for Python or package.json for Node.js.
  3. The bot token from @BotFather. It is best read in the code from an environment variable such as BOT_TOKEN and not kept in the repository.

How to start

  1. Open the bot hosting page and pick a plan. Mini is enough for most bots.
  2. When ordering choose the app Your Telegram bot.
  3. Give the link to the repository, the variables and, if needed, the start command, for example python main.py or npm start.
  4. After the payment we clone the code, install the dependencies and start the bot as a system service.

What next

The bot's logs show in the panel. Push your changes to GitHub, update in one click in the panel, and the bot restarts with the new code. After a failure or a server reboot it comes back by itself.

If the bot needs a database or webhooks

The bot gets a whole server with root access. Next to it you can put PostgreSQL or Redis, open a port for webhooks and run a few more bots. The server has an address of its own and a free name on pirs.dev.

Questions

What does it cost to keep a bot on a server?

From $6.99 a month on the Mini plan: 1 GB of memory is enough for most bots.

Will it do for a Discord bot?

Yes. Any bot in Python or Node.js from GitHub runs.

Can I do without GitHub?

Yes. You have root access: upload the files over SFTP and start the bot yourself.

How do I update the bot?

Push the changes to the repository and update the bot in one click in the panel.

More in the help