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.md
.
dt_helper.sh
is located in
scripts/dt_helper.sh
at the same level as this
SKILL.md
.

核心概念

Core Concepts

  • 路径中的
    userId
    :日程 API 路径
    /v1.0/calendar/users/{userId}/...
    中的
    {userId}
    unionId(与待办、文档一致),不是 staffId。
  • 主日历:个人默认日历的
    calendarId
    固定使用字符串
    primary
    (小写)。创建/查询/列表/更新/删除均针对
    .../calendars/primary/events...
  • 时间格式
    start
    /
    end
    、闲忙的
    startTime
    /
    endTime
    、列表的
    timeMin
    /
    timeMax
    须使用 UTC ISO8601 且含毫秒,例如
    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)。是否与线下会议、审批流联动以钉钉侧能力为准。
  • userId
    in the path
    : The
    {userId}
    in the schedule API path
    /v1.0/calendar/users/{userId}/...
    is unionId (consistent with to-dos and documents), not staffId.
  • Primary Calendar: The
    calendarId
    of the personal default calendar uses the fixed string
    primary
    (lowercase). All create/query/list/update/delete operations target
    .../calendars/primary/events...
    .
  • Time Format:
    start
    /
    end
    ,
    startTime
    /
    endTime
    for busy/free status,
    timeMin
    /
    timeMax
    for list queries must use UTC ISO8601 with milliseconds, for example
    2026-03-24T07:02:48.000Z
    . Omitting milliseconds can easily trigger
    ParsedISO8601TimestampError
    .
  • Modify Schedule: The HTTP method is PUT (same path as the "partial update" semantics), the request body needs to include the schedule
    id
    and the fields to be modified (such as
    summary
    ).
  • Video Conference: Add
    "onlineMeetingInfo":{"type":"dingtalk"}
    to the request body when creating a schedule, the response will include
    onlineMeetingInfo.url
    and other related information.
  • Meeting Room: First query by
    roomIds
    + time window through the meeting room availability interface; then add meeting room to the existing schedule (requires the enterprise internal meeting room
    roomId
    , which can be found in the management backend or open platform). For integration testing, you can use the environment variable
    TEST_MEETING_ROOM_IDS
    (comma-separated).
  • 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)

用户意图优先接口方向
订会议室、查会议室有没有空
POST .../meetingRooms/schedules/query
给已有日程加会议室
POST .../events/{eventId}/meetingRooms
要签到码、签退链接
GET .../signInLinks
GET .../signOutLinks
每周重复、每天重复创建日程时带
recurrence
(见 api.md)
只看人忙闲(不针对会议室)
POST .../querySchedule
User IntentPriority API Direction
Book a meeting room, check meeting room availability
POST .../meetingRooms/schedules/query
Add meeting room to existing schedule
POST .../events/{eventId}/meetingRooms
Request check-in code, check-out link
GET .../signInLinks
,
GET .../signOutLinks
Weekly recurrence, daily recurrenceAdd
recurrence
when creating a schedule (see api.md)
Only query user availability (not for meeting rooms)
POST .../querySchedule

工作流程(每次执行前)

Workflow (before each execution)

  1. 识别任务 → 按上表归类后,再选具体 API(见
    references/api.md
    )。
  2. 校验配置
    bash scripts/dt_helper.sh --get
    读取
    DINGTALK_APP_KEY
    DINGTALK_APP_SECRET
    DINGTALK_MY_USER_ID
    DINGTALK_MY_OPERATOR_ID
    (缺 unionId 时
    --to-unionid
    )。
  3. 收集缺失项 → 一次性询问并
    --set
    写入
    ~/.dingtalk-skills/config
  4. 获取新版 Token
    NEW_TOKEN=$(bash scripts/dt_helper.sh --token)
    ,请求头
    x-acs-dingtalk-access-token
  5. 执行 API → 多行逻辑写入
    /tmp/<task>.sh
    再执行;禁止 heredoc。
  1. Identify the task → Classify according to the table above, then select the specific API (see
    references/api.md
    ).
  2. Verify configuration → Run
    bash scripts/dt_helper.sh --get
    to read
    DINGTALK_APP_KEY
    ,
    DINGTALK_APP_SECRET
    ,
    DINGTALK_MY_USER_ID
    ,
    DINGTALK_MY_OPERATOR_ID
    (use
    --to-unionid
    if unionId is missing).
  3. Collect missing items → Ask for all missing information at once and write to
    ~/.dingtalk-skills/config
    with
    --set
    .
  4. Get the latest Token
    NEW_TOKEN=$(bash scripts/dt_helper.sh --token)
    , add to request header
    x-acs-dingtalk-access-token
    .
  5. Execute API → Write multi-line logic to
    /tmp/<task>.sh
    before execution; heredoc is prohibited.

按任务校验配置

Verify Configuration by Task

  • 通用必需
    DINGTALK_APP_KEY
    DINGTALK_APP_SECRET
    DINGTALK_MY_USER_ID
    ;调用前需 unionId
    DINGTALK_MY_OPERATOR_ID
    或通过
    --to-unionid
    生成)。
未通过校验前不得调用 API。凭证展示仅前 4 位 +
****
  • General requirements:
    DINGTALK_APP_KEY
    ,
    DINGTALK_APP_SECRET
    ,
    DINGTALK_MY_USER_ID
    ; unionId is required before calling (either
    DINGTALK_MY_OPERATOR_ID
    or generated via
    --to-unionid
    ).
API calls are not allowed before passing verification. Only the first 4 digits of credentials are displayed +
****
.

所需配置

Required Configuration

配置键必填说明
DINGTALK_APP_KEY
Client ID(AppKey)
DINGTALK_APP_SECRET
Client Secret
DINGTALK_MY_USER_ID
当前用户 userId(管理后台通讯录)
DINGTALK_MY_OPERATOR_ID
当前用户 unionId(
--to-unionid
可写入)
Configuration KeyRequiredDescription
DINGTALK_APP_KEY
Client ID (AppKey)
DINGTALK_APP_SECRET
Client Secret
DINGTALK_MY_USER_ID
Current user userId (from management backend address book)
DINGTALK_MY_OPERATOR_ID
Current user unionId (can be written via
--to-unionid
)

身份标识说明

Identity Description

标识说明
userId
企业员工 ID,管理后台可见
unionId
日程路径参数与 body 中的用户标识均使用 unionId
userId → unionId:使用旧版
access_token
POST https://oapi.dingtalk.com/topapi/v2/user/get
(见
references/api.md
),取
result.unionid
(无下划线)。
IdentifierDescription
userId
Enterprise employee ID, visible in management backend
unionId
All user identifiers in schedule path parameters and body use unionId
userId → unionId: Use old version
access_token
to call
POST https://oapi.dingtalk.com/topapi/v2/user/get
(see
references/api.md
), get
result.unionid
(no underscore).

执行脚本模板

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.md
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.md