The Bot Object

The bot global is a pre-initialized Telegraf instance. Never import or recreate it.

Available methods

bot.command(trigger, handler)   // responds to /commands
bot.hears(pattern, handler)     // text match — string or RegExp
bot.on(event, handler)          // any Telegram update type
bot.action(data, handler)       // inline keyboard callbacks

Context object

Every handler receives a Telegraf ctx:

ctx.from.id            // Telegram user ID (number)
ctx.from.first_name    // user's first name
ctx.chat.id            // chat ID
ctx.message.text       // raw text content

Rich & new Telegram methods

The runtime passes through the latest Bot API methods. Use them directly on ctx or bot:

// Premium emoji in messages
ctx.reply('Hello 👋', { parse_mode: 'HTML' });

// Premium emoji inside inline keyboard buttons
ctx.reply('Pick one:', {
  reply_markup: {
    inline_keyboard: [[
      { text: '⭐ Premium', callback_data: 'premium' }
    ]]
  }
});

// Star payments / invoices
ctx.replyWithInvoice({
  title: 'Pro plan',
  description: 'Monthly subscription',
  payload: 'pro-monthly',
  currency: 'XTR',
  prices: [{ label: 'Pro', amount: 100 }]
});

// Rich message (formatted text + media)
bot.telegram.sendMessage(ctx.chat.id, 'Rich <b>formatted</b> message', { parse_mode: 'HTML' });

For the full Python-side reference (richMessage, starPayments, premium emoji sending, premium emoji in inline keyboards and more), see the Python docs →.

Practical notes

The legacy docs repeatedly treated NxCreator as “Telegraf logic with a few exceptions.” That is the right framing. Work with the provided bot object instead of creating a new bot instance or redoing setup that the platform already owns.

When you need handler-specific state, store it in the database or move the conversation into a scene rather than trying to keep cross-user mutable state in memory.

PREVIOUS
Bot Development
NEXT
Commands
Was this page helpful?
Last updated March 22, 2026