返回顶部
f

feishu-doc-writer飞书文档写入器

Feishu (Lark) Document API writing spec. Converts Markdown content to Feishu Block structures and writes to cloud docs. Handles concurrency ordering. Use when syncing articles, creating document blocks, or writing long-form content to Feishu docs.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
863
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

feishu-doc-writer

Feishu Document Writer

Reference spec for writing content to Feishu (Lark) cloud documents via the Docx API. Feishu docs use a Block tree model — raw Markdown is not accepted.

CODEBLOCK0

Preferred Approach: Convert API

Feishu provides an official Markdown -> Blocks conversion endpoint:

CODEBLOCK1

CODEBLOCK2

Pros: No manual Block JSON construction. Handles most standard Markdown.
Limitation: Does not support Feishu-specific blocks (Callout, etc.) — use manual Block creation for those.

Block Type Reference

block_typeNameJSON KeyNotes
1PageINLINECODE0Document root
2
Text | text | Paragraph | | 3-11 | Heading1-9 | heading1-heading9 | Headings | | 12 | Bullet | bullet | Unordered list (each item = separate block) | | 13 | Ordered | ordered | Ordered list | | 14 | Code | code | Code block (with style.language enum) | | 15 | Quote | quote | Blockquote | | 17 | Todo | todo | Checkbox item (with style.done) | | 19 | Callout | callout | Highlight box (Feishu-specific, container block) | | 22 | Divider | divider | Horizontal rule | | 27 | Image | image | Two-step: create placeholder, then upload | | 31 | Table | table | Table | | 34 | QuoteContainer | quote_container | Quote container |

Create Blocks API

CODEBLOCK3

  • - block_id: Parent block ID (usually document_id itself for root)
  • INLINECODE18: Insert position (0 = beginning, -1 or omit = end)

Block JSON Examples

Text

CODEBLOCK4

Heading

CODEBLOCK5

Bullet / Ordered List

CODEBLOCK6

Each list item is a separate Block.

Code Block

CODEBLOCK7

Common language enums: PlainText=1, JavaScript=23, Python=40, TypeScript=49, Go=20, Shell=46, SQL=47, Java=22, Rust=44, C=12, CSS=17, HTML=21, Docker=19.

Callout (Feishu-specific highlight box)

Callout is a container block — create it first, then add child blocks inside.

CODEBLOCK8

Color enums: Red=1, Orange=2, Yellow=3, Green=4, Blue=5, Purple=6, Grey=7.

Divider

CODEBLOCK9

Image (two-step)

CODEBLOCK10

Text Styling

Apply styles via text_element_style in text_run:

PropertyTypeEffect
INLINECODE21boolBold
INLINECODE22
bool | Italic |
| strikethrough | bool | Strikethrough |
| underline | bool | Underline |
| inline_code | bool | Inline code |
| text_color | int | Text color (same enum as callout colors) |
| background_color | int | Background color |
| link.url | string | Hyperlink |

Multiple text_run elements in one block = mixed styles in one paragraph.

Markdown to Block Mapping

Markdownblock_typeJSON Key
INLINECODE303INLINECODE31
INLINECODE32
4 | heading2 | | ### H3 | 5 | heading3 | | Paragraph | 2 | text | | - item | 12 | bullet | | 1. item | 13 | ordered | | Code fence | 14 | code | | > quote | 15 | quote | | - [ ] todo | 17 | todo | | --- | 22 | divider | | ![](url) | 27 | image (two-step) | | **bold** | -- | text_element_style.bold: true | | *italic* | -- | text_element_style.italic: true | | ` code | -- | textelementstyle.inlinecode: true | | ~~strike~~ | -- | textelementstyle.strikethrough: true | | text | -- | textelementstyle.link.url | | (no MD equivalent) | 19 | callout (Feishu-specific) | ## Concurrency & Ordering (Critical) **Problem**: Concurrent Block creation API calls produce random ordering. ### Solution A: Single Batch Request (Recommended) Put all blocks in one children array, single API call: CODEBLOCK11 ### Solution B: Serial Writes with Index For long content requiring multiple requests, execute **serially** with explicit index: CODEBLOCK12 ### Solution C: Collect-Then-Write (Recommended) CODEBLOCK13 **Never** let the LLM write one paragraph at a time with concurrent API calls. ## Complete Write Flow 1. **Create document**: POST /open-apis/docx/v1/documents with { "foldertoken": "", "title": "Title" } -> returns documentid 2. **Build Block array**: Convert full content to Block JSON 3. **Batch write**: POST .../documents/{docid}/blocks/{docid}/children?documentrevisionid=-1 with all blocks 4. **Container blocks** (optional): For Callout etc., get blockid from step 3 response, then add children ## Custom Callout Syntax Since Markdown has no Callout equivalent, use this custom markup: CODEBLOCK14 | Param | Values | Default | Purpose | |-------|--------|---------|---------| | color | red, orange, yellow, green, blue, purple, grey | yellow | Background & border | | emoji | Any Feishu emoji_id (bulb, star, warning, fire) | bulb | Left icon | | border | Same as color values | Same as color | Border color (override) | Common templates: CODEBLOCK15 ## Rate Limits & Constraints - Max blocks per batch: ~50 recommended - Long articles: Split by H2/H3 sections, 200-500ms between batches - Always use documentrevisionid=-1 (latest version) - Token validity: ~2 hours, cache and refresh before expiry ## Authentication CODEBLOCK16 ## Schema Pitfalls (Battle-tested) - **No Markdown tables in write ops** — use bullet lists instead (prevents schema errors) - **No nested code blocks inside lists** — Feishu schema validation is strict on nesting depth - **Callout is a container** — always requires a two-step create (container first, then children) - **Each list item = separate Block** — don't try to put multiple items in one block ## References - Create Blocks API: https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-children/create - Block Data Structure: https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/data-structure/block - Convert API: https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document/convert - Extended API reference: See FEISHUAPI_HANDBOOK.md` in workspace root

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 feishu-doc-write-1776420033 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 feishu-doc-write-1776420033 技能

通过命令行安装

skillhub install feishu-doc-write-1776420033

下载

⬇ 下载 feishu-doc-writer v1.0.0(免费)

文件大小: 4.29 KB | 发布时间: 2026-4-17 18:51

v1.0.0 最新 2026-4-17 18:51
- Initial release of feishu-doc-writer, providing a comprehensive spec for converting Markdown to Feishu (Lark) cloud document blocks.
- Supports Feishu's Block tree model, including headings, text, lists, code, quotes, todos, dividers, images, tables, and Feishu-specific Callout blocks.
- Details the official Markdown-to-Blocks conversion endpoint for streamlined document creation.
- Includes extensive Block type references with JSON examples for all major block types.
- Explains concurrency and block ordering pitfalls with recommended batch writing solutions.
- Documents custom Callout markup syntax for enhanced content formatting.
- Provides text styling options and Markdown-to-Block mapping for feature-rich document output.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部