Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const config = require('./bottender.config');
const server = express();
server.use(
bodyParser.json({
verify: (req, res, buf) => {
req.rawBody = buf.toString();
},
})
);
const bots = {
messenger: new MessengerBot(config.messenger).onEvent(handler),
line: new LineBot(config.line).onEvent(handler),
slack: new SlackBot(config.slack).onEvent(handler),
telegram: new TelegramBot(config.telegram).onEvent(handler),
viber: new ViberBot(config.viber).onEvent(handler),
};
registerRoutes(server, bots.messenger, {
path: '/messenger',
verifyToken: config.messenger.verifyToken,
});
registerRoutes(server, bots.line, { path: '/line' });
registerRoutes(server, bots.slack, { path: '/slack' });
registerRoutes(server, bots.telegram, { path: '/telegram' });
registerRoutes(server, bots.viber, { path: '/viber' });
server.listen(5000, () => {
console.log('server is listening on 5000 port...');
});
const { SlackBot, SlackHandler } = require('bottender');
const { createServer } = require('bottender/express');
const bot = new SlackBot({
accessToken: '__FILL_YOUR_TOKEN_HERE__',
verificationToken: '__FILL_YOUR_VERIFICATION_TOKEN_HERE__',
});
const handler = new SlackHandler()
.onText(/yo/i, async context => {
await context.sendText('Hi there!');
})
.onEvent(async context => {
await context.sendText("I don't know what you say.");
})
.onError(async context => {
await context.sendText('Something wrong happened.');
});
bot.onEvent(handler);