How to use the bottender/koa.createServer function in bottender

To help you get started, we’ve selected a few bottender examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bottenderjs / bottender-facebook / examples / multi-pages / server.js View on Github external
}),
});

bot.onEvent(async context => {
  if (context.event.isCommentAdd && !context.event.isSentByPage) {
    try {
      await context.sendPrivateReply('OK!');
      await context.sendComment('Public reply!');
      await context.sendLike();
    } catch (err) {
      console.log(err);
    }
  }
});

const server = createServer(bot, { verifyToken: VERIFY_TOKEN });

module.exports = server;
github bottenderjs / bottender-facebook / examples / facebook-batch / server.js View on Github external
bot.onEvent(async context => {
  console.log(context.event);

  if (context.event.isCommentAdd && !context.event.isSentByPage) {
    try {
      await context.sendPrivateReply('OK!');
      await context.sendComment('Public Reply!');
      await context.sendLike();
    } catch (err) {
      console.log(err.response.data);
    }
  }
});

const server = createServer(bot, { verifyToken: VERIFY_TOKEN });

module.exports = server;
github bottenderjs / bottender-facebook / examples / single-page / server.js View on Github external
bot.onEvent(async context => {
  console.log(context.event);

  if (context.event.isCommentAdd && !context.event.isSentByPage) {
    try {
      await context.sendPrivateReply('OK!');
      await context.sendComment('Public Reply!');
      await context.sendLike();
    } catch (err) {
      console.log(err.response.data);
    }
  }
});

const server = createServer(bot, { verifyToken: VERIFY_TOKEN });

module.exports = server;
github Yoctol / bottender / examples / server-koa / index.js View on Github external
const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/koa');

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);

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