Host a Telegram bot as a worker

A long-polling bot is a persistent background process and does not need a regular web page. A webhook bot can instead use a web service that receives HTTPS requests.

1. Prepare the bot

Get a token through BotFather. Keep it out of GitHub and logs. Include the bot code, pinned dependencies and the startup command in your repository.

2. Choose Worker

Create a Worker service and connect the Git repository. Start Command must launch the actual process, such as python bot.py for Python. The code should keep running through a loop or a library polling function.

3. Configure credentials and resources

Store the token as a secret environment variable such as BOT_TOKEN and read that name in your code. Review worker limits and balance requirements for continuous operation.

4. Keep polling and webhooks separate

Telegram API does not allow getUpdates while a webhook is configured. Before removing an old webhook, check the service using it. Avoid accidentally running multiple polling copies with the same token.

5. Test in Telegram

After deployment, send /start and inspect runtime logs. If it fails, check the token variable name, dependency installation and startup command. Once the bot replies, also test a restart.

This is a hosting guide. Final verification with your token happens inside Telegram; this page does not promise compatibility with every bot implementation.