Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack Interactive Messages: No POST response from Slack

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

like image 573
hatter123 Avatar asked Aug 19 '16 16:08

hatter123


People also ask

Why are Slack messages not sending?

Try restarting your device again, then resetting the cache. If that doesn't work, you can uninstall and reinstall the Slack app. Note: If running the test doesn't reveal any issues or the steps above don't fix the problem, run the test again and tap Send a report so our Support team can help out.

What is Slack ephemeral message?

This method posts an ephemeral message, which is visible only to the assigned user in a specific public channel, private channel, or private conversation. Ephemeral message delivery is not guaranteed — the user must be currently active in Slack and a member of the specified channel .

How do I post automated messages on Slack?

Schedule a messageClick the compose button or open the conversation where you'd like to send your message. Type your message in the message field. Click the arrow icon to the right of the paper plane icon. Choose a date and time from the list or select Custom time.

What is an interactive message?

Interactive messages are much like other messages, only they contain buttons, a variety of menus types, or they have some custom actions available. Rather than remaining mostly static, interactive messages evolve over time. Message buttons and menus may travel almost anywhere a message goes.


1 Answers

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.

like image 119
Juan Avatar answered Oct 13 '22 11:10

Juan