npx skills add https://github.com/breath57/dingtalk-skills --skill dingtalk-documentHandles all operations for DingTalk knowledge bases and documents. This file is a Policy Guide containing only decision logic and workflows. For complete API request formats, refer to the "references/api.md Index" at the end.
dt_helper.shis located atscripts/dt_helper.shin the same directory as thisSKILL.md.
workspaceId and rootNodeIdtype is FILE or 广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
FOLDER/v1.0/doc/suites/documents/{id}): Can use docKey or dentryUuid
docKey, dentryUuid, nodeIddocKey / dentryUuid can be used for reading/writing content; nodeId is used for deletion and document management APIsnodeId returned by wiki/nodes is actually the dentryUuid and can be directly used for content read/writebash scripts/dt_helper.sh --to-unionidbash scripts/dt_helper.sh --get KEY; only validate items essential for this taskbash scripts/dt_helper.sh --set KEY=VALUEbash scripts/dt_helper.sh; details of token acquisition and caching are handled automatically/tmp/<task>.sh and then execute with bash /tmp/<task>.sh. Do not paste multi-line commands directly into the terminal (terminal tools may truncate them), and avoid using <<'EOF' syntax (heredoc can also be truncated in tools, leading to variable loss).DINGTALK_APP_KEY, DINGTALK_APP_SECRET, DINGTALK_MY_USER_IDDINGTALK_MY_OPERATOR_ID (if missing, first use bash scripts/dt_helper.sh --to-unionid to automatically convert and write back)workspaceId/nodeId/docKey are task parameters, obtained at runtime from user input or API responses.Rule: Do not proceed to the API call step before passing the "current task configuration validation".
Credentials are prohibited from being printed in full in the output; when confirming, only show the first 4 characters +
****
| Configuration Key | Required | Description | How to Obtain |
|---|---|---|---|
DINGTALK_APP_KEY | ✅ | Application AppKey | DingTalk Open Platform → Application Management → Credentials |
DINGTALK_APP_SECRET | ✅ | Application AppSecret | Same as above |
DINGTALK_MY_USER_ID | ✅ | Current user's enterprise employee ID (userId) | Admin Console → Contacts → Member Management → Click name to view |
DINGTALK_MY_OPERATOR_ID | ✅ | Current user's unionId (operatorId) | Initially automatically converted and written by bash scripts/dt_helper.sh --to-unionid |
| Identifier | Description |
|---|---|
userId (= staffId) | Internal enterprise employee ID, viewable via Admin Console -> Contacts -> Member Management -> Click name |
unionId | Cross-enterprise/cross-application unique identifier, obtainable via bash scripts/dt_helper.sh --to-unionid <userid> |
#!/bin/bash
set -e
HELPER="./scripts/dt_helper.sh"
NEW_TOKEN=$(bash "$HELPER" --token)
OPERATOR_ID=$(bash "$HELPER" --get DINGTALK_MY_OPERATOR_ID)
# Append specific API calls here, e.g., query knowledge base list:
WORKSPACES=$(curl -s -X GET "https://api.dingtalk.com/v2.0/wiki/workspaces?operatorId=${OPERATOR_ID}&maxResults=20" \
-H "x-acs-dingtalk-access-token: $NEW_TOKEN")
echo "Knowledge Base List: $WORKSPACES"
Token Expiration Handling: dt_helper only caches based on time and cannot detect if a token is revoked early. If the API returns 401 (token invalid/expired), use
--nocacheto skip the cache and force re-acquisition:NEW_TOKEN=$(bash "$HELPER" --token --nocache)
Once you've determined what to do, use the following commands to extract the complete API details (request format, parameter descriptions, return value examples) for the corresponding section from references/api.md:
grep -A 30 "^## 1. Query Knowledge Base List" references/api.md
grep -A 10 "^## 2. Query Knowledge Base Information" references/api.md
grep -A 35 "^## 3. Query Node List" references/api.md
grep -A 10 "^## 4. Query Single Node" references/api.md
grep -A 15 "^## 5. Query Node by URL" references/api.md
grep -A 28 "^## 6. Create Document" references/api.md
grep -A 10 "^## 7. Delete Document" references/api.md
grep -A 30 "^## 8. Read Document Content" references/api.md
grep -A 15 "^## 9. Overwrite Document Content" references/api.md
grep -A 12 "^## 10. Append Text to Paragraph" references/api.md
grep -A 18 "^## 11. Add Document Member" references/api.md
grep -A 12 "^## 12. Update Document Member Permissions" references/api.md
grep -A 10 "^## 13. Remove Document Member" references/api.md
grep -A 10 "^## Error Codes" references/api.md
grep -A 10 "^## Required Application Permissions" references/api.md
Weekly Installs
414
Repository
GitHub Stars
29
First Seen
Mar 5, 2026
Security Audits
Installed on
github-copilot411
gemini-cli410
codex410
kimi-cli410
cursor410
opencode410
负责钉钉知识库和文档的所有操作。本文件为策略指南 ,仅包含决策逻辑和工作流程。完整 API 请求格式见文末「references/api.md 查阅索引」。
dt_helper.sh位于本SKILL.md同级目录的scripts/dt_helper.sh。
workspaceId 和 rootNodeIdtype 为 FILE 或 FOLDER/v1.0/doc/suites/documents/{id}):可用 docKey 或 dentryUuid
docKey、dentryUuid、nodeIddocKey / dentryUuid 可用于读写正文;nodeId 用于删除和文档管理类接口wiki/nodes 返回的 nodeId 实际上是 dentryUuid,可直接用于正文读写bash scripts/dt_helper.sh --to-unionid 自动转换bash scripts/dt_helper.sh --get KEY 读取;仅校验本任务必须项bash scripts/dt_helper.sh --set KEY=VALUE 写入bash scripts/dt_helper.sh,token 获取与缓存细节无需关心/tmp/<task>.sh 再 bash /tmp/<task>.sh 执行。不要把多行命令直接粘到终端里(终端工具会截断),也不要用 <<'EOF' 语法(heredoc 在工具中同样会被截断导致变量丢失)DINGTALK_APP_KEY、DINGTALK_APP_SECRET、DINGTALK_MY_USER_IDDINGTALK_MY_OPERATOR_ID(若缺失,先用 bash scripts/dt_helper.sh --to-unionid 自动转换并写回)workspaceId/nodeId/docKey 属于任务参数,运行时从用户输入或 API 响应中获取规则:未通过“本次任务配置校验”前,不得进入 API 调用步骤。
凭证禁止在输出中完整打印,确认时仅显示前 4 位 +
****
| 配置键 | 必填 | 说明 | 如何获取 |
|---|---|---|---|
DINGTALK_APP_KEY | ✅ | 应用 AppKey | 钉钉开放平台 → 应用管理 → 凭证信息 |
DINGTALK_APP_SECRET | ✅ | 应用 AppSecret | 同上 |
DINGTALK_MY_USER_ID | ✅ | 当前用户的企业员工 ID(userId) | 管理后台 → 通讯录 → 成员管理 → 点击姓名查看 |
DINGTALK_MY_OPERATOR_ID | ✅ | 当前用户的 unionId(operatorId) | 首次由 bash scripts/dt_helper.sh --to-unionid 自动转换并写入 |
| 标识 | 说明 |
|---|---|
userId(= staffId) | 企业内部员工 ID,可通过管理后台 -> 通讯录 -> 成员管理 -> 点击姓名查看 |
unionId | 跨企业/跨应用唯一标识,可通过 bash scripts/dt_helper.sh --to-unionid <userid> 获取 |
#!/bin/bash
set -e
HELPER="./scripts/dt_helper.sh"
NEW_TOKEN=$(bash "$HELPER" --token)
OPERATOR_ID=$(bash "$HELPER" --get DINGTALK_MY_OPERATOR_ID)
# 在此追加具体 API 调用,例如查询知识库列表:
WORKSPACES=$(curl -s -X GET "https://api.dingtalk.com/v2.0/wiki/workspaces?operatorId=${OPERATOR_ID}&maxResults=20" \
-H "x-acs-dingtalk-access-token: $NEW_TOKEN")
echo "知识库列表: $WORKSPACES"
Token 失效处理 :dt_helper 仅按时间缓存,无法感知 token 被提前吊销。若 API 返回 401(token 无效/过期),用
--nocache跳过缓存强制重新获取:NEW_TOKEN=$(bash "$HELPER" --token --nocache)
确定好要做什么之后,用以下命令从 references/api.md 中提取对应章节的完整 API 细节(请求格式、参数说明、返回值示例):
grep -A 30 "^## 1. 查询知识库列表" references/api.md
grep -A 10 "^## 2. 查询知识库信息" references/api.md
grep -A 35 "^## 3. 查询节点列表" references/api.md
grep -A 10 "^## 4. 查询单个节点" references/api.md
grep -A 15 "^## 5. 通过 URL 查询节点" references/api.md
grep -A 28 "^## 6. 创建文档" references/api.md
grep -A 10 "^## 7. 删除文档" references/api.md
grep -A 30 "^## 8. 读取文档内容" references/api.md
grep -A 15 "^## 9. 覆盖写入文档内容" references/api.md
grep -A 12 "^## 10. 追加文本到段落" references/api.md
grep -A 18 "^## 11. 添加文档成员" references/api.md
grep -A 12 "^## 12. 更新文档成员权限" references/api.md
grep -A 10 "^## 13. 移除文档成员" references/api.md
grep -A 10 "^## 错误码" references/api.md
grep -A 10 "^## 所需应用权限" references/api.md
Weekly Installs
414
Repository
GitHub Stars
29
First Seen
Mar 5, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
github-copilot411
gemini-cli410
codex410
kimi-cli410
cursor410
opencode410
头脑风暴技能:AI协作设计流程,将创意转化为完整规范与实施计划
77,000 周安装