Phones and mobile apps2 minutes to read

How do I host a Telegram bot from my phone?

Create the bot with BotFather in Telegram, put the code on GitHub, and run it 24/7 from the Bothosting app on iPhone or Android, all from your phone.

BotFather and the Bothosting app cover all of it

Create the bot with BotFather inside the Telegram app, then run its code on a host and control it from the iOS app or the Android app. The host keeps the bot answering when your phone is locked, offline or out of battery. A polling bot is the simplest choice. It needs no domain or HTTPS address and runs on the free Spark plan.

Set it up in five steps

  1. In Telegram, open @BotFather, send /newbot and copy the token it returns.
  2. Put your bot’s code in a GitHub repository, public or private, using github.com in your phone’s browser. Keep the token out of the code.
  3. In the Bothosting app, tap New deployment, choose Telegram bot and pick the Node.js or Python polling profile.
  4. Open Deploy and connect the repository and branch. Then open Token & variables and paste the token into TELEGRAM_BOT_TOKEN.
  5. Tap Start, open Logs, and send /start to your bot in a private chat.

Allow notifications when the app asks. Your phone is then alerted if the bot stops unexpectedly. To ship changes without touching the app, add the GitHub push webhook on the website. Each commit then redeploys the bot.

Read the token from the environment

Python (aiogram or python-telegram-bot)
import os
TOKEN = os.environ['TELEGRAM_BOT_TOKEN']
Node.js (grammY or Telegraf)
const token = process.env.TELEGRAM_BOT_TOKEN;

If the bot runs but never replies, an old webhook may still be registered for the token. A webhook and polling can’t both receive updates. See polling or webhook and switching a bot to polling.

Test from the same phone

Keep Logs open in the Bothosting app, switch to Telegram and send a command. Each message should leave a line in Logs, and the reply should arrive in the chat. If Logs shows an error, tap Copy logs and paste the lines into your notes or an assistant. Remove any token before you share them.