Skip to content

Latest commit

 

History

History
91 lines (63 loc) · 2.08 KB

README.md

File metadata and controls

91 lines (63 loc) · 2.08 KB

Bottender Botanalytics

npm Build Status License: MIT

Middleware for using Botanalytics with Bottender.

Installation

npm install bottender-botanalytics

Example

const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/express');
const botanalyticsMiddleware = require('bottender-botanalytics/express');

const bot = new MessengerBot({
  accessToken: '__FILL_YOUR_TOKEN_HERE__',
  appSecret: '__FILL_YOUR_SECRET_HERE__',
});

bot.onEvent(async context => {
  await context.sendText('Hello World');
});

const server = createServer(bot, {
  verifyToken: '__FILL_YOUR_VERIFY_TOKEN_HERE__',
  webhookMiddleware: botanalyticsMiddleware(bot, {
    apiKey: '__FILL_YOUR_BOTANALYTICS_TOKEN_HERE__',
  }),
});

server.listen(5000, () => {
  console.log('server is running on 5000 port...');
});

Server

Supported servers:

  • express
  • koa
const botanalyticsMiddleware = require('bottender-botanalytics/express');
const botanalyticsMiddleware = require('bottender-botanalytics/koa');

Contributing

Pull Requests and issue reports are welcome. You can follow steps below to submit your pull requests:

Fork, then clone the repo:

git clone [email protected]:your-username/bottender-botanalytics.git

Install the dependencies:

cd bottender-botanalytics
yarn

Make sure the tests pass (including eslint, flow checks and jest tests):

yarn test

Make your changes and tests, and make sure the tests pass.

License

MIT © Yoctol