【问题标题】:Slack API slash commands and interactive components modalSlack API 斜线命令和交互组件模式
【发布时间】:2020-06-10 04:48:42
【问题描述】:

我正在尝试让机器人处于松弛状态。我用 /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
        }
    }
]}

我期待这个结果

但我得到的是这个响应而不是模态

/showmodal 因错误“invalid_blocks”而失败

【问题讨论】:

  • 你在用views.open吗?
  • @CalebNjiiri 是的,我已经解决了,trigger_id 和 view 属性丢失了

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


【解决方案1】:

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

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

{ "trigger_id": "TriggerIdFromRequestPayload", “看法”: { “类型”:“模态”, "callback_id": "模态标识符", “标题”: { “类型”:“纯文本”, “文本”:“新帖子” }, “提交”: { “类型”:“纯文本”, "文本": "提交", “表情符号”:是的 }, “关闭”: { “类型”:“纯文本”, "文本": "取消", “表情符号”:是的 }, “块”:[ { “类型”:“输入”, “元素”: { “类型”:“plain_text_input”, “action_id”:“标题”, “占位符”:{ “类型”:“纯文本”, "text": "输入标题" } }, “标签”: { “类型”:“纯文本”, “文本”:“标题” } }, { “类型”:“输入”, “元素”: { “类型”:“plain_text_input”, “多行”:真 }, “标签”: { “类型”:“纯文本”, “文本”:“内容”, “表情符号”:是的 } } ] } }

【讨论】:

    猜你喜欢
    • 2021-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 2014-08-26
    • 2021-12-31
    相关资源
    最近更新 更多