getting started

a bot from zero in about a minute. node 20+, esm only.

install

the core package is all you need to start. plugins are separate and opt-in.

terminal
pnpm add @yaebal/core

your first bot

create a bot with your token from @BotFather, register a couple of handlers, and start long-polling.

bot.ts
import { Bot } from "@yaebal/core";

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

bot.command("start", (ctx) => ctx.reply("hello 👋"));

bot.on("message:text", (ctx) => {
  console.log("got message:", ctx.text);
  ctx.reply(`you said: ${ctx.text}`);
});

bot.onStart((me) => console.log("bot ready"));

bot.start();
esm only. yaebal is "type": "module" with NodeNext resolution — use explicit .js specifiers in your own source.

run it

point an env var at your token and run with your favourite runtime:

terminal
BOT_TOKEN=123:abc node bot.js

webhooks

webhooks live in core. webhookCallback returns a fetch handler with a constant-time secret check, so it drops straight into Bun, Deno or Cloudflare Workers.

worker.ts
import { webhookCallback } from "@yaebal/core";

// any fetch-style runtime (Bun, Deno, Cloudflare Workers)
export default {
  fetch: webhookCallback(bot, { secretToken: process.env.WEBHOOK_SECRET }),
};

next

  • core concepts — the composer, derive/decorate, filter queries
  • contexts — the auto-generated context layer (the killer feature)
  • plugins — sessions, keyboards, scenes, i18n and more