block-kit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBlock Kit
Block Kit
Help the developer build a rich Block Kit layout. If is provided, it specifies the target surface (, , or ).
$0messagemodalhome-tabThis skill walks through surface selection, layout planning, JSON generation, and validation. Block types, elements, and fields come from the live docs (see Source of Truth below) — discover them and read each component's schema there, never from memory.
Common Block Kit mistakes (and why): A few errors recur often enough to flag up front. Most others are caught byin Step 5, so lean on validation rather than memorizing rules.blocks.validate
is not a thing. Text is a composition object:"type": "text"or{ "type": "plain_text", "text": "..." }.{ "type": "mrkdwn", "text": "..." } is a block type, not a text type. Amarkdownblock holds standard markdown; text objects inside other blocks usemarkdown(see mrkdwn vs. themrkdwnblock in Step 4). Slack'smarkdownismrkdwn/*bold*/_italic_, not~strike~.**bold**- Messages need a top-level
fallback.textwon't flag a missing one, but notifications and screen readers display it instead of the blocks — so summarize what the layout conveys rather than leaving it empty.blocks.validate
帮助开发者构建丰富的Block Kit布局。若提供,则指定目标载体(、或)。
$0messagemodalhome-tab此技能会引导完成载体选择、布局规划、JSON生成和验证流程。块类型、元素和字段均来自官方实时文档(见下方权威来源)——请从文档中查找并查看每个组件的 schema,切勿凭记忆操作。
常见Block Kit错误(及原因): 有一些错误出现频率很高,特此提前提醒。大多数其他错误会在步骤5中被检测到,因此请依赖验证而非记忆规则。blocks.validate
不存在。文本是一种组合对象:"type": "text"或{ "type": "plain_text", "text": "..." }。{ "type": "mrkdwn", "text": "..." } 是块类型,而非文本类型。markdown块用于承载标准markdown;其他块内的文本对象使用markdown(见步骤4中的mrkdwn 与mrkdwn块的区别)。Slack的markdown语法为mrkdwn/*bold*/_italic_,而非~strike~。**bold**- 消息需要顶层
备用文本。text不会标记缺失的备用文本,但通知和屏幕阅读器会显示它而非块内容——因此请概述布局传达的信息,不要留空。blocks.validate
Source of Truth: the Live Docs
权威来源:官方实时文档
Every block, element, and composition object is documented on . Append to any reference URL to fetch it as markdown with WebFetch (no auth required).
docs.slack.dev.md- Master index: the authoritative list of every block, block element, and composition object, each linking to its own page: . WebFetch it to confirm a type exists and to get the link to its page.
https://docs.slack.dev/reference/block-kit.md - Per-component pages carry the full field schema (a fields table with required/optional flags and constraints, plus JSON examples):
- Blocks:
https://docs.slack.dev/reference/block-kit/blocks/<slug>-block.md - Block elements:
https://docs.slack.dev/reference/block-kit/block-elements/<slug>-element.md - Composition objects:
https://docs.slack.dev/reference/block-kit/composition-objects/<slug>.md
- Blocks:
- The slug is not always the type name. For example maps to
datepicker, and everydate-picker-element.mdmenu (*_select,static_select,users_select, and so on) is documented onmulti_channels_select. When unsure of a slug, follow the link from the master index rather than building the URL by hand.select-menu-element.md - Surface payload structure lives in the surface guides: messages at , modals at
https://docs.slack.dev/messaging/formatting-message-text.md, and Home tabs athttps://docs.slack.dev/surfaces/modals.md.https://docs.slack.dev/surfaces/app-home.md
Never use a block type, element, or field you have not seen on a live page.
每个块、元素和组合对象均记录在上。在任何参考URL后添加,即可通过WebFetch获取其markdown格式内容(无需授权)。
docs.slack.dev.md- 主索引:包含所有块、块元素和组合对象的权威列表,每个条目均链接至其专属页面:。通过WebFetch获取该页面,确认类型是否存在并获取其页面链接。
https://docs.slack.dev/reference/block-kit.md - 组件专属页面:包含完整的字段schema(带有必填/可选标记和约束的字段表,以及JSON示例):
- 块:
https://docs.slack.dev/reference/block-kit/blocks/<slug>-block.md - 块元素:
https://docs.slack.dev/reference/block-kit/block-elements/<slug>-element.md - 组合对象:
https://docs.slack.dev/reference/block-kit/composition-objects/<slug>.md
- 块:
- slug并非总是类型名称。例如对应
datepicker,所有date-picker-element.md菜单(*_select、static_select、users_select等)均记录在multi_channels_select上。若不确定slug,请从主索引中点击链接,而非手动构建URL。select-menu-element.md - 载体负载结构:记录在载体指南中:消息见,模态框见
https://docs.slack.dev/messaging/formatting-message-text.md,主页标签见https://docs.slack.dev/surfaces/modals.md。https://docs.slack.dev/surfaces/app-home.md
切勿使用未在实时页面中见过的块类型、元素或字段。
Fast Path (for clear, specific requests)
快速路径(适用于明确、具体的需求)
If the developer's request is specific enough to determine both the target surface and the desired layout, collapse Steps 1-4 into a single pass:
- Determine the surface from or context
$0 - Fetch only the doc pages for the blocks and elements mentioned
- Generate the JSON directly
- Proceed to Step 5 (validation)
Fast-path indicators (skip the full workflow):
- Developer provides existing JSON to modify → use Modification Mode instead
- Developer names specific block types: "add an actions block with two buttons"
- Developer describes a well-known pattern: "approval message", "feedback form", "settings modal"
- Developer provides a complete description in one message with enough detail to build
Full-workflow indicators (use Steps 1-7):
- Vague requests: "make something cool", "build a dashboard"
- Exploratory: "what can Block Kit do?", "show me my options"
- Complex layouts: 10+ blocks, nested modals, conditional logic
- Developer asks for help deciding what to build
若开发者的请求足够具体,可确定目标载体和所需布局,则可将步骤1-4合并为一步:
- 从或上下文确定载体
$0 - 仅获取提及的块和元素的文档页面
- 直接生成JSON
- 进入步骤5(验证)
快速路径触发标识(跳过完整流程):
- 开发者提供现有JSON用于修改→改用修改模式
- 开发者指定具体块类型:"添加一个包含两个按钮的actions块"
- 开发者描述知名模式:"审批消息"、"反馈表单"、"设置模态框"
- 开发者在一条消息中提供足够详细的完整描述,可直接构建
完整流程触发标识(使用步骤1-7):
- 模糊请求:"做些炫酷的东西"、"构建一个仪表盘"
- 探索性请求:"Block Kit能做什么?"、"展示我的可选方案"
- 复杂布局:10个以上块、嵌套模态框、条件逻辑
- 开发者请求帮助决定构建内容
Modification Mode
修改模式
If the developer provides existing Block Kit JSON (pasted inline, in a file, or referenced from code), enter Modification Mode instead of the full creation workflow:
-
Parse the existing structure:
- List each block by index, type, and a short description of its content
- Infer the surface: = modal,
"type": "modal"= home tab, bare"type": "home"array = messageblocks
-
Ask what changes they want:
- Add blocks (where in the sequence?)
- Remove blocks (which ones?)
- Modify blocks (which block, what change?)
- Reorder blocks
-
Apply changes while preserving:
- All existing values (these are referenced in app interaction handlers)
block_id - All existing values (these map to event listeners)
action_id - Existing styles, text content, and structure for unchanged blocks
- All existing
-
Validate the modified JSON: proceed to Step 5 (validation)
Detection: If the developer's message contains a JSON array starting with or a view object with , enter Modification Mode automatically. If they say "edit", "update", "modify", or "change" in reference to existing blocks, ask them to provide the current JSON.
[{"type":"blocks":若开发者提供现有Block Kit JSON(内联粘贴、文件中或代码引用),则进入修改模式而非完整创建流程:
-
解析现有结构:
- 按索引、类型和内容简短描述列出每个块
- 推断载体:=模态框,
"type": "modal"=主页标签,纯"type": "home"数组=消息blocks
-
询问所需更改:
- 添加块(在序列中的哪个位置?)
- 删除块(哪些块?)
- 修改块(哪个块,做什么更改?)
- 重新排序块
-
应用更改时保留以下内容:
- 所有现有值(这些值在应用交互处理程序中被引用)
block_id - 所有现有值(这些值映射到事件监听器)
action_id - 未更改块的现有样式、文本内容和结构
- 所有现有
-
验证修改后的JSON:进入步骤5(验证)
检测规则:若开发者的消息包含以开头的JSON数组,或带有的视图对象,则自动进入修改模式。若开发者提及"编辑"、"更新"、"修改"或"更改"现有块,请要求他们提供当前JSON。
[{"type":"blocks":Step 1: Determine the Target Surface
步骤1:确定目标载体
If is provided and matches one of , , or , use it directly.
$0messagemodalhome-tabOtherwise, ask the developer using AskUserQuestion:
- Message: Conversational content posted to a channel or DM. Max 50 blocks.
- Modal: A dialog or form opened by a user action. Max 100 blocks.
- Home tab: A persistent, per-user dashboard in the App Home. Max 100 blocks.
Once the surface is determined, use the correct payload structure for it:
- Message: a object posted via
{ "text": "Fallback text", "blocks": [...] }(and friends). Thechat.postMessagefield is the notification/accessibility fallback. For message text formatting (mrkdwn, mentions, dates), seetext.https://docs.slack.dev/messaging/formatting-message-text.md - Modal: a view object (). For the full view object structure, lifecycle, and the rule that
{ "type": "modal", "title": ..., "blocks": [...] }is required when the view contains anysubmitblock, seeinput.https://docs.slack.dev/surfaces/modals.md - Home tab: a view object () published via
{ "type": "home", "blocks": [...] }. For structure and behavior, seeviews.publish.https://docs.slack.dev/surfaces/app-home.md
若提供且匹配、或之一,则直接使用该值。
$0messagemodalhome-tab否则,使用AskUserQuestion询问开发者:
- Message:发布到频道或私信的对话内容。最多50个块。
- Modal:由用户操作触发打开的对话框或表单。最多100个块。
- Home tab:App Home中持久化的用户专属仪表盘。最多100个块。
确定载体后,使用对应的负载结构:
- Message:通过(及相关方法)发布的
chat.postMessage对象。{ "text": "备用文本", "blocks": [...] }字段是通知/无障碍备用文本。关于消息文本格式(mrkdwn、提及、日期),请查看text。https://docs.slack.dev/messaging/formatting-message-text.md - Modal:视图对象()。关于完整视图对象结构、生命周期,以及当视图包含任何
{ "type": "modal", "title": ..., "blocks": [...] }块时必须包含input的规则,请查看submit。https://docs.slack.dev/surfaces/modals.md - Home tab:通过发布的视图对象(
views.publish)。关于结构和行为,请查看{ "type": "home", "blocks": [...] }。https://docs.slack.dev/surfaces/app-home.md
Step 2: Understand What to Build
步骤2:明确构建需求
Ask the developer to describe what they want their layout to look like or accomplish.
If they need inspiration, suggest examples — several map directly onto a ready-made template in (named in parentheses), which you can start from in Step 3:
references/common-patterns.md- "A feedback form with a text input and a category selector" (Simple Form Modal)
- "A notification message with an alert banner, description, and Approve/Reject buttons" (Notification Alert / Approval Message)
- "A dashboard home tab with a welcome header, key metrics in fields, and quick-action buttons" (Dashboard Home Tab)
- "A settings modal with dropdowns, checkboxes, and a time picker" (Settings Modal with Multiple Input Types)
- "A table of sprint tasks with status and points" (Data Table)
Get enough detail to plan the layout before generating any JSON.
请开发者描述他们希望布局呈现的样子或实现的功能。
若他们需要灵感,可提供示例——部分示例直接对应中的现成模板(括号内为模板名称),可在步骤3中以此为起点:
references/common-patterns.md- "包含文本输入框和类别选择器的反馈表单"(简单表单模态框)
- "带有警告横幅、描述和批准/拒绝按钮的通知消息"(通知警告/审批消息)
- "包含欢迎标题、关键指标字段和快速操作按钮的仪表盘主页标签"(仪表盘主页标签)
- "包含下拉菜单、复选框和时间选择器的设置模态框"(多输入类型设置模态框)
- "包含状态和点数的 sprint 任务表格"(数据表格)
在生成任何JSON之前,获取足够的细节以规划布局。
Step 3: Plan the Block Layout
步骤3:规划块布局
Based on the developer's description:
-
Fetch only what you need from the live docs:
- WebFetch the master index () to confirm the block and element types you plan to use exist and to grab links to their pages.
https://docs.slack.dev/reference/block-kit.md - Check (the one local reference file) if the request matches a common pattern; start from the template instead of building from scratch.
references/common-patterns.md - Defer reading individual component pages until Step 4, when you build each block's fields.
- WebFetch the master index (
-
Propose a numbered block outline. For example:text
1. header: "Weekly Report" 2. section: Summary text with a datepicker accessory 3. divider 4. section: Status fields (Name, Role, Team) 5. actions: "Approve" button (primary) and "Reject" button (danger) -
Present the outline to the developer and ask for approval or changes before generating JSON.
Surface constraints to check:
- Block count limit: 50 for messages, 100 for modals/home tabs
- Modal-specific: if using blocks, the modal payload must include a
inputfieldsubmit - Table: only one block per message
table - Surface compatibility (whether a block is valid on the chosen surface) and element compatibility (whether an element is allowed inside a given block) are not always spelled out on a component's doc page. Build the layout from the docs, and let in Step 5 confirm it. It is the authoritative check.
blocks.validate
根据开发者的描述:
-
仅从实时文档获取所需内容:
- 通过WebFetch获取主索引(),确认计划使用的块和元素类型是否存在,并获取其页面链接。
https://docs.slack.dev/reference/block-kit.md - 若请求匹配常见模式,可查看(本地参考文件);以此模板为起点,而非从零开始构建。
references/common-patterns.md - 延迟读取单个组件页面,直到步骤4构建每个块的字段时再进行。
- 通过WebFetch获取主索引(
-
提出编号的块大纲示例:text
1. header: "每周报告" 2. section: 包含日期选择器附件的摘要文本 3. divider 4. section: 状态字段(姓名、角色、团队) 5. actions: "批准"按钮(primary)和"拒绝"按钮(danger) -
将大纲呈现给开发者,在生成JSON前请求批准或修改。
需检查的载体约束:
- 块数量限制:消息最多50个,模态框/主页标签最多100个
- 模态框专属:若使用块,模态框负载必须包含
input字段submit - 表格:每条消息仅允许一个块
table - 载体兼容性(块是否适用于所选载体)和元素兼容性(元素是否允许在给定块内)并非总是在组件文档页面中明确说明。请根据文档构建布局,并通过步骤5中的确认。这是权威检查方式。
blocks.validate
Step 4: Generate the Block Kit JSON
步骤4:生成Block Kit JSON
Once the layout is approved, build each block from its live doc page, fetching each page's fields table (required vs optional, constraints) and JSON example with WebFetch. The URL patterns are in Source of Truth above; the one slug to remember is that every menu (, , , …) lives on . Fetch pages as you need them and reuse what you have already fetched — don't re-fetch the same page for every block of the same type. Then build the payload block-by-block and wrap it in the surface structure from Step 1.
*_selectstatic_selectusers_selectmulti_channels_selectselect-menu-element.mdGuidelines:
- Use descriptive values (e.g.,
action_idnot"approve_report_btn") — they identify the element in your interaction handlers"action_1" - Include values where the developer will need them for interaction handling
block_id - For modals, include ,
title,submit, andclose; for home tabs, thecallback_idwrappertype: "home" - Use text for rich formatting,
mrkdwnwhere required (headers, labels, modal title)plain_text
mrkdwn vs. the block: and blocks format text with Slack's (, , , ) — use these for short, interactive layouts. The separate block (Messages only) renders standard markdown (, headings, tables, numbered lists) and is meant for AI/LLM-generated or long-form content that already exists in standard markdown. Reach for it when the developer has such content or needs those features in the message body; there is a cumulative 12,000-character limit across all blocks in one message.
markdownsectioncontextmrkdwn*bold*_italic_~strike~`code`markdown**bold**markdownAccessibility is easy to skip and hard to retrofit, so build it in now:
- Give images descriptive (what the image shows, not just "image"), and make sure image-heavy layouts also carry the key information as text
alt_text - Summarize the layout in the message's fallback (notifications and screen readers show it instead of the blocks)
text - Use blocks for logical section headings — they convey document structure to assistive tech
header
Present the complete payload to the developer in the Step 1 surface structure.
布局获批后,从实时文档页面构建每个块,通过WebFetch获取每个页面的字段表(必填/可选、约束)和JSON示例。URL模式见上方权威来源;需记住的一个slug是:所有菜单(、、等)均在上。按需获取页面并重复使用已获取的内容——无需为同一类型的每个块重新获取页面。然后逐个构建负载块,并使用步骤1中的载体结构进行封装。
*_selectstatic_selectusers_selectmulti_channels_selectselect-menu-element.md指南:
- 使用描述性值(例如
action_id而非"approve_report_btn")——它们在交互处理程序中标识元素"action_1" - 在开发者需要进行交互处理的位置包含值
block_id - 对于模态框,包含、
title、submit和close;对于主页标签,包含callback_id封装type: "home" - 使用文本实现富格式,在需要的位置使用
mrkdwn(标题、标签、模态框标题)plain_text
mrkdwn 与 块的区别:和块使用Slack的(、、、)格式化文本——适用于短交互式布局。独立的块(仅消息可用)渲染标准markdown(、标题、表格、编号列表),适用于AI/LLM生成或已存在的长格式内容。当开发者拥有此类内容或需要在消息正文中使用这些功能时再选择它;单条消息中所有块的累计字符限制为12000个。
markdownsectioncontextmrkdwn*bold*_italic_~strike~`code`markdown**bold**markdown无障碍设计容易被忽略且难以后期补充,因此请从一开始就纳入:
- 为图片添加描述性(说明图片内容,而非仅写"image"),确保图片密集的布局也通过文本传达关键信息
alt_text - 在消息的备用文本中概述布局内容(通知和屏幕阅读器会显示它而非块内容)
text - 使用块作为逻辑章节标题——它们向辅助技术传达文档结构
header
将完整负载以步骤1中的载体结构呈现给开发者。
Step 5: Validate
步骤5:验证
Always validate. is a public Web API method, so no auth token is required.
blocks.validateThe authoritative reference for this method (its parameters, auth requirements, and response/error shape) is the live doc. WebFetch it before relying on any detail here: . It documents the accepted parameters ( for a message's blocks array, for a modal/home-tab view, for a full message payload; send exactly one) and the response shape.
https://docs.slack.dev/reference/methods/blocks.validate.mdblocksviewmessage务必进行验证。是公共Web API方法,无需授权令牌。
blocks.validate此方法的权威参考(参数、授权要求、响应/错误格式)见实时文档。在依赖此处的任何细节之前,请通过WebFetch获取该文档:。文档记录了接受的参数(对应消息的块数组,对应模态框/主页标签视图,对应完整消息负载;仅需发送其中一个)和响应格式。
https://docs.slack.dev/reference/methods/blocks.validate.mdblocksviewmessage5a. Build the validation request
5a. 构建验证请求
Prefer the Slack CLI when it's available, since it reuses the slack-cli skill's CLI detection and needs no token wrangling. If the CLI isn't installed, fall back to curl. Both call the same public method and return the same response, so Step 5b applies either way.
Path A: Slack CLI (preferred).
Use the skill, Step 1: Detect the Slack CLI, to check whether the public CLI is installed and resolve its command ().
slack:slack-cliSLACK_CMDIf the CLI is available, use the skill, Step 4: Calling Web API Methods (), to invoke it. That step covers the syntax. Run first to confirm the syntax and the flag that skips authentication. needs no token, so call it without authentication. Don't hard-code that flag from memory; read it from the help output so this stays correct if it's ever renamed. Pass the payload as a positional argument: for messages, or for modals and home tabs.
slack:slack-clislack apiSLACK_CMD api <method> key=value …SLACK_CMD api --helpblocks.validatekey=valueblocks=<JSON array>view=<JSON view object>Path B: curl (fallback, when the CLI isn't installed).
POST to the endpoint with the Bash tool. The API uses form-urlencoded encoding, so pass the JSON directly as the parameter value.
For messages, send the array as a form-encoded parameter:
blocksbash
curl -s -X POST 'https://slack.com/api/blocks.validate' \
-d 'blocks=[ ... the blocks array ... ]'For modals and home tabs, send the complete view object in the field:
viewbash
curl -s -X POST 'https://slack.com/api/blocks.validate' \
-d 'view={ "type": "modal", "title": ..., "blocks": [...] }'若Slack CLI可用,优先使用它,因为它可复用slack-cli技能的CLI检测功能,无需处理令牌。若未安装CLI,则回退到curl。两种方式调用的是同一个公共方法,返回相同响应,因此步骤5b均适用。
路径A:Slack CLI(优先)
使用技能的步骤1:检测Slack CLI,检查是否已安装公共CLI并解析其命令()。
slack:slack-cliSLACK_CMD若CLI可用,使用技能的步骤4:调用Web API方法()来调用它。该步骤涵盖语法。先运行确认语法以及跳过身份验证的标志。无需令牌,因此无需身份验证即可调用。请勿凭记忆硬编码该标志;请从帮助输出中读取,以便在标志重命名时保持正确性。将负载作为位置参数传递:消息使用,模态框和主页标签使用。
slack:slack-clislack apiSLACK_CMD api <method> key=value …SLACK_CMD api --helpblocks.validatekey=valueblocks=<JSON array>view=<JSON view object>路径B:curl(回退,当CLI未安装时)
通过Bash工具向端点发送POST请求。API使用form-urlencoded编码,因此直接将JSON作为参数值传递。
对于消息,将数组作为表单编码参数发送:
blocksbash
curl -s -X POST 'https://slack.com/api/blocks.validate' \
-d 'blocks=[ ... the blocks array ... ]'对于模态框和主页标签,在字段中发送完整视图对象:
viewbash
curl -s -X POST 'https://slack.com/api/blocks.validate' \
-d 'view={ "type": "modal", "title": ..., "blocks": [...] }'5b. Handle the response
5b. 处理响应
Success:
json
{ "ok": true }Tell the developer their blocks are valid.
Failure:
json
{
"ok": false,
"error": "invalid_blocks",
"errors": [
{
"code": "missing_field",
"message": "missing required field: type",
"field": "type",
"pointer": "/0"
}
]
}When validation fails:
- Read each error. is a JSON pointer to the offending node (e.g.,
pointer= first block,/0= second element of the third block,/2/elements/1= the/0/text/typefield of the first block's text object).typedescribes the problem, andmessage(when present) names the rule that failed and its expected values.constraint - Fix the JSON. For the authoritative meaning of an error code and the field requirements behind it, consult the live method doc () and the relevant block/element/composition-object page you fetched in Steps 3-4.
https://docs.slack.dev/reference/methods/blocks.validate.md - Re-validate. Repeat until .
"ok": true
成功:
json
{ "ok": true }告知开发者他们的块验证通过。
失败:
json
{
"ok": false,
"error": "invalid_blocks",
"errors": [
{
"code": "missing_field",
"message": "missing required field: type",
"field": "type",
"pointer": "/0"
}
]
}验证失败时:
- 读取每个错误。是指向错误节点的JSON指针(例如
pointer=第一个块,/0=第三个块的第二个元素,/2/elements/1=第一个块的文本对象的/0/text/type字段)。type描述问题,message(若存在)指明违反的规则及其预期值。constraint - 修复JSON。若需了解错误代码的权威含义及背后的字段要求,请查阅实时方法文档()以及步骤3-4中获取的相关块/元素/组合对象页面。
https://docs.slack.dev/reference/methods/blocks.validate.md - 重新验证。重复此过程直到返回。
"ok": true
Step 6: Deliver the Final Output
步骤6:交付最终输出
Present the validated payload, then help the developer put it to use.
呈现验证通过的负载,然后帮助开发者将其投入使用。
Send it
发送负载
Building the payload is this skill's job; sending it (, , , and the token/scope handling around them) belongs to the Web API layer. To call the right method — via the Slack CLI, raw curl, or a Bolt SDK — use the skill, Step 4: Call the Method (Manage), passing this payload as the method's argument (messages) or argument (modals and home tabs). That skill matches the argument names to the SDK or HTTP call so we don't duplicate them here.
chat.postMessageviews.openviews.publishslack:slack-apiblocksview构建负载是此技能的职责;发送负载(、、及相关令牌/权限处理)属于Web API层。要调用正确的方法——通过Slack CLI、原始curl或Bolt SDK,请使用技能的步骤4:调用方法(管理),将此负载作为方法的参数(消息)或参数(模态框和主页标签)传递。该技能会将参数名称匹配到SDK或HTTP调用,因此此处不再重复。
chat.postMessageviews.openviews.publishslack:slack-apiblocksviewPreview it
预览布局
Help the developer view their layout with the Block Kit Builder. Prefer the Slack CLI if it is installed. The CLI automatically loads the blocks, saving the developer from copying and pasting. If the CLI is not available, provide the standard Builder link instead.
Path A: Slack CLI (preferred).
Use the skill, Step 1: Detect the Slack CLI, to check whether the public CLI is installed and resolve its command ().
slack:slack-cliSLACK_CMDIf the CLI is available, run to see how to pass the blocks and open the preview. The command loads the blocks into the Block Kit Builder in the developer's browser.
SLACK_CMD blocks preview --helpBecause you run the CLI non-interactively, this command also needs a flag. Resolve the team ID with the skill, Step 2: Command Discovery via Help, whose "Resolving and values" guidance covers running ; Any authenticated workspace works for a preview, if several are available, pick one and mention which you used rather than blocking on the choice.
--teamslack:slack-cli--app--teamSLACK_CMD auth listPath B: Block Kit Builder link (fallback, when the CLI isn't installed).
Offer the Block Kit Builder link so the developer can paste the JSON in and tweak visually: . Builder needs an object ( or a full view object), not a bare array.
https://app.slack.com/block-kit-builder{ "blocks": [...] }帮助开发者通过Block Kit Builder查看其布局。若已安装Slack CLI,优先使用它。CLI会自动加载块,省去开发者复制粘贴的步骤。若CLI不可用,则提供标准Builder链接。
路径A:Slack CLI(优先)
使用技能的步骤1:检测Slack CLI,检查是否已安装公共CLI并解析其命令()。
slack:slack-cliSLACK_CMD若CLI可用,运行查看如何传递块并打开预览。该命令会将块加载到开发者浏览器中的Block Kit Builder。
SLACK_CMD blocks preview --help由于是非交互式运行CLI,此命令还需要标志。使用技能的步骤2:通过帮助发现命令中的"解析和值"指南,运行来解析团队ID;任何已认证的工作区均可用于预览,若有多个可用,选择一个并告知开发者,无需等待选择。
--teamslack:slack-cli--app--teamSLACK_CMD auth list路径B:Block Kit Builder链接(回退,当CLI未安装时)
提供Block Kit Builder链接,让开发者粘贴JSON并进行可视化调整:。Builder需要对象(或完整视图对象),而非纯数组。
https://app.slack.com/block-kit-builder{ "blocks": [...] }Step 7: Iterate
步骤7:迭代
Ask whether the developer wants to add, modify, remove, or reorder blocks, or build a layout for a different surface. If they want to change the layout you just produced, re-enter Modification Mode (it preserves their / values); for a fresh layout, loop back to Step 3.
block_idaction_id询问开发者是否需要添加、修改、删除或重新排序块,或为其他载体构建布局。若他们想要修改刚生成的布局,则重新进入修改模式(保留/值);若需构建新布局,则回到步骤3。
block_idaction_idNotes
注意事项
- Scope: this skill owns building and validating the Block Kit payload — choosing the surface, composing the JSON from the live docs, and confirming it with . Sending it lives in the Web API layer (
blocks.validate), and CLI detection/auth inslack:slack-api.slack:slack-cli - needs no auth — it's a public method, so it works without a token whether you call it via the CLI or curl. Always validate before finalizing (Step 5).
blocks.validate
- 范围:此技能负责构建和验证Block Kit负载——选择载体、从实时文档编写JSON、通过确认。发送负载属于Web API层(
blocks.validate),CLI检测/授权属于slack:slack-api。slack:slack-cli - 无需授权——它是公共方法,因此无论通过CLI还是curl调用,无需令牌即可工作。在最终确定前务必进行验证(步骤5)。
blocks.validate