Slack:如何在交互式菜单上设置默认/选定值

AyK*_*rsi 3 slack-api slack

我有松弛的交互式菜单,除了我想要在菜单中显示当前选择的值之外,它工作得很好。阅读文档后,我认为附件应该如下所示:

{
    'text': 'settings.slack_notification_time ',
    'fallback': 'oops',
    'color': '#3AA3E3',
    'attachment_type': 'default',
    'callback_id': callback_id,
    'actions': [
        {
            'name': 'notification_time',
            'text': 'Choose a notification_time',
            'type': 'select',
            'selected_options': [
                {
                    'text': '07:00',
                    'value': 7
                }
            ],
            'options': [
                {text:'01:00',value:1},
                {text:'02:00',value:2},
                {text:'03:00',value:3},
                ....

            ]                       
        }
    ]
};
Run Code Online (Sandbox Code Playgroud)

设置所选选项的正确方法是什么?

小智 5

“initial_option”对我有用。

供参考。 样本

代码:

{
"blocks": [
    {
        "type": "section",
        "text": {
            "type": "mrkdwn",
            "text": "Pick an item from the dropdown list"
        },
        "accessory": {
            "type": "static_select",
            "placeholder": {
                "type": "plain_text",
                "text": "Select an item",
                "emoji": true
            },
            "initial_option": {
                "text": {
                    "type": "plain_text",
                    "text": "*this is plain_text text*",
                    "emoji": true
                },
                "value": "value-1"
            },
            "options": [
                {
                    "text": {
                        "type": "plain_text",
                        "text": "*this is plain_text text*",
                        "emoji": true
                    },
                    "value": "value-0"
                },
                {
                    "text": {
                        "type": "plain_text",
                        "text": "*this is plain_text text*",
                        "emoji": true
                    },
                    "value": "value-1"
                },
                {
                    "text": {
                        "type": "plain_text",
                        "text": "*this is plain_text text*",
                        "emoji": true
                    },
                    "value": "value-2"
                }
            ],
            "action_id": "static_select-action"
        }
    }
]
Run Code Online (Sandbox Code Playgroud)

}