Skip to main content
Version: 1.5

Getting Started

Create a New Bottender App

Create Bottender App is the best way to start building a new app in Bottender.

It initializes your development environment for latest Bottender features, provides a great experience for multi-channel development, and optimizes your app for production deployment. To create a project, run:

npx create-bottender-app my-app

Note: npx comes with npm 5.2+ and higher, see npx command introduction.

After going through the steps, you see a directory named my-app containing a new Bottender project with every Bottender's dependency installed:

Running the bot in Bottender Console Mode is the easiest way to run the bot. To run in Console Mode, provide the --console option to the npm run dev command:

cd my-app
npm run dev -- --console

As you can see, you get a bot that always replies with the "Welcome to Bottender" to your console.

Teaching Your Bot to Echo

The next step is teaching your bot to send back what it receives. Let's see how the bot works before making any changes to the bot.

The src/index.js file is the entry point of the app created by Create Bottender App. You may find the following few lines of code in the src/index.js file:

module.exports = async function App(context) {
await context.sendText('Welcome to Bottender');
};

Whenever Bottender invokes the App function, the App function always calls context.sendText() to reply with the "Welcome to Bottender".

To make the bot send back what it receives, open the src/index.js file in your preferred code editor and apply the following changes to the code:

module.exports = async function App(context) {
- await context.sendText('Welcome to Bottender');
+ if (context.event.isText) {
+ await context.sendText(context.event.text);
+ }
});

After applying the changes, Bottender restarts the app automatically.

That's it! Now, you get a bot that can reply with what it receives to your console.

For more information about Create Bottender App, see the README file of Create Bottender App.