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

Slack interactive messages not working with azure bot service connector #326

Closed
bolleman opened this issue Dec 20, 2021 · 3 comments
Closed
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-reported As opposed to development work item.

Comments

@bolleman
Copy link

I'm using the Slack channel in Azure Bot Service (for clarity, not the Slack adapter package). My bot is receiving bot events properly, but block kit button clicks (aka interactive messages) generate the following error.
400errorSlack
The Slack channel shows as Healthy but nothing is being forwarded to my bot endpoint.
The Slack app is configured with the request_url specified in the Azure Bot Service documentation for configuring a Slack channel as follows:

"interactivity": {
            "is_enabled": true,
            "request_url": "https://slack.botframework.com/api/Actions"
        },

It looks like this issue was raised back in Jun 2020 and then fixed in Jul 2020:
microsoft/BotBuilder-Samples#2553
microsoft/botbuilder-dotnet#4246

However, it also appears that it is not working again for others as well:
https://stackoverflow.com/questions/68215851/microsoft-bot-framework-respond-to-slack-block-kit-ui-action-buttons#new-answer

Just wondering if this is a new bug or am I missing something in the config. Thanks!

@dmvtech dmvtech added Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-reported As opposed to development work item. labels Dec 20, 2021
@ssss141414
Copy link

Hi @bolleman ,
We're trying repro it. Can you provide your code about constructing this Activity with buttons?

@bolleman
Copy link
Author

I created a new Composer project with one dialog, as follows. The Slack bot channel registration contains the default scopes.

I haven't put in a trigger in this dialog to handle the event/activity from the Slack button click yet as I was waiting to see it come through on ngrok first so I know what it will look like. If you also happen to know what trigger I should use that would be awesome as I'm going to need to know that next. Thanks for your help!

{
  "$kind": "Microsoft.AdaptiveDialog",
  "$designer": {
    "name": "TestSlack",
    "description": "",
    "id": "A79tBe"
  },
  "autoEndDialog": true,
  "defaultResultProperty": "dialog.result",
  "triggers": [
    {
      "$kind": "Microsoft.OnUnknownIntent",
      "$designer": {
        "id": "mb2n1u",
        "comment": "This trigger fires when an incoming activity is not handled by any other trigger."
      },
      "actions": [
        {
          "$kind": "Microsoft.HttpRequest",
          "$designer": {
            "id": "fVgcUr",
            "name": "Start new thread"
          },
          "resultProperty": "dialog.sendResult",
          "method": "POST",
          "url": " https://slack.com/api/chat.postMessage",
          "headers": {
            "Authorization": "Bearer ${turn.activity.channelData.ApiToken}"
          },
          "contentType": "application/json",
          "responseType": "json",
          "body": {
            "channel": "${turn.activity.channelData.SlackMessage.event.channel}",
            "blocks": [
              {
                "type": "actions",
                "block_id": "actionblock789",
                "elements": [
                  {
                    "type": "button",
                    "text": {
                      "type": "plain_text",
                      "text": "Primary Button"
                    },
                    "style": "primary",
                    "value": "click_me_456"
                  },
                  {
                    "type": "button",
                    "text": {
                      "type": "plain_text",
                      "text": "Link Button"
                    },
                    "url": "https://api.slack.com/block-kit"
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  ],
  "generator": "TestSlack.lg",
  "id": "TestSlack",
  "recognizer": {
    "$kind": "Microsoft.RegexRecognizer",
    "intents": []
  }
}

@bolleman
Copy link
Author

bolleman commented Dec 23, 2021

I did further searching and discovered there is a legacy Slack message button format using attachments in addition to the current Block Kit button elements that I used initially. I added the legacy approach to the previous dialog (see below) and it works. This provides a suitable workaround for my purposes so I am closing the issue. I've created an issue on MSDocs so others are aware.

Also, since I now see this comes through as a regular message activity, that answers the other question of how to trigger off it.

{
  "$kind": "Microsoft.AdaptiveDialog",
  "$designer": {
    "name": "TestSlack",
    "description": "",
    "id": "A79tBe"
  },
  "autoEndDialog": true,
  "defaultResultProperty": "dialog.result",
  "triggers": [
    {
      "$kind": "Microsoft.OnUnknownIntent",
      "$designer": {
        "id": "mb2n1u",
        "comment": "This trigger fires when an incoming activity is not handled by any other trigger."
      },
      "actions": [
        {
          "$kind": "Microsoft.HttpRequest",
          "$designer": {
            "id": "fVgcUr",
            "name": "Start new thread"
          },
          "resultProperty": "dialog.sendResult",
          "method": "POST",
          "url": " https://slack.com/api/chat.postMessage",
          "headers": {
            "Authorization": "Bearer ${turn.activity.channelData.ApiToken}"
          },
          "contentType": "application/json",
          "responseType": "json",
          "body": {
            "channel": "${turn.activity.channelData.SlackMessage.event.channel}",
            "blocks": [
              {
                "type": "actions",
                "block_id": "actionblock789",
                "elements": [
                  {
                    "type": "button",
                    "text": {
                      "type": "plain_text",
                      "text": "Primary Button"
                    },
                    "style": "primary",
                    "value": "click_me_456"
                  },
                  {
                    "type": "button",
                    "text": {
                      "type": "plain_text",
                      "text": "Link Button"
                    },
                    "url": "https://api.slack.com/block-kit"
                  }
                ]
              }
            ]
          }
        },
        {
          "$kind": "Microsoft.HttpRequest",
          "$designer": {
            "id": "YSkbjQ",
            "name": "Start new thread"
          },
          "resultProperty": "dialog.sendResult",
          "method": "POST",
          "url": " https://slack.com/api/chat.postMessage",
          "headers": {
            "Authorization": "Bearer ${turn.activity.channelData.ApiToken}"
          },
          "contentType": "application/json",
          "responseType": "json",
          "body": {
            "channel": "${turn.activity.channelData.SlackMessage.event.channel}",
            "text": "Would you like to play a game?",
            "attachments": [
              {
                "text": "Choose a game to play",
                "fallback": "You are unable to choose a game",
                "callback_id": "wopr_game",
                "color": "#3AA3E3",
                "attachment_type": "default",
                "actions": [
                  {
                    "name": "game",
                    "text": "Chess",
                    "type": "button",
                    "value": "chess"
                  },
                  {
                    "name": "game",
                    "text": "Falken's Maze",
                    "type": "button",
                    "value": "maze"
                  },
                  {
                    "name": "game",
                    "text": "Thermonuclear War",
                    "style": "danger",
                    "type": "button",
                    "value": "war",
                    "confirm": {
                      "title": "Are you sure?",
                      "text": "Wouldn't you prefer a good game of chess?",
                      "ok_text": "Yes",
                      "dismiss_text": "No"
                    }
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  ],
  "generator": "TestSlack.lg",
  "id": "TestSlack",
  "recognizer": {
    "$kind": "Microsoft.RegexRecognizer",
    "intents": []
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-reported As opposed to development work item.
Projects
None yet
Development

No branches or pull requests

4 participants