Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to Slack #208

Open
phaniindra opened this issue Mar 27, 2020 · 4 comments
Open

Cannot connect to Slack #208

phaniindra opened this issue Mar 27, 2020 · 4 comments
Labels

Comments

@phaniindra
Copy link

phaniindra commented Mar 27, 2020

I have integrated the bot kit with Slack

Here is my CODE

const { Botkit } = require('botkit');
const { MemoryStorage } = require('botbuilder');
const { SlackAdapter } = require('botbuilder-adapter-slack');
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,
    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.middleware.receive.use(
    middleware.receive.bind(middleware),
);

controller.hears(['.*'], ['direct_message', 'direct_mention', 'mention', 'message_received'], 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?)');
        await bot.reply(message, 'I\'m sorry, but for technical reasons I can\'t respond to your message');
    }
});

Integrated with Slack configuration too. But when i sent a message to Bot. I couldn't catch the message to reply from watson assistant

Thanks.

@Naktibalda
Copy link
Contributor

receive and interpret are different names of the same method, there is no need to call it twice.

Do you see Slack message received in the output?

@phaniindra
Copy link
Author

No I didn't see any message on the console

@phaniindra
Copy link
Author

Hey, Any Update on this. Still same issue

@Naktibalda
Copy link
Contributor

It isn't fault of this middleware, it would be better to raise an issue in Botkit repo or ask for help in https://dev4slack.slack.com/

I think that it is possible that you missed correct message type in parameters of hears method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants