Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Slack API—单击按钮时从同一消息中获取其他组件的值_Node.js_Express_Slack_Slack Api - Fatal编程技术网

Node.js Slack API—单击按钮时从同一消息中获取其他组件的值

Node.js Slack API—单击按钮时从同一消息中获取其他组件的值,node.js,express,slack,slack-api,Node.js,Express,Slack,Slack Api,我有一条互动信息: [ { "type": "section", "text": { "type": "mrkdwn", "text": "The number of items you want to see (Top X)" }, "accessory": { "type": "static_select", "placeh

我有一条互动信息:

 [
    {
        "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的请求。然后,您的应用程序将替换该消息并询问条件。等等
  • 或者你也可以用一个。这将显示为模式窗口,允许您在一个步骤中查询多达5个元素

我选择了对话的方式。你介意扩展一下多步骤方法吗?我添加了一些关于多步骤方法的更多信息。希望这能澄清问题如果你有什么问题,请你用伪代码(或正确的代码)展示一下多个步骤是如何工作的。我不确定如何实际实现它(使用哪个slackapi、哪个函数等)