You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过response_url webhook更新Slack临时消息时出现Invalid blocks错误

问题根因

你提交的请求体存在两处不符合Slack API规范的错误,直接触发了invalid_blocks报错:

  • Block字段命名错误:Slack Block Kit 规范要求所有字段使用蛇形命名(下划线分隔),你在image块中使用的驼峰命名imageUrl、altText属于非法字段,正确命名应为image_url、alt_text
  • 参数类型错误:replace_original要求为布尔类型,你提交的是字符串类型的"true",需要改为布尔值true

修正后的请求体示例

{
    "blocks": [
        {
            "type": "image",
            "image_url": "https://example.com/image.jpeg",
            "alt_text": "alt-text",
            "title": {
                "type": "plain_text",
                "text": "some text"
            }
        },
        {
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "text": "Send",
                        "emoji": false
                    },
                    "value": "send",
                    "style": "primary"
                },
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "text": "Find new",
                        "emoji": false
                    },
                    "value": "some text"
                },
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "text": "Cancel",
                        "emoji": false
                    },
                    "value": "cancel"
                }
            ]
        }
    ],
    "replace_original": true,
    "text": "some fallback text"
}

修正后提交请求即可正常替换临时消息。

内容的提问来源于stack exchange,提问作者cardouken

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 22:54:00