Advanced usage

Command handling in group

For handling group/supergroup commands(/start@your_bot) you need to provide bot username.


// Provide with options
const app = new Telegraf(process.env.BOT_TOKEN, {username: 'your_bot'})

// Or you can get username from Telegram server
const app = new Telegraf(process.env.BOT_TOKEN)

app.telegram.getMe().then((botInfo) => {
  app.options.username = botInfo.username
})

app.command('start', (ctx) => ctx.reply('Hello World'))

Composer

Example

Router

Example