Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { Bot } = require('bottender');
const { createServer } = require('bottender/koa');
const { FacebookConnector } = require('bottender-facebook');
const { isError613 } = require('messenger-batch');
require('dotenv').config();
const ACCESS_TOKEN = process.env.ACCESS_TOKEN;
const APP_SECRET = process.env.APP_SECRET;
const VERIFY_TOKEN = process.env.VERIFY_TOKEN;
const bot = new Bot({
connector: new FacebookConnector({
accessToken: ACCESS_TOKEN,
appSecret: APP_SECRET,
batchConfig: {
delay: 1000,
shouldRetry: isError613, // (#613) Calls to this api have exceeded the rate limit.
retryTimes: 2,
},
}),
});
bot.onEvent(async context => {
console.log(context.event);
if (context.event.isCommentAdd && !context.event.isSentByPage) {
try {
const { TelegramBot } = require('bottender');
const bot = new TelegramBot({
accessToken: '__FILL_YOUR_TOKEN_HERE__',
});
bot.onEvent(async context => {
await context.sendText('Hello World');
});
bot.createLongPollingRuntime({
limit: 10, // Limits the number of updates to be retrieved. Defaults to 100.
timeout: 60, // Timeout in seconds for long polling. Defaults to 0.
allowed_updates: ['message', 'callback_query'], // List the types of updates you want your bot to receive
});
const { ConsoleBot } = require('bottender');
const handler = require('./handler');
const bot = new ConsoleBot();
bot.onEvent(handler);
module.exports = bot;
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 handler = new TelegramHandler()
.onText(/yo/i, async context => {
const options = {
parse_mode: 'Markdown',
};
await context.sendMessage('*Hi* there!', options);
})
.onEvent(async context => {
await context.sendMessage("Sorry, I don't know what you say.");
});
bot.onEvent(handler);
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/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, { ngrok: true });
server.listen(5000, () => {
console.log('server is running on 5000 port...');
});