Build your first Console bot

Import ConsoleBot from bottender package and create a bot instance:

const { ConsoleBot } = require('bottender');

const bot = new ConsoleBot();

Then, define your handler function:

bot.onEvent(async context => {
  if (context.event.isText) {
    await context.sendText('received text.');
  } else if (context.event.isPayload) {
    await context.sendText('received payload.');

call createRuntime to start the interactive mode:



Sending Text

Send text to the bot. For example:


Sending Payload

Send payload to the bot. For example:


Fallback Unsupported Methods

ConsoleBot only has native support for sendText. After setting fallbackMethods to true, bot can call any methods on the context and fallback all of response to text:

const bot = new ConsoleBot({
  fallbackMethods: true,

bot.onEvent(async context => {
  await context.sendText('Hello World');
  await context.sendImage('');
  await context.sendButtonTemplate('What do you want to do next?', [
      type: 'web_url',
      url: '',
      title: 'Show Website',
      type: 'postback',
      title: 'Start Chatting',
      payload: 'USER_DEFINED_PAYLOAD',

It will get responses like below:

Bot > Hello World
Bot > sendImage: [""]
Bot > sendButtonTemplate: ["What do you want to do next?",[{"type":"web_url","url":"","title":"Show Website"},{"type":"postback","title":"Start Chatting","payload":"USER_DEFINED_PAYLOAD"}]]

It's helpful when you want to test bots of any platforms on the console.

Exit Runtime

To exit console runtime, just type /exit or /quit as message.