wecomcli-smartpage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

企业微信智能文档管理

WeCom Smart Document Management

wecom-cli
是企业微信提供的命令行程序,所有操作通过执行
wecom-cli
命令完成。
资源型技能,负责智能文档(原名智能主页,
/smartpage/*
)的创建与内容导出。
wecom-cli
is a command-line program provided by WeCom, and all operations are completed by executing the
wecom-cli
command.
This is a resource-type skill responsible for creating and exporting Smart Documents (formerly known as Smart Homepage,
/smartpage/*
).

调用方式

Calling Method

通过
wecom-cli
调用,品类为
doc
bash
wecom-cli doc <tool_name> '<json_params>'
Call via
wecom-cli
, with the category
doc
:
bash
wecom-cli doc <tool_name> '<json_params>'

返回格式说明

Return Format Description

所有接口返回 JSON 对象,包含以下公共字段:
字段类型说明
errcode
integer返回码,
0
表示成功,非
0
表示失败
errmsg
string错误信息,成功时为
"ok"
errcode
不为
0
时,说明接口调用失败,可重试 1 次;若仍失败,将
errcode
errmsg
展示给用户。
All interfaces return a JSON object containing the following public fields:
FieldTypeDescription
errcode
integerReturn code,
0
indicates success, non-
0
indicates failure
errmsg
stringError message,
"ok"
when successful
When
errcode
is not
0
, it means the interface call failed, and you can retry once; if it still fails, display
errcode
and
errmsg
to the user.

特殊错误码

Special Error Codes

errcodeerrmsg含义处理方式
851002
incompatible doc type
文档品类与所调用的接口不匹配确认目标 URL 为
/smartpage/*
;若不是,请跳转到对应品类的 skill
errcodeerrmsgMeaningHandling Method
851002
incompatible doc type
The document category does not match the called interfaceConfirm that the target URL is
/smartpage/*
; if not, switch to the corresponding category skill

接口详述

Interface Details

创建智能文档

Create Smart Document

创建智能文档(原名智能主页),支持传入标题和多个子页面。每个子页面可指定标题、内容类型和本地文件路径。创建成功返回
docid
url
特殊语法:此命令必须使用
+smartpage_create
(带
+
前缀),加号不可省略;该
+
仅适用于此命令,不要泛化到其他
doc
子命令。
命令
bash
wecom-cli doc +smartpage_create '<JSON 参数>'
参数
参数类型必填默认值说明
title
string智能文档标题
pages
array子页面列表
pages[].page_title
string子页面标题
pages[].content_type
int1内容类型:1-Markdown,0-Text(纯文本)
pages[].page_filepath
string子页面内容对应的本地文件路径
注意事项
  • content_type
    必须与文件实际内容匹配
    .md
    文件或包含 Markdown 语法的内容必须传
    1
    ,仅纯文本才传
    0
    。绝大多数场景应传
    1
  • docid
    仅在创建时返回,需妥善保存。
  • 每个子页面的 Markdown 文件大小不得超过 10MB,超过会导致创建失败;如文件过大,需先拆分为多个子页面再创建。
  • 智能文档还支持背景块(
    <card>
    )、分栏(
    <grid>
    )等扩展语法,详见 references/smartpage-create.md
Create a Smart Document (formerly known as Smart Homepage), supporting the input of a title and multiple subpages. Each subpage can specify a title, content type, and local file path. Returns
docid
and
url
upon successful creation.
Special Syntax: This command must use
+smartpage_create
(with the
+
prefix), the plus sign cannot be omitted; this
+
only applies to this command, do not generalize it to other
doc
subcommands.
Command
bash
wecom-cli doc +smartpage_create '<JSON parameters>'
Parameters
ParameterTypeRequiredDefault ValueDescription
title
stringNoSmart Document title
pages
arrayYesList of subpages
pages[].page_title
stringNoSubpage title
pages[].content_type
intNo1Content type: 1-Markdown, 0-Text (plain text)
pages[].page_filepath
stringNoLocal file path corresponding to the subpage content
Notes
  • content_type
    must match the actual content of the file:
    .md
    files or content containing Markdown syntax must pass
    1
    , only plain text should pass
    0
    .
    1
    should be used in most scenarios.
  • docid
    is only returned during creation, please save it properly.
  • The size of each subpage's Markdown file must not exceed 10MB, otherwise creation will fail; if the file is too large, split it into multiple subpages before creation.
  • Smart Documents also support extended syntax such as background blocks (
    <card>
    ) and columns (
    <grid>
    ), see references/smartpage-create.md for details.

导出智能文档内容

Export Smart Document Content

获取智能文档的完整内容,导出为 Markdown。采用异步两步操作:先用
smartpage_export_task
提交导出任务拿到
task_id
,再用
smartpage_get_export_result
轮询任务,直到
task_done
true
时返回
content
第一步:提交导出任务
bash
undefined
Obtain the complete content of a Smart Document and export it to Markdown. Uses asynchronous two-step operation: first submit an export task with
smartpage_export_task
to get
task_id
, then poll the task with
smartpage_get_export_result
until
task_done
is
true
, then return
content
.
Step 1: Submit Export Task
bash
undefined

通过 docid

Via docid

wecom-cli doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}'
wecom-cli doc smartpage_export_task '{"docid": "DOCID", "content_type": 1}'

通过 url

Via url

wecom-cli doc smartpage_export_task '{"url": "https://doc.weixin.qq.com/smartpage/xxx", "content_type": 1}'

| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| `docid` | string | 与 `url` 二选一 | — | 智能文档的 docid |
| `url` | string | 与 `docid` 二选一 | — | 智能文档的访问链接 |
| `content_type` | int | 是 | — | 导出内容格式,目前仅支持 `1`(Markdown) |

**第二步:轮询导出结果**

```bash
wecom-cli doc smartpage_get_export_result '{"task_id": "TASK_ID"}'
参数类型必填默认值说明
task_id
string
smartpage_export_task
返回的任务 ID
使用规则
  • 第一步获取
    task_id
    后,携带其调用第二步;若
    task_done
    false
    则继续轮询,直到
    task_done
    true
    ,返回的
    content
    字段即为完整 Markdown 内容。
参见 API 详情
wecom-cli doc smartpage_export_task '{"url": "https://doc.weixin.qq.com/smartpage/xxx", "content_type": 1}'

| Parameter | Type | Required | Default Value | Description |
|---|---|---|---|---|
| `docid` | string | Either `docid` or `url` is required | — | docid of the Smart Document |
| `url` | string | Either `docid` or `url` is required | — | Access link of the Smart Document |
| `content_type` | int | Yes | — | Export content format, currently only supports `1` (Markdown) |

**Step 2: Poll Export Result**

```bash
wecom-cli doc smartpage_get_export_result '{"task_id": "TASK_ID"}'
ParameterTypeRequiredDefault ValueDescription
task_id
stringYesTask ID returned by
smartpage_export_task
Usage Rules
  • After obtaining
    task_id
    in the first step, call the second step with it; if
    task_done
    is
    false
    , continue polling until
    task_done
    is
    true
    , and the returned
    content
    field is the complete Markdown content.
See API Details.

跨技能依赖

Cross-Skill Dependencies

依赖技能典型协作场景数据流向
wecomcli-msg
用户要求把智能文档链接发给某人/某群本 skill 创建后返回
url
wecomcli-msg
发送链接
Dependent SkillTypical Collaboration ScenarioData Flow
wecomcli-msg
User requests to send the Smart Document link to someone/some groupThis skill returns
url
after creation →
wecomcli-msg
sends the link