How to deploy a Telegram bot?
In this guide we build a bot from scratch and deploy it to EliteHost. Basic knowledge is enough — no Linux or VPS experience needed.
Creating a Telegram bot
in Telegram @BotFather — open it and /newbot — send the command. BotFather will ask you two things:
- Bot name — the name users see (e.g.:
My Bot) - Username —
_botmust end with (e.g.:mening_botim_bot)
Once created, BotFather token gives you. It looks like this:
7123456789:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsawNever share your token
Writing the bot code
Below are ready examples for the most popular libraries. Name the file main.py (Python) or index.js (Node.js) — the system finds it automatically.
aiogram 3.xRecommended
# main.py
import asyncio
import logging
import os
from aiogram import Bot, Dispatcher, types
from aiogram.filters import CommandStart
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
logging.basicConfig(level=logging.INFO)
# Token muhit o'zgaruvchisidan olinadi — kodga yozmang!
TOKEN = os.getenv("BOT_TOKEN")
if not TOKEN:
raise RuntimeError("BOT_TOKEN o'zgaruvchisi topilmadi")
dp = Dispatcher()
@dp.message(CommandStart())
async def start(message: types.Message) -> None:
await message.answer(
f"Salom, <b>{message.from_user.full_name}</b>! 👋\n"
"Men EliteHost'da ishlayapman."
)
@dp.message()
async def echo(message: types.Message) -> None:
await message.answer(message.text or "Matn yuboring")
async def main() -> None:
bot = Bot(TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())pyTelegramBotAPI
# main.py
import os
import telebot
TOKEN = os.getenv("BOT_TOKEN")
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=["start"])
def start(message):
bot.reply_to(message, "Salom! Men EliteHost'da ishlayapman.")
@bot.message_handler(func=lambda m: True)
def echo(message):
bot.reply_to(message, message.text)
# infinity_polling — tarmoq uzilsa avtomatik qayta ulanadi
bot.infinity_polling(skip_pending=True)python-telegram-bot
# main.py
import os
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text("Salom! Men EliteHost'da ishlayapman.")
def main() -> None:
app = Application.builder().token(os.getenv("BOT_TOKEN")).build()
app.add_handler(CommandHandler("start", start))
app.run_polling()
if __name__ == "__main__":
main()Node.js (Telegraf)
// index.js
import { Telegraf } from 'telegraf';
const token = process.env.BOT_TOKEN;
if (!token) {
throw new Error("BOT_TOKEN o'zgaruvchisi topilmadi");
}
const bot = new Telegraf(token);
bot.start((ctx) => ctx.reply("Salom! Men EliteHost'da ishlayapman."));
bot.on('text', (ctx) => ctx.reply(ctx.message.text));
bot.launch();
// To'g'ri to'xtatish
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));Preparing the dependencies file
For Python projects requirements.txt — create it. It lists the libraries you use with their versions:
aiogram==3.15.0And for Node.js — package.json:
{
"name": "mening-botim",
"version": "1.0.0",
"type": "module",
"main": "index.js",
"dependencies": {
"telegraf": "^4.16.3"
}
}Pin the version
aiogram==3.15.0 — pin an exact version. Otherwise your bot may break unexpectedly when the library updates.Preparing the ZIP archive
Your project folder should look like this:
mening-botim/ ├── main.py ← entry file ├── requirements.txt ← dependencies ├── handlers/ ← additional modules (optional) │ └── admin.py └── data/ ← data files (optional)Folder inside — select the files and zip them (not the folder itself — though the system handles both correctly).
Don't add to the archive
- ·
venv/,.venv/— virtual environment - ·
node_modules/— installed on the server - ·
.env— enter tokens via the panel - ·
__pycache__/,.git/
Uploading to EliteHost
- In the dashboard New server → Bot Hosting — choose the plan
- Choose an environment: Python, Node.js, Go, PHP, Java, .NET, Rust, Bun, or Ruby
- Choose the version (Python 3.12 recommended)
- Upload the ZIP file
After uploading Elite AutoDeploy analyzes the archive and shows you the result:
Setting environment variables
Settings → Environment variables go to the section and enter the needed values:
BOT_TOKEN=7123456789:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw ADMIN_ID=123456789 DATABASE_URL=sqlite:///data/bot.dbThese values are stored in the database AES-256-GCM encrypted and is decrypted only inside the container.
Launch and check
🚀 Launching the bot — click the button. The system will, in order:
- Creates the server (~30 seconds)
- Uploads the files
- Installs dependencies
- Starts the bot
The whole process live logs is shown. When it's done, send your bot in Telegram /start .
Bot not responding?
Common errors
Unauthorized / 401Cause: BOT_TOKEN is wrong or revoked.
Fix: Get a fresh token from @BotFather and update it in the Environment variables section.
ModuleNotFoundError: No module named 'aiogram'Cause: The library isn't listed in requirements.txt.
Fix: Add it to requirements.txt and click “Reinstall dependencies”.
Conflict: terminated by other getUpdates requestCause: A bot with the same token is running somewhere else.
Fix: Stop the copy on your computer or another server.
Killed / MemoryErrorCause: The bot exceeded the plan's RAM limit.
Fix: Upgrade to a higher plan or move large data into a database.