时间:2026-03-16 11:10
人气:
作者:admin
本文详细介绍如何在 OpenClaw 中配置钉钉机器人,实现通过钉钉与 AI 助手交互。
在开始配置前,你需要准备:
打开 钉钉开发者后台,使用钉钉账号登录。
重要:选择「Stream 模式」:
你的服务器地址/callback发布成功后,获取以下信息:
| 字段 | 说明 | 获取位置 |
|---|---|---|
| AppKey (Client ID) | 应用标识 | 应用详情→凭证与回见 |
| AppSecret (Client Secret) | 应用密钥 | 应用详情→凭证与回见 |
| CorpId | 企业ID | 钉钉管理后台→我的企业 |
| AgentId | 应用ID | 应用详情→基础信息 |
| RobotCode | 机器人Code | 机器人配置页面 |
# 启动配置向导
openclaw configure
# 或直接配置渠道
openclaw configure --section channels
按照提示选择「钉钉」,输入凭证信息。
编辑 OpenClaw 配置文件:
{
"channels": {
"dingtalk": {
"enabled": true,
"config": {
"clientId": "你的AppKey",
"clientSecret": "你的AppSecret",
"corpId": "你的企业ID",
"agentId": "你的应用ID",
"robotCode": "你的RobotCode"
}
}
}
}
openclaw config patch --raw '{
"channels": {
"dingtalk": {
"enabled": true,
"config": {
"clientId": "你的AppKey",
"clientSecret": "你的AppSecret",
"corpId": "你的企业ID",
"agentId": "你的应用ID",
"robotCode": "你的RobotCode"
}
}
}
}'
openclaw gateway restart
openclaw status
应该显示:
DingTalk: configured
# 发送测试消息
openclaw message send --channel dingtalk --target 你的用户ID --message "测试消息"
在钉钉中@你的机器人,发送消息,应该能收到回复。
检查:
确保配置文件路径正确,尝试重启 Gateway。
可能是网络问题,检查服务器网络稳定性。
直接修改配置文件后重启 Gateway 即可。
让机器人在群聊中工作:
配置自动回复关键词:
{
"channels": {
"dingtalk": {
"keywords": {
"天气": "我来帮你查天气",
"新闻": "我来帮你查新闻"
}
}
}
}
设置定时任务推送消息:
openclaw cron add \
--name "每日早报" \
--cron "0 7 * * *" \
--message "早安!今天是..." \
--channel dingtalk \
--announce
{
"channels": {
"dingtalk": {
"enabled": true,
"config": {
"clientId": "dingxxxxx",
"clientSecret": "xxxxxxxxxxxxxxxxxxxx",
"corpId": "dingxxxxx",
"agentId": "1234567890",
"robotCode": "dingxxxxx"
},
"options": {
"autoReply": true,
"mentionOnly": false
}
}
}
}
| 命令 | 说明 |
|---|---|
openclaw status |
查看钉钉连接状态 |
openclaw gateway restart |
重启 Gateway |
openclaw channels list |
查看所有渠道 |
openclaw message send --channel dingtalk |
发送钉钉消息 |
openclaw logs |
查看钉钉日志 |
配置钉钉机器人需要以下步骤:
按照本文档操作,通常 5-10 分钟即可完成配置。
如果有问题,欢迎在评论区留言讨论!