首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >松弛错误:失败,错误为"invalid_blocks“

松弛错误:失败,错误为"invalid_blocks“
EN

Stack Overflow用户
提问于 2020-06-26 12:28:02
回答 1查看 3.2K关注 0票数 1

我正在构建一个内部松弛应用程序,启动一个模式,所以技术要求可以更有效地被罚单。

当我在一个斜杠命令的JSON响应中从我的API返回以下内容时,我得到了一个失败的错误和错误"invalid_blocks",然而,当我把它放入块-工具包-构建器中时,它工作得很好(包括"sending to slack“按钮)。

当我运行我的斜杠命令时,你知道为什么这个命令失败了吗--有没有可能从slack看到更详细的错误消息?

代码语言:javascript
运行
复制
return {
        statusCode: 200,
        body: JSON.stringify({
                "callback_id": "tech-support",
                "title": {
                    "type": "plain_text",
                    "text": "Tech Support Ticket",
                    "emoji": true
                },
                "submit": {
                    "type": "plain_text",
                    "text": "Submit",
                    "emoji": true
                },
                "type": "modal",
                "close": {
                    "type": "plain_text",
                    "text": "Cancel",
                    "emoji": true
                },
                "blocks": [
                    {
                        "type": "input",
                        "element": {
                            "type": "plain_text_input"
                        },
                        "label": {
                            "type": "plain_text",
                            "text": "Ticket Title",
                            "emoji": true
                        }
                    },
                    {
                        "type": "divider"
                    },
                    {
                        "type": "input",
                        "element": {
                            "type": "static_select",
                            "placeholder": {
                                "type": "plain_text",
                                "text": "Select an item",
                                "emoji": true
                            },
                            "options": [
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Website",
                                        "emoji": true
                                    },
                                    "value": "value-0"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Hubspot",
                                        "emoji": true
                                    },
                                    "value": "value-1"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Email",
                                        "emoji": true
                                    },
                                    "value": "value-2"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Other",
                                        "emoji": true
                                    },
                                    "value": "value-3"
                                }
                            ]
                        },
                        "label": {
                            "type": "plain_text",
                            "text": "Impacted Technology",
                            "emoji": true
                        }
                    },
                    {
                        "type": "divider"
                    },
                    {
                        "type": "input",
                        "element": {
                            "type": "checkboxes",
                            "options": [
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Security",
                                        "emoji": true
                                    },
                                    "value": "value-4"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Productivity",
                                        "emoji": true
                                    },
                                    "value": "value-5"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Data Accuracy",
                                        "emoji": true
                                    },
                                    "value": "value-6"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Feature Suggestion",
                                        "emoji": true
                                    },
                                    "value": "value-7"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Client Useability",
                                        "emoji": true
                                    },
                                    "value": "value-8"
                                }
                            ]
                        },
                        "label": {
                            "type": "plain_text",
                            "text": "Business Impacts",
                            "emoji": true
                        }
                    },
                    {
                        "type": "divider"
                    },
                    {
                        "type": "input",
                        "element": {
                            "type": "radio_buttons",
                            "options": [
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Yes",
                                        "emoji": true
                                    },
                                    "value": "value-9"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "No",
                                        "emoji": true
                                    },
                                    "value": "value-10"
                                }
                            ]
                        },
                        "label": {
                            "type": "plain_text",
                            "text": "Does the problem block you from your core deliverables",
                            "emoji": true
                        }
                    },
                    {
                        "type": "divider"
                    },
                    {
                        "type": "input",
                        "element": {
                            "type": "plain_text_input",
                            "multiline": true
                        },
                        "label": {
                            "type": "plain_text",
                            "text": "Give a detailed description of the problem",
                            "emoji": true
                        }
                    },
                    {
                        "type": "divider"
                    },
                    {
                        "type": "input",
                        "element": {
                            "type": "static_select",
                            "placeholder": {
                                "type": "plain_text",
                                "text": "Select an item",
                                "emoji": true
                            },
                            "options": [
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "High: Critical To Reach Operations",
                                        "emoji": true
                                    },
                                    "value": "value-11"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Medium: Multi-Person Technical Inconvenience",
                                        "emoji": true
                                    },
                                    "value": "value-12"
                                },
                                {
                                    "text": {
                                        "type": "plain_text",
                                        "text": "Low: Normal Technical Issue",
                                        "emoji": true
                                    },
                                    "value": "value-13"
                                }
                            ]
                        },
                        "label": {
                            "type": "plain_text",
                            "text": "Select a priority",
                            "emoji": true
                        }
                    },
                    {
                        "type": "divider"
                    },
                    {
                        "type": "input",
                        "element": {
                            "type": "multi_users_select",
                            "placeholder": {
                                "type": "plain_text",
                                "text": "Select users",
                                "emoji": true
                            }
                        },
                        "label": {
                            "type": "plain_text",
                            "text": "Does this impact other people as well?",
                            "emoji": true
                        }
                    }
                ]

        }),
    };```
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-26 18:53:27

从Slash命令获取有效负载时,发送的响应只能返回一条消息。模态必须通过JSON方法打开,将views.open传递给view参数、来自斜杠命令有效负载的trigger_id和用于验证请求的令牌。

使用BoltBlock Builder JS库,如下所示:

代码语言:javascript
运行
复制
const openMyView = async ({ body, context, client }) => {

  // Do some stuff and build viewParams object

  const view = callSomeMethod(viewParams); // Calls a method that uses Block Builder to build a modal

  await client.views.open({
    view: view.buildToJSON(); // Could also be just the JSON built from Slack's builder site
    token: context.botToken,
    trigger_id: body.trigger_id,
  });
};
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62588036

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档