【问题标题】:Slack dialog accessory static select not wokring松弛对话框附件静态选择不起作用
【发布时间】:2020-03-22 09:46:57
【问题描述】:

我正在尝试打开一个松弛模式。 以下是我的 JSON。字段放在附件下时不传递值。我在该字段旁边收到错误消息。我做错什么了吗?当我把它放在输入类型块中时,同样的事情也有效。下面是我使用 Slack Block Kit Builder 构建的 JSON 代码。我也添加了action_id

{
    "type": "modal",
    "title": {
        "type": "plain_text",
        "text": "My App",
        "emoji": true
    },
    "submit": {
        "type": "plain_text",
        "text": "Submit",
        "emoji": true
    },
    "close": {
        "type": "plain_text",
        "text": "Cancel",
        "emoji": true
    },
"blocks": [
            {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "To"
            },
            "accessory": {
                "type": "static_select",
                "action_id": "to_time",
                "placeholder": {
                    "type": "plain_text",
                    "text": "Select an item",
                    "emoji": true
                },
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "8 AM",
                            "emoji": true
                        },
                        "value": "8"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "9 AM",
                            "emoji": true
                        },
                        "value": "9"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "10 AM",
                            "emoji": true
                        },
                        "value": "10"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "11 AM",
                            "emoji": true
                        },
                        "value": "11"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "12 PM",
                            "emoji": true
                        },
                        "value": "12"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "1 PM",
                            "emoji": true
                        },
                        "value": "1"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "2 PM",
                            "emoji": true
                        },
                        "value": "2"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "3 PM",
                            "emoji": true
                        },
                        "value": "3"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "4 PM",
                            "emoji": true
                        },
                        "value": "4"
                    },
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "5 PM",
                            "emoji": true
                        },
                        "value": "5"
                    }
                ]
            }
        }
    ]
}

值未通过

【问题讨论】:

    标签: node.js aws-lambda slack slack-api slack-dialog


    【解决方案1】:

    您需要使用views.open 而不是dialog.open。由于您在模态中使用块元素,因此建议使用 view.open 我希望这对您有用。

    然后检查是否为交互组件添加了 webhook。

    您的 webhook URL 似乎有问题,您能再检查一次吗?我尝试了你的 JSON,它就像一个魅力!

    代码:

        const data = {
            token: authToken,
            trigger_id: trigger_id,
            view: {
                // Json goes here
            }
        };
        const headers = {
            Authorization: `Bearer ${authToken}`
        }
        const response = await axios.post(`${apiUrl}/views.open`, data, { headers });
        console.log(response.data);
        return response;
    

    对话框:

    成功响应:

    【讨论】:

    • 我只使用了views.open
    • 那么,你有没有在你的 slack 应用中添加交互式 webhook?
    • 是的,我已经添加了。当我使用输入块时。有用。但配件不返回值
    • 在 view_submission 中,是这样的 ....type: 'modal', blocks: [ [Object] ], private_metadata: '', callback_id: '', state: { values: { } },
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-24
    • 2018-06-05
    • 1970-01-01
    • 2018-11-02
    • 2020-12-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多