Bot Development
Build handlers, middleware, and runtime flows using NxCreator’s Telegraf-based execution model.
NxCreator follows Telegraf’s event-driven model, but removes the boilerplate around runtime setup, connection handling, and deployment.
Overview
The legacy docs centered everything around one idea: if you know Telegraf-style handlers, you can build on NxCreator quickly. That is still the right starting point. Most bot features begin with commands, text listeners, actions, scenes, and database calls.
You do not manage webhook plumbing, polling lifecycle, or server process orchestration. The platform handles the runtime so your code can stay focused on bot behavior.
Handler model
Use the pre-initialized bot object to register handlers such as bot.command(), bot.hears(), bot.on(), and bot.action(). These behave like their Telegraf equivalents for the common Telegram update types.
For unmatched text input, a trailing bot.on('text') can act as a global fallback. Place it late in your code so it does not preempt more specific text handlers.
Middleware
Use bot.use() for cross-cutting logic that should run before the rest of your handlers. Common examples include ban checks, logging, rate-limiting, and request shaping.
Put middleware near the top of your bot logic so it wraps the handlers that follow.
Error handling
Use bot.catch() as the global error boundary for your bot code. Define your commands, scenes, and middleware first, then register the catch handler near the end of setup.
bot.on('text') fallback or misplaced middleware can change the behavior of everything beneath it. Order matters.How did this page feel?
Quick feedback helps improve the docs.