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 createTextQuickReplies = (options) => options.map(option => new QuickReply({
title: option,
content_type: 'text',
payload: 'empty'
}))
//
// Initialize Wit.ai
// ---
// API Reference: https://wit.ai/docs
//
export const wit = new Wit({
accessToken: WIT_TOKEN,
actions: actions,
logger: new log.Logger(log.INFO)
})
// BOT TESTING MODE
if (TESTING_MODE) {
console.log('Bot testing mode!')
dbConnect()
interactive(wit)
}
return;
})
.catch(() => {
context.missingUrl = true;
})
.then(() => {
return context;
});
}
};
// Setting up our bot
const wit = new Wit({
accessToken: config.WIT_TOKEN,
actions,
logger: new log.Logger(log.INFO)
});
var app = express();
app.set('port', config.port);
app.use(bodyParser.json({verify: bot.verifyRequestMiddleware()}));
app.get('/', function (req, res) {
res.status(200).send('Hello world');
});
/*
* Use your own validation token. Check that the token used in the Webhook
* setup is the same token used here.
*
*/
app.get('/webhook', bot.verifyBotMiddleware());
if (!process.env.WIT_AI_TOKEN) {
throw new Error('No WIT_AI_TOKEN defined');
}
this.sendAction = sendAction;
this.wit = new Wit({
accessToken: process.env.WIT_AI_TOKEN,
actions: {
send: this.send.bind(this),
set_name: this.set_name.bind(this),
set_job: this.set_job.bind(this),
set_age: this.set_age.bind(this),
reset: this.reset.bind(this),
},
logger: new log.Logger(log.INFO),
});
this.sessions = new Sessions();
}