Closed kota-xbee closed 5 years ago
It is better to raise Slack related issues in botkit repository.
Thank you for your advice Naktibalda-san. I will raise it in botkit repository.
Im actually pretty sure this one is on the Watson side. In the past when I've heard this problem it is because the credentials for your cloud function are not getting set before the dialog node that does the callout. You should move the credentials to this node or a node that definitely gets hit in your flow (remember that the 'welcome' node does not get hit in slack because it is user initiated)
Thank you for your advice mitchmason-san. The reason is concern with credentials position. Which files do I have to modify? If you have a information about it please give example.
Where are you currently setting your cloud function credentials? You would need to set them somewhere in order for it to work in the try out panel. Most people do this on the welcome node, but I dont know if you are doing that or not.
You just need to make sure that your cloud function credentials are hit on a dialog node that occurs within the conversation with the user on slack.
Thank you for your kindness mitchmason-san. I have set credentials as below's youtube way. Are there any diffrence between my way of credentials setting and your setting way? https://youtu.be/Z2j1HKz2h0A
I am talking about the credentials used to connect dialog to your cloud function. it doesn't really matter the channel or how you connect, if the callout fails no response will be shown
It was very helpful mitchmason-san. I will check my credentials of cloud function in watson again.
I dont know where you are storing the credentials, most people just put them into context inside of a dialog node. You need to make sure that same dialog node gets activated during the conversation before the callout (or put them in the same node as the callout) if that node does not get activated, then the creds are never set and the callout will fail
dear mitchmason-san. What you mean the code as below?
require('dotenv').load();
var Botkit = require('botkit');
var express = require('express');
var middleware = require('botkit-middleware-watson')({
username: process.env.ASSISTANT_USERNAME,
password: process.env.ASSISTANT_PASSWORD,
workspace_id: process.env.WORKSPACE_ID,
url: process.env.ASSISTANT_URL || 'https://gateway.watsonplatform.net/assistant/api',
version: '2018-07-10'
});
// Configure your bot.
var slackController = Botkit.slackbot();
var slackBot = slackController.spawn({
token: process.env.SLACK_TOKEN
});
slackController.hears(['.*'], ['direct_message', 'direct_mention', 'mention'], function(bot, message) {
slackController.log('Slack message received');
middleware.interpret(bot, message, function() {
if (message.watsonError) {
console.log(message.watsonError);
bot.reply(message, message.watsonError.description || message.watsonError.error);
} else if (message.watsonData && 'output' in message.watsonData) {
bot.reply(message, message.watsonData.output.text.join('\n'));
} else {
console.log('Error: received message in unknown format. (Is your connection with Watson Conversation up and running?)');
bot.reply(message, 'I\'m sorry, but for technical reasons I can\'t respond to your message');
}
});
});
slackBot.startRTM();
// Create an Express app
var app = express();
var port = process.env.PORT || 5000;
app.set('port', port);
app.listen(port, function() {
console.log('Client server listening on port ' + port);
});
This is nothing to do with bot kit, slack, etc., it is 100% in your Watson Assistant Dialog.
In a dialog node you have to store your cloud function credentials, where are you doing that?
@mitchmason Are you sure that @kota-xbee is using cloud functions? I don't see any proof of that in his messages.
@kota-xbee Please explain how are you calling that webhook.
rereading it I guess not... its the only way too call directly from Watson, and I had just seen this same issue yesterday due to cloud functions, but reading the issue you're right they could be doing something with bot kit instead
I don't see any problem with the code @kota-xbee
dear all I'm very impressed with your support. Naktibalda-san this is my call for webhook
SLACK_URL = "****"
def send_slack(content):
payload = {
"text": content,
"icon_emoji": ':snake:',
}
data = json.dumps(payload)
requests.post(SLACK_URL, data)
if __name__ == '__main__':
main()
@mitchmason -san Is this fit for your advice?
This issue is fairly old and there hasn't been much activity on it. Closing, but please re-open if it still occurs.
In case I send message to bot at Slack it works. But I send message with incoming webhook it dosen't works.
Please tell me how to fix it