We believe the beginning of a successful bot has little to do with engineering and everything to do with the skill of the product owner in acquiring users and keeping them faster than their competition.
That's why we've open sourced our Facebook Messenger node.js code base so you can get all the latest features from API.AI, Facebook Messenger and Analytics like Dashbot and BotMetrics. While setting yourself up for success with a robust and extensible code base when you've tested your assumptions and are ready for an engineer to build domain specific features.
npm install botstack
Create index.js
file with this content:
const BotStack = require('botstack');
class ExampleBot extends BotStack {};
const bot = new ExampleBot('example-bot');
bot.startServer();
Before the start of the bot, we need to set a few environment variables:
FB_PAGE_ACCESS_TOKEN, FB_VERIFY_TOKEN, APIAI_ACCESS_TOKEN
If you don't want to set environment variables explicitly, you can use the dotenv
library.
Example:
.env
file in the root folder of your project
Example:
FB_PAGE_ACCESS_TOKEN=
FB_VERIFY_TOKEN=
APIAI_ACCESS_TOKEN=
require('dotenv').config();
class ExampleBot extends BotStack {};
const bot = new ExampleBot('example-bot'); bot.startServer();
3. Run
```bash
node index.js
Other examples you can find in the examples
folder of this repository.
It's still early days and everything we are learning on customers messenger bots we are trying to incorporate here. If you are using this source code and make enhancements please feed the changes back in. If you are more a product person message me or add your ideas under the issues.