CallbackContext
This page describes CallbackContext in zalo-bot-js, the context object passed to the callbacks of CommandHandler and MessageHandler.
CallbackContext helps callbacks quickly access application, bot and the list of args already separated from the command.
Key properties
applicationbotargs
Example with CommandHandler
ts
app.addHandler(new CommandHandler("start", async (update, ctx) => {
console.log(ctx.args);
await ctx.bot.sendMessage(update.message!.chat.id, "Xin chào!");
}));How args works
For example if the user submits:
text
/start demo valuethen ctx.args would be:
ts
["demo", "value"]When should you use it?
- callback needs to be reused
bot - callback needs to access
application - The command callback needs to read the parameters after the command
Next
- See CommandHandler to see when
CallbackContextis transmitted. - See Application to understand the relationship between context and app.
Last updated: April 5, 2026