Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: 'ltsubdomain',
alias: 's',
args: 1,
description:
'Custom subdomain for the localtunnel.me URL. This option can only be used together with --lt.',
type: String,
defaultValue: null,
},
]);
if (ops.lt === false && ops.ltsubdomain !== null) {
console.log('error: --ltsubdomain can only be used together with --lt.');
process.exit();
}
const controller = Botkit.facebookbot({
debug: true,
log: true,
access_token: process.env.page_token,
verify_token: process.env.verify_token,
app_secret: process.env.app_secret,
validate_requests: true, // Refuse any requests that don't provide the app_secret specified
});
const dialogflow = require('../')({
keyFilename: process.env.dialogflow,
});
controller.middleware.receive.use(dialogflow.receive);
const bot = controller.spawn({});
/* eslint-disable brace-style */
/* eslint-disable camelcase */
// CONFIG===============================================
/* Uses the slack button feature to offer a real time bot to multiple teams */
var Botkit = require('botkit')
var mongoUri = process.env.MONGODB_URI || 'mongodb://localhost/botkit-demo'
var db = require('../../config/db')({mongoUri: mongoUri})
var controller = Botkit.facebookbot({
debug: true,
access_token: process.env.FACEBOOK_PAGE_TOKEN,
verify_token: process.env.FACEBOOK_VERIFY_TOKEN,
storage: db
})
var bot = controller.spawn({})
// SETUP
require('./facebook_setup')(controller)
// Conversation logic
require('./conversations')(controller)
// this function processes the POST request to the webhook
var handler = function (obj) {
token: process.env.token,
});
/* FB MESSENGER */
var fbBotOptions = {
debug: true,
log: true,
access_token: process.env.fbAccessToken,
verify_token: process.env.fbVerifyToken,
app_secret: process.env.fbAppSecret,
validate_requests: true
};
var fbController = Botkit.facebookbot(fbBotOptions);
var fbBot = fbController.spawn({
});
fbController.setupWebserver(
3000,
(err, webserver) => {
fbController.createWebhookEndpoints(webserver, fbBot);
}
);
var dialogflowMiddleware = require('botkit-middleware-dialogflow')({
token: process.env.dialogflow,
});
(isDev && process.env.ENABLE_TUNNEL) || argv.tunnel
? require('ngrok')
: false;
// const ngrok = false;
const { resolve } = require('path');
const webserver = express();
const passport = require('passport');
const isAuth = require('./authentication/isAuthenticated');
/**
* Botkit
*/
const Botkit = require('botkit');
const controller = Botkit.facebookbot({
debug: true,
verify_token: 'null',
access_token: 'null',
});
webserver.use(
bodyParser.urlencoded({
parameterLimit: 10000,
limit: '2mb',
extended: true,
}),
);
webserver.use(bodyParser.json());
webserver.use(passport.initialize());
const localSignupStrategy = require('./authentication/local-signup');
// CLOSE THE BOT IF IT FAILS TO RECONNECT
slackController.on('rtm_reconnect_failed', function(bot) {
throw new Error('RTM failed to reconnect. Closing the bot...');
});
// FB MESSENGER
var fbBotOptions = {
debug: true,
log: true,
access_token: process.env.fbAccessToken,
verify_token: process.env.fbVerifyToken,
app_secret: process.env.fbAppSecret,
validate_requests: true,
};
var fbController = Botkit.facebookbot(fbBotOptions);
var fbBot = fbController.spawn({});
fbController.setupWebserver(
process.env.PORT || 5000,
(err, webserver) => fbController.createWebhookEndpoints(webserver, fbBot)
);
// LOAD 'SpellChecker' MIDDLEWARE
var spellCheckerMiddleware = require('./spell-checker-middleware.js')();
// LOAD 'Dialogflow' MIDDLEWARE
var dialogflowMiddleware = require('botkit-middleware-dialogflow')({
token: process.env.dialogflow,
sessionIdProps: ['channel'],
});
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const Botkit = require('botkit');
const controller = Botkit.facebookbot({
access_token: process.env.FB_ACCESS_TOKEN,
verify_token: process.env.FB_VERIFY_TOKEN
});
const bot = controller.spawn();
controller.hears('(.*)', 'message_received', async (bot, message) => {
if (message.watsonError) {
console.log(message.watsonError);
bot.reply(message, message.watsonError.description || message.watsonError.error);
} else if (message.watsonData && 'output' in message.watsonData) {
bot.reply(message, message.watsonData.output.text.join('\n'));
} else {
console.log('Error: received message in unknown format. (Is your connection with Watson Assistant up and running?)');
bot.reply(message, 'I\'m sorry, but for technical reasons I can\'t respond to your message');
}
});