Install
openclaw skills install dingtalk-bot-chenDingTalk Bot integration for messaging, group management, approval workflows, and attendance. Send messages, manage groups, handle approvals, and automate notifications via DingTalk Open API.
openclaw skills install dingtalk-bot-chenComplete DingTalk bot integration for AI agents.
Set environment variables:
# For webhook-based bots
export DINGTALK_WEBHOOK_URL="https://oapi.dingtalk.com/robot/send?access_token=xxx"
export DINGTALK_SECRET="SECxxx"
# For API-based bots
export DINGTALK_APP_KEY="ding_xxx"
export DINGTALK_APP_SECRET="xxx"
export DINGTALK_AGENT_ID="xxx"
from dingtalk_bot import DingTalkBot
# Webhook mode
bot = DingTalkBot(webhook_url="YOUR_WEBHOOK_URL", secret="YOUR_SECRET")
# Send text
bot.send_text("Hello from bot!")
# Send with at mentions
bot.send_text("Hello @all", at_mobiles=["13800138000"])
bot.send_markdown(
title="Daily Report",
text="## Sales Report\n- Today: $10,000\n- Week: $50,000"
)
bot.send_action_card(
title="Approval Request",
text="Please approve the following request",
buttons=[
{"title": "Approve", "action_url": "https://.../approve"},
{"title": "Reject", "action_url": "https://.../reject"}
]
)
# API mode with authentication
bot = DingTalkBot(app_key="xxx", app_secret="xxx", agent_id="xxx")
group = bot.create_group(name="Project Team", owner_user_id="manager123")
print(group["open_conversation_id"])
# Create approval
approval = bot.create_approval(
process_code="PROC-xxx",
originator_user_id="user123",
form_values={"title": "Leave Request", "days": 3}
)
# Get status
status = bot.get_approval_instance(approval["process_instance_id"])
records = bot.get_attendance_records(
work_date="2024-03-15",
user_ids=["user123", "user456"]
)
print(records)
| Method | Description |
|---|---|
send_text(text, at_mobiles=None, at_user_ids=None) | Send text message |
send_markdown(title, text) | Send markdown message |
send_link(title, text, message_url, pic_url) | Send link message |
send_action_card(title, text, buttons) | Send action card |
send_feed_card(links) | Send feed card |
| Method | Description |
|---|---|
create_group(name, owner_user_id, user_ids) | Create group |
add_group_members(chat_id, user_ids) | Add members |
remove_group_members(chat_id, user_ids) | Remove members |
create_approval(process_code, originator_user_id, form_values) | Create approval |
get_approval_instance(process_instance_id) | Get approval status |
get_attendance_records(work_date, user_ids) | Get attendance |
get_vacation_balance(user_id) | Get vacation balance |
For webhook security, generate signature:
import hmac
import hashlib
import base64
import time
timestamp = str(round(time.time() * 1000))
secret = "YOUR_SECRET"
string_to_sign = f'{timestamp}\n{secret}'
sign = hmac.new(string_to_sign.encode('utf-8'), digestmod=hashlib.sha256).digest()
signature = base64.b64encode(sign).decode('utf-8')
Common errors:
400031: Invalid signature - check secret400035: Missing parameters - verify request body400036: Invalid approval process - check process_code400037: Duplicate approval - instance already exists