Slack API斜杠命令和交互组件模式

时间:2020-02-26 10:29:27

标签: slack slack-api slack-commands slack-dialog

我正试图使机器人变得松弛。我用/ showmodal创建了一个斜杠命令,当该命令触发我的api返回此json

{
"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",
            "multiline": true
        },
        "label": {
            "type": "plain_text",
            "text": "Label",
            "emoji": true
        }
    }
]}

我期待这个结果

enter image description here

但是我得到的不是模态响应

/ showmodal失败,错误为“ invalid_blocks”

1 个答案:

答案 0 :(得分:0)

我已经通过阅读我忘记了包含trigger_id和view属性的文档来解决了这个问题

在下面查看正确的有效载荷

{ “ trigger_id”:“ TriggerIdFromRequestPayload”, “视图”:{ “ type”:“ modal”, “ callback_id”:“模式标识符”, “标题”:{ “ type”:“ plain_text”, “ text”:“ New Post” }, “提交”:{ “ type”:“ plain_text”, “ text”:“ Submit”, “表情符号”:正确 }, “关”: { “ type”:“ plain_text”, “ text”:“ Cancel”, “表情符号”:正确 }, “块”:[ { “ type”:“输入”, “元素”:{ “ type”:“ plain_text_input”, “ action_id”:“标题”, “占位符”:{ “ type”:“ plain_text”, “ text”:“输入标题” } }, “标签”: { “ type”:“ plain_text”, “ text”:“标题” } }, { “ type”:“输入”, “元素”:{ “ type”:“ plain_text_input”, “多行”:true }, “标签”: { “ type”:“ plain_text”, “ text”:“ Content”, “表情符号”:正确 } } ] } }