How to use the botbuilder-adapter-slack.SlackAdapter function in botbuilder-adapter-slack

To help you get started, we’ve selected a few botbuilder-adapter-slack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github watson-developer-cloud / botkit-middleware / examples / simple-bot / simple-bot-slack.js View on Github external
const { Botkit } = require('botkit');
const { MemoryStorage } = require('botbuilder');
const { SlackAdapter } = require('botbuilder-adapter-slack');

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);

botbuilder-adapter-slack

Connect Botkit or BotBuilder to Slack

MIT
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis