tgx 0
TypeScript · on grammY · MIT

Build Telegram bots fast.

You describe a screen as a function of state. Navigation, menus, AI-chat UIs, files, payments and analytics come as defaults. Build a shop, an AI assistant, a form or a mini-app backend, not the boilerplate.

Get started npm i @tgxjs/core
52 lines, not 152.

The same AI image bot. tgx vs raw grammY, identical behavior.

01 — How it works

You describe one screen. The engine owns the request lifecycle.

Persistent state, button cleanup, payment matching and analytics are already on. This is the whole bot.

  bot.ts
import { screen, run } from "@tgxjs/core"; const chat = screen("chat") .mode("feed") // panel follows the newest reply .state({ model: "flux" }) .text(s => `Model: ${s.model}. Send a prompt.`) .pick("model", ["flux", "turbo"]) .onPrompt(async (c, p) => { await c.working("Generating…"); await c.image(generate(p, c.state)); }) .entry("/start"); run({ token, storage: "state.json" }, [chat]);
Model: flux. Send a prompt.
✓ fluxturbo
a red fox in the snow
▦ generated image
// kill the process → restart → the user resumes on the same screen.
02 — Built in

Everything a real Telegram app needs, on by default.

Screens & navigation.

A persistent go / back / replace stack. Users resume exactly where they were after a restart.

Menus.

The persistent bottom menu and the command menu, from one config.

Feed mode.

For AI assistants and generators: the control panel follows the newest reply.

Files & albums.

Eight media types normalized to one shape. Media groups buffered for you.

Stars payments.

successful_payment matched back to the right user's screen. No global handler.

Analytics.

Every step counted. Query the funnel with /stats. Zero tracking code.

03 — Built to be built by AI

One correct way, so your agent gets it right.

The API has no synonyms. An agent cannot pick the wrong pattern.

AGENTS.md

The build reference

Every button, menu and payment with copy-paste code and a Do-NOT list.

MCP

tgx on demand

Run npx @tgxjs/mcp. Claude Code and Cursor pull the reference on demand.

Cursor · Copilot

Drop-in rules

Your editor defaults to tgx for Telegram bots, out of the box.

Ship a bot today.

Read the docs npm i @tgxjs/core @tgxjs/kit