In this guide we'll show you how to get up and running quickly. Read our Welcome page first if you just want to know what Botonic is about.
Let's get started!
Step 1 – Install the Botonic CLI
Open a terminal and run this command to install the CLI:
- NodeJS version >= 10 required
- Mac/Linux users might need to run this command with
Don't want to install?
You can use botonic with
npx @botonic/cli <command>
Step 2 – Create a Bot
Create a new Botonic project based on the "blank" template by running:
This command will scaffold a new Botonic project in
myBot folder and install its dependencies.
- It might take 2-3 minutes to complete
- You can run this command without the last argument to see the list of all templates available:
botonic new myBot
Step 3 – Run Your Bot
Now everything is ready to run your bot:
- Start the local development server:
Windows users might need to use the alternative
npm run start
- Open http://localhost:8080/ in your web browser. You'll see the Botonic logo at the bottom-right corner, click on it to open the chat interface and start talking.
You'll notice that the bot doesn't understand anything you say, that's fine. In Botonic there are two main concepts that need to be defined in order to add functionality to your bot: routes and actions. If those are not defined, any user input will fallback to the "404" route that responds "I don't understand you" by default.
You can leave the
botonic serve process running while you edit the code, the browser will auto-refresh the page when it detects changes in the source files.
Step 4 – Add a new route and action
- Edit the file
src/routes.jswith your favourite editor and add a new route:
- Go back to the browser and try typing "Hi there!":
The route we just defined indicates that any input text matching the regex
/hi/i will be responded by the text "Hello! Nice to meet you ;)", defined in the
Actions are just React components that can run random JS code (fetching data from APIs, etc) and return components supported by messaging channels, like
- Routes are not limited only to regex, you can also use functions, intents trained by NLU models and more.
- For simplicity sake we've defined everything in the same file, but typically actions live in their own file under
Where to go from here
Cool, now you have a bot prototype working on your local browser. What can you do next: