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 } = 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...');
});
const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/express');
const config = require('./bottender.config');
const bot = new MessengerBot(config.messenger);
bot.onEvent(async context => {
await context.sendText('Hello World');
});
const server = createServer(bot, config);
server.listen(5000, () => {
console.log('server is running on 5000 port...');
});
const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/restify');
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...');
});
const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/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);
server.listen(5000, () => {
console.log('server is running on 5000 port...');
});
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, {
apiToken: '__FILL_YOUR_BOTANALYTICS_TOKEN_HERE__',
}),
});
server.listen(5000, () => {
const { parse } = require('url');
const nextjs = require('next');
const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/express');
const bot = new MessengerBot({
accessToken: '__FILL_YOUR_TOKEN_HERE__',
appSecret: '__FILL_YOUR_SECRET_HERE__',
});
bot.onEvent(async context => {
await context.sendText('Hello World');
});
async function createServerWithNext() {
const nextApp = nextjs({
dev: process.env.NODE_ENV !== 'production',
});
const handle = nextApp.getRequestHandler();
await nextApp.prepare();
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 { MessengerBot } = require('bottender');
const { createRequestHandler } = require('bottender/micro');
const bot = new MessengerBot({
accessToken: '__FILL_YOUR_TOKEN_HERE__',
appSecret: '__FILL_YOUR_SECRET_HERE__',
});
bot.onEvent(async context => {
await context.sendText('Hello World');
});
module.exports = createRequestHandler(bot);
const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/express');
const { getAttachment } = require('bottender/utils');
const config = require('./bottender.config').messenger;
const bot = new MessengerBot({
accessToken: config.accessToken,
appSecret: config.appSecret,
});
bot.onEvent(async context => {
if (context.event.text === 'video') {
const attachment = getAttachment('video.mp4');
await context.sendVideo({ attachment_id: attachment.id });
} else {
const attachment = getAttachment('bottender.png');
await context.sendImage({ attachment_id: attachment.id });
}
});
const server = createServer(bot, { verifyToken: config.verifyToken });
const { MessengerBot } = require('bottender');
const { createServer } = require('bottender/express');
const dashbotMiddleware = require('bottender-dashbot/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: dashbotMiddleware(bot, {
apiKey: '__FILL_YOUR_DASHBOT_KEY_HERE__',
platform: 'facebook',
}),
});