Skip to main content

Introduction

Button - base component of telegram bot. The demo available by video below:

Usage

index.ts
import { Telegraf } from "telegraph";
import { Button } from "@tlgr/button";

const bot = new Telegraf("TELEGRAM TOKEN");
const button = new Button(bot);

bot.command("start", (ctx) => {
bot.telegram.sendMessage(
ctx.chat.id,
"hello there! Welcome to button demo.",
{
reply_markup: {
inline_keyboard: [[button.render("DATA")]],
},
}
);
});

button.on("click", (ctx, button) => {
ctx.reply(`Congrats! Your are clicked with name: ${button.name} and payload: ${button.payload!.toString()}`);
});

Demo

button demo

Here You can find button example.

The source code of this example you can find at events page

````