dingtalk-calendar
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese钉钉日程技能
DingTalk Schedule Skill
负责钉钉日历(Calendar)API 的操作。本文件为策略指南;完整请求格式见 。
references/api.md位于本dt_helper.sh同级目录的SKILL.md。scripts/dt_helper.sh
Responsible for operating DingTalk Calendar API. This document is a policy guide; for complete request formats, refer to .
references/api.mdis located indt_helper.shat the same level as thisscripts/dt_helper.sh.SKILL.md
核心概念
Core Concepts
- 路径中的 :日程 API 路径
userId中的/v1.0/calendar/users/{userId}/...为 unionId(与待办、文档一致),不是 staffId。{userId} - 主日历:个人默认日历的 固定使用字符串
calendarId(小写)。创建/查询/列表/更新/删除均针对primary。.../calendars/primary/events... - 时间格式:/
start、闲忙的end/startTime、列表的endTime/timeMin须使用 UTC ISO8601 且含毫秒,例如timeMax。省略毫秒易触发2026-03-24T07:02:48.000Z。ParsedISO8601TimestampError - 修改日程:HTTP 方法为 PUT(与「部分更新」语义对应的路径相同),请求体需包含日程 及要改的字段(如
id)。summary - 视频会议:创建日程时在请求体中加 ,响应含
"onlineMeetingInfo":{"type":"dingtalk"}等。onlineMeetingInfo.url - 会议室:先通过 会议室忙闲 接口按 + 时间窗查询;再在已有日程上 添加会议室(需企业内会议室
roomIds,管理后台或开放平台可查)。集成测试可用环境变量roomId(逗号分隔)。TEST_MEETING_ROOM_IDS - 签到/签退:日程创建后,可 GET 签到/签退链接 分发参会人;组织者/参与者 POST 签到;详情用 GET signin / signOut 列表接口(见 api.md)。是否与线下会议、审批流联动以钉钉侧能力为准。
- in the path: The
userIdin the schedule API path{userId}is unionId (consistent with to-dos and documents), not staffId./v1.0/calendar/users/{userId}/... - Primary Calendar: The of the personal default calendar uses the fixed string
calendarId(lowercase). All create/query/list/update/delete operations targetprimary..../calendars/primary/events... - Time Format: /
start,end/startTimefor busy/free status,endTime/timeMinfor list queries must use UTC ISO8601 with milliseconds, for exampletimeMax. Omitting milliseconds can easily trigger2026-03-24T07:02:48.000Z.ParsedISO8601TimestampError - Modify Schedule: The HTTP method is PUT (same path as the "partial update" semantics), the request body needs to include the schedule and the fields to be modified (such as
id).summary - Video Conference: Add to the request body when creating a schedule, the response will include
"onlineMeetingInfo":{"type":"dingtalk"}and other related information.onlineMeetingInfo.url - Meeting Room: First query by + time window through the meeting room availability interface; then add meeting room to the existing schedule (requires the enterprise internal meeting room
roomIds, which can be found in the management backend or open platform). For integration testing, you can use the environment variableroomId(comma-separated).TEST_MEETING_ROOM_IDS - Check-in/Check-out: After the schedule is created, you can GET check-in/check-out links to distribute to participants; organizers/participants POST to complete check-in; for details, use the GET signin / signOut list interface (see api.md). Whether it is linked with offline meetings and approval flows is subject to DingTalk's capabilities.
场景路由(先分类再调 API)
Scenario Routing (classify first then call API)
| 用户意图 | 优先接口方向 |
|---|---|
| 订会议室、查会议室有没有空 | |
| 给已有日程加会议室 | |
| 要签到码、签退链接 | |
| 每周重复、每天重复 | 创建日程时带 |
| 只看人忙闲(不针对会议室) | |
| User Intent | Priority API Direction |
|---|---|
| Book a meeting room, check meeting room availability | |
| Add meeting room to existing schedule | |
| Request check-in code, check-out link | |
| Weekly recurrence, daily recurrence | Add |
| Only query user availability (not for meeting rooms) | |
工作流程(每次执行前)
Workflow (before each execution)
- 识别任务 → 按上表归类后,再选具体 API(见 )。
references/api.md - 校验配置 → 读取
bash scripts/dt_helper.sh --get、DINGTALK_APP_KEY、DINGTALK_APP_SECRET、DINGTALK_MY_USER_ID(缺 unionId 时DINGTALK_MY_OPERATOR_ID)。--to-unionid - 收集缺失项 → 一次性询问并 写入
--set。~/.dingtalk-skills/config - 获取新版 Token → ,请求头
NEW_TOKEN=$(bash scripts/dt_helper.sh --token)。x-acs-dingtalk-access-token - 执行 API → 多行逻辑写入 再执行;禁止 heredoc。
/tmp/<task>.sh
- Identify the task → Classify according to the table above, then select the specific API (see ).
references/api.md - Verify configuration → Run to read
bash scripts/dt_helper.sh --get,DINGTALK_APP_KEY,DINGTALK_APP_SECRET,DINGTALK_MY_USER_ID(useDINGTALK_MY_OPERATOR_IDif unionId is missing).--to-unionid - Collect missing items → Ask for all missing information at once and write to with
~/.dingtalk-skills/config.--set - Get the latest Token → , add to request header
NEW_TOKEN=$(bash scripts/dt_helper.sh --token).x-acs-dingtalk-access-token - Execute API → Write multi-line logic to before execution; heredoc is prohibited.
/tmp/<task>.sh
按任务校验配置
Verify Configuration by Task
- 通用必需:、
DINGTALK_APP_KEY、DINGTALK_APP_SECRET;调用前需 unionId(DINGTALK_MY_USER_ID或通过DINGTALK_MY_OPERATOR_ID生成)。--to-unionid
未通过校验前不得调用 API。凭证展示仅前 4 位 +。****
- General requirements: ,
DINGTALK_APP_KEY,DINGTALK_APP_SECRET; unionId is required before calling (eitherDINGTALK_MY_USER_IDor generated viaDINGTALK_MY_OPERATOR_ID).--to-unionid
API calls are not allowed before passing verification. Only the first 4 digits of credentials are displayed +.****
所需配置
Required Configuration
| 配置键 | 必填 | 说明 |
|---|---|---|
| ✅ | Client ID(AppKey) |
| ✅ | Client Secret |
| ✅ | 当前用户 userId(管理后台通讯录) |
| ✅ | 当前用户 unionId( |
| Configuration Key | Required | Description |
|---|---|---|
| ✅ | Client ID (AppKey) |
| ✅ | Client Secret |
| ✅ | Current user userId (from management backend address book) |
| ✅ | Current user unionId (can be written via |
身份标识说明
Identity Description
| 标识 | 说明 |
|---|---|
| 企业员工 ID,管理后台可见 |
| 日程路径参数与 body 中的用户标识均使用 unionId |
userId → unionId:使用旧版 调 (见 ),取 (无下划线)。
access_tokenPOST https://oapi.dingtalk.com/topapi/v2/user/getreferences/api.mdresult.unionid| Identifier | Description |
|---|---|
| Enterprise employee ID, visible in management backend |
| All user identifiers in schedule path parameters and body use unionId |
userId → unionId: Use old version to call (see ), get (no underscore).
access_tokenPOST https://oapi.dingtalk.com/topapi/v2/user/getreferences/api.mdresult.unionid执行脚本模板
Execution Script Template
bash
#!/bin/bash
set -e
HELPER="./scripts/dt_helper.sh"
NEW_TOKEN=$(bash "$HELPER" --token)
UNION_ID=$(bash "$HELPER" --get DINGTALK_MY_OPERATOR_ID)
CAL_ID="primary"
curl -s -X POST "https://api.dingtalk.com/v1.0/calendar/users/${UNION_ID}/calendars/${CAL_ID}/events" \
-H "x-acs-dingtalk-access-token: $NEW_TOKEN" \
-H "Content-Type: application/json" \
-d '{"summary":"周会","start":{"dateTime":"2026-03-25T02:00:00.000Z","timeZone":"UTC"},"end":{"dateTime":"2026-03-25T03:00:00.000Z","timeZone":"UTC"}}'Token 异常时:bash "$HELPER" --token --nocache
bash
#!/bin/bash
set -e
HELPER="./scripts/dt_helper.sh"
NEW_TOKEN=$(bash "$HELPER" --token)
UNION_ID=$(bash "$HELPER" --get DINGTALK_MY_OPERATOR_ID)
CAL_ID="primary"
curl -s -X POST "https://api.dingtalk.com/v1.0/calendar/users/${UNION_ID}/calendars/${CAL_ID}/events" \
-H "x-acs-dingtalk-access-token: $NEW_TOKEN" \
-H "Content-Type: application/json" \
-d '{"summary":"周会","start":{"dateTime":"2026-03-25T02:00:00.000Z","timeZone":"UTC"},"end":{"dateTime":"2026-03-25T03:00:00.000Z","timeZone":"UTC"}}'When Token is abnormal:bash "$HELPER" --token --nocache
references/api.md 查阅索引
references/api.md Reference Index
bash
grep -A 35 "^## 1. 创建日程" references/api.md
grep -A 25 "^## 2. 查询单个日程" references/api.md
grep -A 30 "^## 3. 查询日程列表" references/api.md
grep -A 25 "^## 4. 更新日程" references/api.md
grep -A 15 "^## 5. 删除日程" references/api.md
grep -A 28 "^## 6. 查询闲忙" references/api.md
grep -A 22 "^## 7. 视频会议" references/api.md
grep -A 28 "^## 8. 查询会议室忙闲" references/api.md
grep -A 25 "^## 9. 添加与移除会议室" references/api.md
grep -A 18 "^## 10. 签到与签退链接" references/api.md
grep -A 22 "^## 11. 签到与签退详情列表" references/api.md
grep -A 18 "^## 12. 签到与签退操作" references/api.md
grep -A 35 "^## 13. 循环日程" references/api.md
grep -A 15 "^## 14. 订阅日历" references/api.md
grep -A 15 "^## 错误码" references/api.md
grep -A 18 "^## 所需应用权限" references/api.mdbash
grep -A 35 "^## 1. 创建日程" references/api.md
grep -A 25 "^## 2. 查询单个日程" references/api.md
grep -A 30 "^## 3. 查询日程列表" references/api.md
grep -A 25 "^## 4. 更新日程" references/api.md
grep -A 15 "^## 5. 删除日程" references/api.md
grep -A 28 "^## 6. 查询闲忙" references/api.md
grep -A 22 "^## 7. 视频会议" references/api.md
grep -A 28 "^## 8. 查询会议室忙闲" references/api.md
grep -A 25 "^## 9. 添加与移除会议室" references/api.md
grep -A 18 "^## 10. 签到与签退链接" references/api.md
grep -A 22 "^## 11. 签到与签退详情列表" references/api.md
grep -A 18 "^## 12. 签到与签退操作" references/api.md
grep -A 35 "^## 13. 循环日程" references/api.md
grep -A 15 "^## 14. 订阅日历" references/api.md
grep -A 15 "^## 错误码" references/api.md
grep -A 18 "^## 所需应用权限" references/api.md