# Setup

> This skill should be used when the user asks to "install grammY", "create a Telegram bot", "set up my first bot", "verify grammY installation", "get a bot token", "BotFather", or needs to bootstrap a brand-new grammY project from zero to a running echo bot.

- Skill: `agents-store/setup-6` (Agent Skill)
- Install (CLI): `npx skillmds@latest add agents-store/setup-6`
- Raw SKILL.md: https://api.skillmd.com/api/skills/agents-store/setup-6/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: agents-store (https://skillmd.com/u/agents-store)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/agents-store/setup-6

---


# grammY — Setup

Bootstrap a grammY Telegram bot from zero. Five steps: install runtime, get a bot token from BotFather, install the package, write a minimal bot, run it and verify in Telegram.

## 1. Pick a runtime

grammY runs on **Node.js 18+**, **Deno 1.40+**, or **Bun 1.0+**. Pick one:

- **Node.js + TypeScript** — most common, biggest ecosystem.
- **Deno** — URL imports, no `node_modules`, native TypeScript.
- **Bun** — Node-compatible, faster cold start.

## 2. Get a bot token

Open [@BotFather](https://t.me/BotFather) in Telegram and send `/newbot`. Pick a display name and a username ending in `bot` (e.g. `my_awesome_bot`). BotFather replies with an API token in the form `123456:ABC-DEF...`. **Treat this as a secret** — put it in `.env`, never commit it.

## 3. Install grammY

```bash
# Node.js / Bun
npm install grammy

# Deno — import directly, no install step
# import { Bot } from "https://deno.land/x/grammy/mod.ts";
```

## 4. Write a minimal bot

### TypeScript (Node.js)

```typescript
// src/bot.ts
import { Bot } from "grammy";

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

bot.command("start", (ctx) => ctx.reply("Hi! I'm alive."));
bot.on("message", (ctx) => ctx.reply(`You said: ${ctx.message.text ?? "(non-text)"}`));

bot.start();
```

### JavaScript (Node.js)

```javascript
// src/bot.js
const { Bot } = require("grammy");

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

bot.command("start", (ctx) => ctx.reply("Hi! I'm alive."));
bot.on("message", (ctx) => ctx.reply(`You said: ${ctx.message.text ?? "(non-text)"}`));

bot.start();
```

### Deno

```typescript
// bot.ts
import { Bot } from "https://deno.land/x/grammy/mod.ts";

const bot = new Bot(Deno.env.get("BOT_TOKEN")!);

bot.command("start", (ctx) => ctx.reply("Hi! I'm alive."));
bot.on("message", (ctx) => ctx.reply(`You said: ${ctx.message.text ?? "(non-text)"}`));

bot.start();
```

## 5. Run and verify

```bash
# Node.js
BOT_TOKEN=123456:ABC-DEF... npx tsx src/bot.ts

# Bun
BOT_TOKEN=... bun run src/bot.ts

# Deno
BOT_TOKEN=... deno run --allow-net --allow-env bot.ts
```

Open Telegram, find your bot by its `@username`, send `/start`. You should see "Hi! I'm alive." Send any other message — the bot echoes it back.

**Verification checklist:**
- Process logs `[grammY] You can stop me by pressing Ctrl+C` (or similar) on startup.
- `/start` returns the welcome string within 1–2 seconds.
- Sending an arbitrary text message produces an echo.

If any of these fail, open the `troubleshoot` skill.

## Quick scaffold (bundled script)

This plugin ships a helper that does steps 3–4 for you:

```bash
${CLAUDE_PLUGIN_ROOT}/scripts/init-bot.sh /path/to/my-bot
cd /path/to/my-bot
cp .env.example .env  # then paste your BOT_TOKEN
npm install
npm run dev
```

The script creates `package.json`, `tsconfig.json`, `src/bot.ts`, `.env.example`, and `.gitignore`.

## What this skill does NOT cover

- Webhook deployment (use `deployment-hosting`).
- Sessions, conversations, or any plugin (use `plugins-catalog`, `sessions`, `conversations`).
- Telegram account automation (different concept — see the `tg-client` plugin).

