This tutorial shows how to keep your Telegram bot running in Replit using the Shell, so it stays active without needing the official Deployments feature.
Note:
- You need a Replit account and a working Telegram bot project. If you haven't built one yet, see How to Create a Telegram Bot on Replit first.
- Your bot token should be saved as a Secret with the key TOKEN. Add it under the Secrets tab if you haven't already.
- This method keeps your bot alive within an active Replit session. For permanent 24/7 uptime, see How to Deploy a Telegram Bot on Replit instead.
- Sign in at replit.com and open your Telegram bot project from the dashboard.
- In your workspace, click New Tab and select Shell tab to open a terminal session.
- In the Shell, run your bot using the command python bot/main.py. Your bot starts and begins polling for messages.
- To keep the bot running after detaching from the session, start a new screen by typing screen -S [botname] and pressing Enter, then run python bot/main.py inside it.
- Detach from the screen session by pressing Ctrl+A, then D. Your bot continues running in the background.
- Open Telegram and send your bot a test message - for example, /start or /help - to confirm it's active and responding.
.gif)
