What you need before starting
- A small Linux server (1 GB of RAM is usually enough) or a container service.
- Your bot’s token, kept as an environment variable.
- Your code with pinned dependencies.
The steps, in short
- Take keys out of the code: read the token from the environment; never leave it written in the repository.
- Prepare the server and create a virtual environment with the dependencies.
- Choose how to receive messages: polling to start, or a webhook with a domain and HTTPS if you expect high volume.
- Run the bot as a service (systemd) with
Restart=always, so it comes back on its own if it fails or the server reboots. - Keep logs and check them with
journalctl; add error handling so an exception does not take the process down. - Respect the platform’s limits (rate limits) and retry with increasing waits.
- Automate deployment: a workflow that updates the code and restarts the service.
Common mistakes
- Running the bot with
python bot.pyinside an SSH session and losing it when you close it. - Using the same token in development and production: messages get stolen from each other.
- Keeping important state only in memory and losing it on every restart.
- Ignoring network errors and leaving the bot “hung” without reconnecting.
How we help
We leave your bot running 24/7, with automatic restart, logs and alerts if it stops responding.