我有这个互动消息:
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "The number of items you want to see (Top X)"
},
"accessory": {
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "X",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "1",
"emoji": true
},
"value": "1"
}
]
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "The criteria you want to group by"
},
"accessory": {
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Select a criteria",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "criteria1",
"emoji": true
},
"value": "criteria1"
}
]
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Fetch P&L",
"emoji": false
}
}
]
}
]
当用户单击按钮时,如何获取用户在 2 个下拉菜单中选择的值?
它不在我从 Slack 获得的事件负载中。我正在使用 NodeJS
库与 express
应用程序中的 Slack 进行通信,并且希望有一个也使用这些库的解决方案。
最佳答案
Slack UI 的工作方式与标准 HTTP 表单略有不同。
每个交互式组件(例如选择或按钮)都是独立的,当用户单击它时,Slack 会向您的应用发送仅包含该组件信息的请求。
要组合多个交互式组件,您有两种选择:
- 您可以分多个步骤进行查询。因此,您首先发送一条消息询问商品数量。然后用户做出选择,您的应用程序会收到来自 Slack 的请求。然后您的应用程序会替换该消息并询问标准。等等。
- 或者您可以使用 Slack Dialog 。这将显示为模态窗口,并允许您一步查询最多 5 个元素。
关于node.js - Slack API - 单击按钮时从同一消息中获取其他组件的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56070104/