无法访问 Slack bot 交互式消息有效负载

JC1*_*JC1 5 node.js express slack-api slack

我制作了一个 slack 应用程序,只需按一下按钮,就可以将负载发送到我的服务器。

当按钮被按下时,服务器会收到负载,其中包含一个 JSON 对象,其布局如下:

{  
   "type":"interactive_message",
   "actions":[ .. ],
   "callback_id":"wopr_game",
   "team":{ .. },
   "channel":{ .. },
   "user":{ .. },
   "action_ts":"1523126737.192039",
   "message_ts":"1523126734.000016",
   "attachment_id":"1",
   "token":"aYydBrSjjHHz4UqYXKB4tzDZ",
   "is_app_unfurl":false,
   "original_message":{ .. },
   "response_url":"https://hooks.slack.com/actions/T1ABCD2E12/330361579271/0dAEyLY19ofpLwxqozy3firz",
   "trigger_id":"342463876993.134749426887.e0c3b2e25d3a070b66361526a13be0bf"
}
Run Code Online (Sandbox Code Playgroud)

但是,我似乎无法访问 JSON 对象中的任何变量。这是我针对特定请求的 express js 代码。

router.post('/', function(req, res, next) {

    console.log(req.body['payload']) // prints json obj fine
    console.log(req.body['payload']['response_url']) // undefined

    res.send('Hello');
});
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么吗?

Cat*_*yst 5

试试看 console.log(JSON.parse(req.body['payload'])['response_url'])