Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { MessengerBot, MessengerHandler } = require('bottender');
const { createServer } = require('bottender/express');
const config = require('./bottender.config').messenger;
const bot = new MessengerBot({
accessToken: config.accessToken,
appSecret: config.appSecret,
});
const handler = new MessengerHandler()
.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);
const server = createServer(bot, { verifyToken: config.verifyToken });
server.listen(5000, () => {
console.log('server is running on 5000 port...');
})
.onText('\/help', async context => {
await context.replyText(welcomeMessage)
})
.onText(async context => {
const text = context.event.text
const userId = context._session.user.id
const reply = await olami.nli(text, userId)
await context.reply([reply.toLineMessage()])
}
)
.onError(async (context, err) => {
await context.replyText('對不起唷~ 我需要多一點時間來處理 Q_Q')
})
exports.messengerHandler = new MessengerHandler()
.onText('\/help', async context => {
await context.sendText(welcomeMessage)
})
.onText(async context => {
const text = context.event.text
const userId = context._session.user.id
const reply = await olami.nli(text, userId)
await context.sendMessage(reply.toMessengerMessage())
})
.onError(async (context, err) => {
await context.sendText('對不起唷~ 我需要多一點時間來處理 Q_Q')
})