Skip to content

Commit

Permalink
fix(slack): added callback_id to attachment (resolve #876)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Paniontko authored and emirotin committed Sep 11, 2018
1 parent 4c81a1c commit 5474761
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/channels/botpress-channel-slack/src/actions.js
Expand Up @@ -60,6 +60,17 @@ const createAttachments = (channelId, attachments, options = {}) => {
validateChannelId(channelId)
validateAttachments(attachments)

attachments = attachments.map(attachment => {
if (attachment.callback_id) {
return attachment
}

const defaultPrefix = attachment.text ? attachment.text.replace(/\s/g, '_') : 'slack_attachment'
const defaultCallbackId = `${defaultPrefix}:${Date.now()}`

return { ...attachment, callback_id: defaultCallbackId }
})

return create({
platform: 'slack',
type: 'attachments',
Expand Down

0 comments on commit 5474761

Please sign in to comment.