Slack Bolt Python:如何使模态中的输入字段可选?

Slack Bolt Python: how to make the input field in modal optional?

我正在使用模态来收集数据。我通过以下代码打开了一个视图:

view = {
    "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": "input",
            "element": {
                "type": "plain_text_input",
                "action_id": "plain_text_input-action"
            },
            "label": {
                "type": "plain_text",
                "text": "Please leave feedback here",
                "emoji": True
            }
        }
    ]
    }
slack_client.views_open(trigger_id=body['trigger_id'],view=view)

我想让输入文本可选,也就是说,即使用户将输入字段留空,he/she 仍然可以提交模态。这能实现吗?

您可以添加 "optional": true 作为输入块的 属性。

"blocks": [
        {
            "type": "input",

            "optional": true,

            "element": {
                "type": "plain_text_input",
                "action_id": "plain_text_input-action"
            },
            "label": {
                "type": "plain_text",
                "text": "Label",
                "emoji": true
            }
        }
    ]