Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// const adapter = new HangoutsAdapter({
// // enable_incomplete: true,
// token: process.env.GOOGLE_TOKEN,
// google_auth_params: {
// credentials: JSON.parse(process.env['GOOGLE_CREDS'])
// }
// });
// const adapter = new TwilioAdapter({
// // enable_incomplete: true,
// // twilio_number: process.env.TWILIO_NUMBER,
// // account_sid: process.env.TWILIO_ACCOUNT_SID,
// // auth_token: process.env.TWILIO_AUTH_TOKEN,
// });
const controller = new Botkit({
debug: true,
webhook_uri: '/api/messages',
disable_console: true,
adapter: adapter,
// disable_webserver: true,
// adapterConfig: {
// appId: process.env.APP_ID,
// appPassword: process.env.APP_PASSWORD
// },
storage
});
const cms = new BotkitCMSHelper({
uri: process.env.cms_uri,
token: process.env.cms_token,
});
const express = require('express');
const WatsonMiddleware = require('botkit-middleware-watson').WatsonMiddleware;
const middleware = new WatsonMiddleware({
iam_apikey: process.env.ASSISTANT_IAM_APIKEY,
workspace_id: process.env.WORKSPACE_ID,
url: process.env.ASSISTANT_URL || 'https://gateway.watsonplatform.net/assistant/api',
version: '2018-07-10'
});
// Configure your bot.
const adapter = new SlackAdapter({
clientSigningSecret: process.env.SLACK_CLIENT_SIGNING_SECRET,
botToken: process.env.SLACK_TOKEN,
});
const controller = new Botkit({
adapter,
storage: new MemoryStorage(),
// ...other options
});
controller.hears(['.*'], ['direct_message', 'direct_mention', 'mention'], async (bot, message) => {
console.log('Slack message received');
await middleware.interpret(bot, message);
if (message.watsonError) {
console.log(message.watsonError);
await bot.reply(message, message.watsonError.description || message.watsonError.error);
} else if (message.watsonData && 'output' in message.watsonData) {
await 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?)');