Skip to main content
Version: 1.2.0

Getting Started

Create a New Bottender App

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

It initializes your development environment for the latest Bottender features, provides a great experience for multiple channels 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 your go through the interactive creation, you will see a directory named my-app containing a fresh Bottender project with every Bottender’s dependency installed:

Running the bot in "Console Mode" is the easiest way. To do this, pass --console option to the command:

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

As you can see, we just got a bot that always replies "Welcome to Bottender" in the console.

Teach Your Bot to Echo

What we did in the previous section is just a "Hello World" example. Let's see how it works and try to make some changes to it.

src/index.js is the entry point of the app created by Create Bottender App. There are only few lines of code in this file:

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

It's very intuitive that it always replies "Welcome to Bottender" whenever it is called.

The next step is teaching your bot to send back what it receives, so let's open the src/index.js file on the editor and apply 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);
+ }
});

And the application will be restarted automatically.

That's it!

You can learn more about Create Bottender App from its README.