Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Address TypeError seen in Issue 1447 #1453

Open
wants to merge 1 commit into
base: legacy
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lib/SlackBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,21 @@ function Slackbot(configuration) {
// Recent changes in Slack will break other integrations as they no longer
// require a bot and therefore Slack won't send the bot information.
if (payload.type === 'event_callback') {

if (!team.bot) {
slack_botkit.log.error('No bot identity found.');
return res.status(500).send();
}

bot.identity = {
id: team.bot.user_id,
name: team.bot.name
};
} else {
bot.identity = {
Copy link
Author

@sprak3000 sprak3000 Aug 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated the original issue using a bot attached to a Slack app. Used same bot to create this fix. When sending a slash command to my bot, the team object was in the form { id: 'XXXXXXXXX', name: 'foo', domain: 'foo' }, and there was no payload.type defined.

Based on my understanding of legacy versus Slack app connected bots, I believe this approach should handle both types. Using this patch with my bot restores slash command functionality.

id: team.id,
name: team.name
};
}

bot.identity = {
id: team.bot.user_id,
name: team.bot.name
};


}

// include the response channel so that they can be used in
Expand Down