I receive 2 messages with each Slack message sent via Direct message to bot.
A couple of other users reported the same thing here https://docs.microsoft.com/en-us/bot-framework/channel-connect-slack and an _Older_ bot works fine and receives 1 message.
receive 1 message
{
"type": "message",
"timestamp": "2017-08-17T15:21:34.1389722Z",
"text": "hello",
"attachments": [],
"entities": [],
"sourceEvent": {
"SlackMessage": {
"type": "message",
"channel": "D6...06",
"user": "U0...C1",
"text": "hello",
"ts": "1502983293.000444",
"source_team": "T0...US",
"team": "T0...US"
},
"ApiToken": "xoxb-22...09-1fQ...R7J"
},
"address": {
"id": "925...310",
"channelId": "slack",
"user": {
"id": "U0...C1:T0...US",
"name": "paul"
},
"conversation": {
"isGroup": false,
"id": "B6...SA:T0...US:D6...06"
},
"bot": {
"id": "B6...SA:T0...US",
"name": "verlofbot"
},
"serviceUrl": "https://slack.botframework.com"
},
"source": "slack",
"agent": "botbuilder",
"user": {
"id": "U0...C1:T0...US",
"name": "paul"
}
}
{
"type": "message",
"timestamp": "2017-08-17T15:21:34.3226653Z",
"text": "hello",
"attachments": [],
"entities": [],
"sourceEvent": {
"SlackMessage": {
"token": "F80...gf7",
"team_id": "T0...US",
"api_app_id": "A6...RN",
"event": {
"type": "message",
"user": "U0...C1",
"text": "hello",
"ts": "1502983293.000444",
"channel": "D6...06",
"event_ts": "1502983293.000444"
},
"type": "event_callback",
"authed_users": [
"U6...SR"
],
"event_id": "Ev...DZ",
"event_time": 1502983293
},
"ApiToken": "xoxb-22...09-1fQ...R7J"
},
"address": {
"id": "09d...154",
"channelId": "slack",
"user": {
"id": "U0...C1:T0...US",
"name": "paul"
},
"conversation": {
"isGroup": false,
"id": "B6...SA:T0...US:D6...06"
},
"bot": {
"id": "B6...SA:T0...US",
"name": "verlofbot"
},
"serviceUrl": "https://slack.botframework.com"
},
"source": "slack",
"agent": "botbuilder",
"user": {
"id": "U0...C1:T0...US",
"name": "paul"
}
}
to overcome this I started filtering messages like that
bot.use({
botbuilder: (session, next) => {
if (session.message.address.channelId === 'slack') {
if (session.message.sourceEvent.SlackMessage) {
if (session.message.sourceEvent.SlackMessage.type === 'message') {
return;
}
}
}
next();
}
});
Glad to hear you found a way to get it working.
thanks for the update @spawn-guy
@JasonSowers @nwhitmont however, this is NOT a problem with my Bot.
I think this is a problem with Platform Itself! With the specific Slack channel. That exists with Newer deployments(connections). As I have another working Bot that doesn't require this hack/override.
PS: I haven't really found a page where I can report this problem other than here.
This is the correct place to report issues. 馃憤
update: I Stopped receiving double messages! Hurray!
However, I stopped receiving messages with type==message.... so I will update my snippet, as I was filtering out the wrong type of messages :/
@nwhitmont, @spawn-guy - I'm experiencing the same issue. Why was this closed? Was there ever a proper fix to this? Is it expected that we use @spawn-guy's monkey patch for the slack channel forever or until Slack changes something?
+1 to @astjohn message above. I am also having the same problem.
I'm seeing this as well, running a simple bot from the examples:
var restify = require('restify');
var builder = require('botbuilder');
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
var bot = new builder.UniversalBot(connector, function (session) {
console.log(session.message.text);
console.log(JSON.stringify(session.message, null, 2));
session.send("You said2: %s", session.message.text);
});
I'm also seeing this, though I am using C#. Will file a new issue.
Most helpful comment
@nwhitmont, @spawn-guy - I'm experiencing the same issue. Why was this closed? Was there ever a proper fix to this? Is it expected that we use @spawn-guy's monkey patch for the slack channel forever or until Slack changes something?