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
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.
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 .
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With