gpt4 book ai didi

松弛 bolt Python : how to make the input field in modal optional?

转载 作者:行者123 更新时间:2023-12-02 02:01:40 27 4
gpt4 key购买 nike

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

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)

enter image description here

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

最佳答案

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

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

"optional": true,

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

关于松弛 bolt Python : how to make the input field in modal optional?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68950019/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com