Slack交互式消息:Slack没有POST响应

我正在构build并发送消息附件:

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); 

带有button的消息在Slack上显示得很好,但是当我点击一个button时,Slack没有向我的本地ngrok或快速路由发送POST响应:

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

而其他消息正常发布到这条路线。

点击button后,我看到Slack的这个错误:

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

Slack Interactive Messages request_url设置为: https://xxx.ngrok.io/slackactionhttps://xxx.ngrok.io/slackaction

感谢Taylor Singletary的评论,指引我朝着正确的方向前进。

自定义集成的testing令牌或bot令牌可以发布交互式消息,但您需要一个应用程序来处理它们。

要修复它,你需要在这里添加一个机器人到你的应用程序: https : //api.slack.com/apps ,然后获得该机器人的访问令牌。

您可以在这里使用Slackbutton生成器: https : //api.slack.com/docs/slack-button#以获取OAuth URL并将其粘贴到浏览器中。

然后从您的应用程序处理OAuthstream程,存储访问令牌并通过chat.postMessage使用该令牌。

然后,当点击消息button时,您应该收到POST请求。