How to keep a Telegram bot running 24/7
Many people think "my bot has to run all the time", but for most bots that isn't actually necessary — this article explains why, how, and when you really need it.
First: do you really need "always on"?
On Botxona, bots stay awake by default as long as the server has enough memory, and respond instantly; when resources are needed, an idle bot may be put to sleep and wakes up within a few seconds when a message arrives (details). For a simple Q&A bot, an order-taking bot or an info bot, users will barely notice the difference — a sleeping bot only delays the first message by a few seconds.
When you do need always on:
- The bot must send messages or reminders on a schedule (e.g. every day at 09:00).
- The bot handles time-sensitive flows like payments or orders, where even a few seconds of delay is a problem.
- The bot must keep a persistent background connection to another service (e.g. a WebSocket).
Three ways to make a bot always on
1. Automatic detection (easiest)
If your code uses a time-based library such as APScheduler, node-cron, JobQueue or setInterval, Botxona detects it automatically and, in "Auto" mode, makes the bot always on — no extra configuration needed.
2. Explicitly in botxona.yaml
always_on: true
This is the most reliable way to make a bot always on, even if there's no scheduler in the code. More: botxona.yaml.
3. Manually in the dashboard
On the bot page, under Settings → Run mode, you can choose "Always on" — a setting you can change at any time without touching the code.
Business plan
Bots on the Business plan are always on regardless of settings — if continuous operation matters to your business, this is the most reliable option.
What happens if a scheduled task is missed?
If the bot is in "Auto" or "Sleep" mode and has fallen asleep due to inactivity when a scheduled task (e.g. a daily report) is due, the task won't run because the bot isn't awake. That's the expected behavior when you deliberately choose "Sleep" mode; if you don't want this, switch to "Always on" or add always_on: true to botxona.yaml.
How do I know my bot has stopped working?
For critical flows you can add a simple self-check to your bot (e.g. send the admin an "I'm up" message on every start). Sharp drops in the DAU and activity charts in analytics also help you spot problems early. In a crash loop (the bot crashes more than 5 times in 10 minutes), the system sends you a notification automatically (details).
Next steps
Depending on what your bot is written with, see the aiogram, python-telegram-bot, grammY or Telegraf guides.