6
votes

I'm constructing and sending the message attachment:

var zz = {
    "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": "chess",
                    "text": "Chess",
                    "type": "button",
                    "value": "chess"
                }
            ]
        }
    ]
}

web.chat.postMessage(message.source.channel, '', zz);

The message with buttons displays fine on Slack, but when I tap a button there's no POST response from Slack to my local ngrok or express route:

app.post('/slackaction', function(req, res)

While other messages are posting fine to this route.

I'm seeing this error from Slack after I tap a button:

"Oh no, something went wrong. Please try that again"

Slack Interactive Messages request_url set as: https://xxx.ngrok.io/slackaction

1
Try to use GET app.get('/slackaction', function(req, res) - Medet Tleukabiluly
Tried GET but no improvement. Still getting same error "Oh no, something went wrong. Please try that again" - hatter123
Is the token you're using for chat.postMessage a token you've received as part of the OAuth authorization flow for the same application you've configured the request URL for? - Taylor Singletary
@TaylorSingletary are you saying that developing/testing responses for Interactive Messages will not work when someone is using a Test Token for chat.postMessage API? - jrace
@hatter123 yes, interactive messages requires using a Slack app for the whole end-to-end process. The messages must originate from the same app that's setup to process the actions activated by those same messages. - Taylor Singletary

1 Answers

7
votes

Thanks to comments from Taylor Singletary for pointing me in the right direction.

The test tokens or a bot token for Custom Integrations can post Interactive Messages but you need an App to handle them.

To fix it you need to add a bot to your app here: https://api.slack.com/apps and then get the access token for that bot.

You can use the Slack button generator here: https://api.slack.com/docs/slack-button# to get the OAuth URL and paste it on a browser.

Then from your app handle the OAuth flow, store the access token and use that with chat.postMessage.

Then you should receive the POST request when clicking on the message buttons.