Botxona

How to deploy a grammY bot (Node.js) — grammY hosting on Botxona

grammY is a modern, fast-growing Telegram bot framework for Node.js/TypeScript. It needs no special settings to work with Botxona — Telegram requests are automatically routed through the platform proxy, so leave apiRoot unchanged.

Steps

1. Create the bot

const { Bot } = require("grammy")

const bot = new Bot(process.env.BOT_TOKEN)

bot.command("start", (ctx) => ctx.reply("Hi! I'm up and running."))

bot.start()

TypeScript works exactly the same way, just with import { Bot } from "grammy".

2. Use DATA_DIR

const path = require("path")
const fs = require("fs")

const DATA_DIR = process.env.DATA_DIR || "./data"
fs.mkdirSync(DATA_DIR, { recursive: true })
const dbPath = path.join(DATA_DIR, "bot.sqlite3")

3. package.json — a "start" script and pinned versions

{
  "name": "mening-botim",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "grammy": "1.30.0"
  }
}

The "start" script matters — Botxona looks for it first (entry point rule).

4. .env.example and upload

Document your bot's own settings in .env.example, zip the folder (don't include node_modules — dependencies are installed automatically, details) and upload it to the dashboard.

5. Check and trial

Read the results here, then test the bot in Telegram during the trial.

grammY runner (long-running polling)

For high-load bots, grammY's official @grammyjs/runner package is recommended — it handles more concurrent updates. It's fully compatible with Botxona, since all requests still go through the proxy automatically.

Scheduling with node-cron or setInterval

If you use node-cron or setInterval to send daily messages or reminders, Botxona detects it and switches the bot to always on. More: Sleep and wake-up.

Common errors

  • GrammyError: 401 Unauthorized — invalid token; see Getting a token.
  • Cannot find module 'grammy' — grammy isn't listed in package.json, or its version is written incorrectly.
  • The bot doesn't start, "missing start script" error — add "scripts": {"start": "node index.js"} to package.json.

Faster with AI

Give your code to an AI together with a ready-made task from the Prompt library to bring it up to Botxona standards automatically.

Next steps

Keeping your bot running 24/7 and the Dashboard tour.