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

Slack Block Kit Builder中Attachments无法显示的问题排查

问题原因及解决方法

你的代码里的attachments对象内的blocks字段格式错误,这是导致Block Kit Builder无法正确渲染附件的核心原因:

  • 在Slack的附件规范中,blocks必须是一个数组,你写成了单个对象
  • Slack Block Kit不存在type: "text"的块类型,正确的文本展示块应该使用type: "section"搭配text子字段

修复后的附件部分代码如下:

"attachments": [
    {
        "fallback": "Plain-text summary of the attachment.",
        "color": "#2eb886",
        "pretext": "Optional text that appears above the attachment block",
        "author_name": "Bobby Tables",
        "author_link": "http://flickr.com/bobby/",
        "author_icon": "http://flickr.com/icons/bobby.jpg",
        "title": "Slack API Documentation",
        "title_link": "https://api.slack.com/",
        "text": "Optional text that appears within the attachment",
        "fields": [
            {
                "title": "Priority",
                "value": "High",
                "short": false
            }
        ],
        "image_url": "http://my-website.com/path/to/image.jpg",
        "thumb_url": "http://example.com/path/to/thumb.png",
        "footer": "Slack API",
        "footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png",
        "ts": 123456789,
        "blocks": [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "test"
                }
            }
        ]
    }
]

如果不需要在附件内嵌套块,直接删除这个错误的blocks字段,附件也能正常显示。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 03:09:53