Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const FB_VERIFY_TOKEN = process.env.FB_VERIFY_TOKEN
export const FB_PAGE_TOKEN = process.env.FB_PAGE_TOKEN
export const FB_APP_SECRET = process.env.FB_APP_SECRET
export const FB_PAGE_TEST_TOKEN = process.env.FB_PAGE_TEST_TOKEN
export const FB_APP_TEST_SECRET = process.env.FB_APP_TEST_SECRET
export const WIT_TOKEN = process.env.WIT_TOKEN
const DASHBOT_KEY = process.env.DASHBOT_KEY
export const NODE_ENV = process.env.NODE_ENV
//
// Analytics
// ---
// Facebook Messenger
//
export const dashbot = Dashbot(DASHBOT_KEY).facebook
export function choosePageToken() {
return (NODE_ENV === 'production')
? FB_PAGE_TOKEN
: FB_PAGE_TEST_TOKEN
}
export function chooseAppSecret() {
return (NODE_ENV === 'production')
? FB_APP_SECRET
: FB_APP_TEST_SECRET
}
module.exports = function (controller) {
// Dashbot is a turnkey analytics platform for bots.
// Sign up for a free key here: https://www.dashbot.io/ to see your bot analytics in real time.
if (process.env.DASHBOT_API_KEY) {
var dashbot = require('dashbot')(process.env.DASHBOT_API_KEY).slack;
controller.middleware.receive.use(dashbot.receive);
controller.middleware.send.use(dashbot.send);
controller.log.info('Thanks for using Dashbot. Visit https://www.dashbot.io/ to see your bot analytics in real time.');
} else {
controller.log.info('No DASHBOT_API_KEY specified. For free turnkey analytics for your bot, go to https://www.dashbot.io/ to get your key.');
}
};
constructor(config) {
try {
this.dashbot = require('dashbot')(_.get(config, 'key')).alexa;
this.platformType = BaseApp.PLATFORM_ENUM.ALEXA_SKILL;
} catch (err) {
console.log('\nPlease install dashbot: npm install dashbot\n');
}
}
const fb = require('./fb');
const apiai = require('./api-ai.js');
const botmetrics = require('./bot-metrics.js');
const dashbot = require('dashbot')(process.env.DASHBOT_API_KEY).facebook;
const sessionStore = require('./session.js')();
const log = require('./log.js');
module.exports = (req, res, next) => {
console.log(' ');
console.log('===Received a message from FB');
res.end();
dashbot.logIncoming(req.body);
console.log(`JSON:${JSON.stringify(req.body)}`);
const entries = req.body.entry;
entries.forEach((entry) => {
const messages = entry.messaging;
messages.forEach((message) => {
constructor(config) {
try {
this.dashbot = require('dashbot')(_.get(config, 'key')).google;
this.platformType = BaseApp.PLATFORM_ENUM.GOOGLE_ACTION;
} catch (err) {
console.log('\nPlease install dashbot: npm install dashbot\n');
}
}
async post({ input, session, lastRoutePath, response }) {
const messageInDashbot = {
text: input.data,
userId: session.user.id
}
await dashbot.logIncoming(messageInDashbot)
const messageOutDashbot = {
text: response,
userId: session.user.id
}
await dashbot.logOutgoing(messageOutDashbot)
}
}
async post({ input, session, lastRoutePath, response }) {
const messageInDashbot = {
text: input.data,
userId: session.user.id
}
await dashbot.logIncoming(messageInDashbot)
const messageOutDashbot = {
text: response,
userId: session.user.id
}
await dashbot.logOutgoing(messageOutDashbot)
}
}