3.0 KiB
3.0 KiB
DING 消息 (ding) 命令参考
命令总览
发送 DING 消息
Usage:
dws ding message send [flags]
Example:
dws ding message send --robot-code <ROBOT_CODE> --users <USER_ID_1>,<USER_ID_2> --content "请查看"
Flags:
--content string 消息内容 (必填)
--robot-code string 机器人 ID (必填, 可从 应用管理→机器人 获取, 或设 DINGTALK_DING_ROBOT_CODE)
--users string 接收人 userId 列表 (必填)
--type string 提醒类型: app/sms/call (默认 app)
撤回 DING 消息
Usage:
dws ding message recall [flags]
Example:
dws ding message recall --robot-code <ROBOT_CODE> --id <OPEN_DING_ID>
Flags:
--id string DING 消息 ID (必填)
--robot-code string 机器人 ID (必填, 或设 DINGTALK_DING_ROBOT_CODE)
查询 DING 消息历史
列表项会同时返回 DING 的 content、openDingId 与状态,可直接读取钉内容,无需再调用详情接口。
Usage:
dws ding message list [flags]
Example:
dws ding message list --type ALL
dws ding message list --type UNREAD
dws ding message list --type SEND --cursor 10
Flags:
--cursor int 分页游标 (首次传 0, 翻页传返回的 nextCursor)
--type string 消息类型: ALL / UNREAD / SEND / NEW_COMMENT / DELETED (默认 ALL; 服务端不接受空值, CLI 不传时会自动按 ALL 查询, 故裸跑 `ding message list` 即可)
查看 DING 接收状态
Usage:
dws ding message receiver-status [flags]
Example:
dws ding message receiver-status --ding-id <OPEN_DING_ID>
# 查询 dingId: dws ding message list --type ALL
Flags:
--ding-id string DING 消息 openDingId (必填)
意图判断
用户说"DING 一下/紧急通知/电话提醒" → message send
用户说"撤回 DING" → message recall
用户说"DING 消息/查 DING/DING 历史/我的 DING" → message list
用户说"DING 接收状态/谁收到了 DING/DING 已读" → message receiver-status
关键区分:
- ding(紧急提醒, 支持电话/短信) vs bot(常规群/单聊消息)
- sms/call 类型有通信费用
核心工作流
# 应用内 DING (免费)
dws ding message send --robot-code <ROBOT_CODE> --type app --users userId1,userId2 --content "请查看" --format json
# 电话 DING (紧急, 有成本!)
dws ding message send --robot-code <ROBOT_CODE> --type call --users userId1 --content "紧急告警" --format json
# 撤回
dws ding message recall --robot-code <ROBOT_CODE> --id <OPEN_DING_ID> --format json
上下文传递表
| 操作 | 提取 | 用于 |
|---|---|---|
message send |
openDingId |
message recall 的 --id |
message list |
openDingId |
message receiver-status 的 --ding-id |
注意事项
--robot-code从钉钉开放平台 应用管理 → 机器人 中获取,也可设环境变量DINGTALK_DING_ROBOT_CODE- sms/call 类型有通信费用,使用前需和用户确认
- 默认
--type app(应用内 DING,免费)