Install
openclaw skills install dingtalk-cli-auto基于钉钉官方CLI工具dws,实现消息发送、日程管理、待办事项、通讯录查询及机器人消息自动化操作。
openclaw skills install dingtalk-cli-auto钉钉 CLI 自动化技能 - 基于钉钉官方 CLI 工具 (dws) 实现企业自动化功能。
本 Skill 封装了钉钉官方 CLI 工具 dws (DingTalk Workspace CLI),提供以下企业自动化能力:
# Linux/macOS
curl -fsSL https://raw.githubusercontent.com/DingTalk-Real-AI/dingtalk-workspace-cli/main/scripts/install.sh | sh
# Windows PowerShell
irm https://raw.githubusercontent.com/DingTalk-Real-AI/dingtalk-workspace-cli/main/scripts/install.ps1 | iex
AppKey 和 AppSecretexport DWS_CLIENT_ID="your-app-key"
export DWS_CLIENT_SECRET="your-app-secret"
或使用 OpenClaw 环境配置:
openclaw config set dingtalk.app_key your-app-key
openclaw config set dingtalk.app_secret your-app-secret
dws auth login
按提示完成 OAuth 设备流认证。
send_text_message发送文本消息给指定用户或群聊
# 给用户发送消息
node scripts/message.js send-text --user-id "user123" --content "Hello, this is a test message"
# 给群聊发送消息
node scripts/message.js send-text --chat-id "chat123" --content "Group notification"
send_markdown_message发送 Markdown 格式消息
node scripts/message.js send-md --user-id "user123" --title "通知" --content "**重要提醒**:会议即将开始"
create_schedule创建日程/会议
node scripts/calendar.js create \
--title "周例会" \
--start "2026-04-03T14:00:00" \
--end "2026-04-03T15:00:00" \
--attendees "user1,user2,user3" \
--location "会议室A"
list_schedules查询日程列表
# 查询今天的日程
node scripts/calendar.js list --today
# 查询指定日期范围
node scripts/calendar.js list --start "2026-04-01" --end "2026-04-07"
check_free_busy查询用户空闲时间
node scripts/calendar.js free-busy \
--users "user1,user2" \
--start "2026-04-03T09:00:00" \
--end "2026-04-03T18:00:00"
create_todo创建待办事项
node scripts/todo.js create \
--content "完成项目文档" \
--due "2026-04-05T18:00:00" \
--assignees "user1"
list_todos查询待办列表
# 所有待办
node scripts/todo.js list
# 即将到期的待办
node scripts/todo.js list --due-within 3
complete_todo完成待办
node scripts/todo.js complete --id "todo123"
delete_todo删除待办
node scripts/todo.js delete --id "todo123"
search_contacts搜索联系人
# 按姓名搜索
node scripts/contact.js search --name "张三"
# 按部门搜索
node scripts/contact.js search --dept "技术部"
get_department_members获取部门成员列表
node scripts/contact.js dept-members --dept-id "dept123"
send_robot_message发送群机器人消息
node scripts/robot.js send \
--webhook "https://oapi.dingtalk.com/robot/send?access_token=xxx" \
--secret "SECxxx" \
--content "机器人通知消息"
# 获取今日待办
node scripts/todo.js list --today
# 创建今日待办
node scripts/todo.js create --content "提交日报" --due "today 18:00"
# 搜索参会人员
node scripts/contact.js search --name "张三"
# 检查空闲时间
node scripts/calendar.js free-busy --users "user1,user2" --duration 60
# 创建会议
node scripts/calendar.js create \
--title "项目评审会" \
--start "2026-04-03T14:00:00" \
--duration 60 \
--attendees "user1,user2"
# 发送会议提醒
node scripts/message.js send-md \
--chat-id "chat123" \
--title "会议提醒" \
--content "**项目评审会** 将于14:00开始,请准时参加"
# 查找成员
node scripts/contact.js search --name "李四"
# 创建并分派待办
node scripts/todo.js create \
--content "完成API文档编写" \
--assignees "user2" \
--due "2026-04-05"
# 发送通知
node scripts/message.js send-text \
--user-id "user2" \
--content "你有一个新的待办任务:完成API文档编写,截止2026-04-05"
所有脚本遵循统一的参数规范:
| 参数 | 说明 | 示例 |
|---|---|---|
--user-id | 用户ID | user123 |
--chat-id | 群聊ID | chat456 |
--content | 消息/内容 | Hello World |
--title | 标题 | 会议通知 |
--start | 开始时间 | 2026-04-03T14:00:00 |
--end | 结束时间 | 2026-04-03T15:00:00 |
--duration | 持续时间(分钟) | 60 |
--attendees | 参会人(逗号分隔) | user1,user2 |
--assignees | 负责人(逗号分隔) | user1 |
--due | 截止日期 | 2026-04-05 或 today |
--dept-id | 部门ID | dept123 |
--name | 姓名 | 张三 |
--dept | 部门名称 | 技术部 |
--webhook | 机器人Webhook | https://... |
--secret | 机器人密钥 | SEC... |
2026-04-03T14:00:00today, tomorrow, +3d (3天后)今天18:00, 明天上午9点| 错误码 | 说明 | 解决方案 |
|---|---|---|
| 401 | 未认证或Token过期 | 执行 dws auth login |
| 403 | 权限不足 | 检查应用权限配置 |
| 404 | 用户/群聊不存在 | 检查ID是否正确 |
| 400 | 参数错误 | 检查参数格式 |
| 429 | 请求过于频繁 | 稍后重试 |
添加 --debug 参数查看详细日志:
node scripts/message.js send-text --user-id "user123" --content "test" --debug
在 OpenClaw 配置文件中添加:
{
"skills": {
"dingtalk-cli-auto": {
"app_key": "your-app-key",
"app_secret": "your-app-secret",
"default_chat_id": "your-default-chat-id"
}
}
}
| 变量名 | 说明 | 必需 |
|---|---|---|
DWS_CLIENT_ID | 钉钉AppKey | 是 |
DWS_CLIENT_SECRET | 钉钉AppSecret | 是 |
DINGTALK_DEFAULT_CHAT | 默认群聊ID | 否 |
DINGTALK_DEBUG | 调试模式 | 否 |
# 克隆到技能目录
cd ~/clawd/skills
git clone <repo-url> dingtalk-cli-auto
# 安装依赖
cd dingtalk-cli-auto
npm install
# 配置认证
export DWS_CLIENT_ID="your-app-key"
export DWS_CLIENT_SECRET="your-app-secret"
dws auth login
# 测试
npm test
运行测试用例:
# 全部测试
npm test
# 单模块测试
npm run test:message
npm run test:calendar
npm run test:todo
npm run test:contact
解决方案:
# 确认安装路径
which dws
# 添加到 PATH
export PATH="$HOME/.local/bin:$PATH"
# 重新安装
curl -fsSL https://raw.githubusercontent.com/DingTalk-Real-AI/dingtalk-workspace-cli/main/scripts/install.sh | sh
解决方案:
# 清除缓存重新认证
dws auth logout
dws auth login
# 检查环境变量
echo $DWS_CLIENT_ID
echo $DWS_CLIENT_SECRET
解决方案:
MIT