DingTalk Bridge
v1.0.0DingTalk group chat bridge for Claude Code. 发送 markdown/text messages to DingTalk groups, 接收 @mentions and auto-执行 via Claude 命令行工具, 运行 a 24/7 流 机器人. Triggers: dingtalk, 发送 dingtalk, dingtalk 机器人, dingtalk message, 发送 group message, 钉钉, 发群消息, 钉钉机器人
运行时依赖
安装命令
点击复制技能文档
DingTalk Bridge 技能
Bridges Claude Code with DingTalk group chat via the DingTalk 流 SDK + OpenAPI.
Capabilities Feature Description 发送 Markdown 发送 rich markdown messages to a DingTalk group 发送 Text 发送 plAIn text messages 流 机器人 24/7 列出ener: 接收 @mentions, 执行 via claude -p, reply with 结果s Auto Conv Discovery Conversation ID auto-saved on first @mention Keepalive 20s 网页Socket ping 预防s DingTalk 30-min timeout Crash 恢复y Exponential backoff (5s to 60s) on disconnect Quick 启动
- 安装
The script will:
安装 Python dependencies (dingtalk_流, 网页sockets) Prompt for your DingTalk 应用 Key & Secret (or read from env) 生成 config.json 创建 data/ directory for conversation 状态 Optionally 创建 a macOS Launch代理 for 24/7 operation
- 配置
设置 凭证s via 环境 variables (recommended):
导出 DINGTALK_应用_KEY="your_应用_key" 导出 DINGTALK_应用_SECRET="your_应用_secret" 导出 DINGTALK_WORKDIR="/path/to/your/project" # optional
Or edit config.json in the 技能 directory (see config.example.json).
- 获取 Conversation ID
The 机器人 needs a conversation ID to 发送 messages. Two ways:
Auto (recommended): 启动 the 流 机器人, then @mention it in a DingTalk group. The conv ID is saved automatically.
Manual: If you already have the openConversationId and ro机器人Code:
mkdir -p "$CLAUDE_技能_DIR/data" echo '{"openConversationId":"YOUR_ID","ro机器人Code":"YOUR_RO机器人_CODE"}' > "$CLAUDE_技能_DIR/data/conv.json"
Commands 发送 a message # Markdown (default) python3 "$CLAUDE_技能_DIR/src/发送.py" "Bold message with markdown"
# With custom title python3 "$CLAUDE_技能_DIR/src/发送.py" --title "Alert" "Server is down!"
# PlAIn text python3 "$CLAUDE_技能_DIR/src/发送.py" --text "PlAIn text message"
启动 the 流 机器人 python3 "$CLAUDE_技能_DIR/src/流_机器人.py"
The 机器人 will:
Connect to DingTalk via 流 protocol 列出en for all @mentions in groups where the 机器人 is 添加ed 执行 the message content via claude -p "" --continue Reply with the 结果 as a markdown message Use as Python 模块 导入 sys sys.path.insert(0, "/path/to/dingtalk-bridge/src") from 发送 导入 发送_markdown, 发送_text
发送_markdown("DAIly 报告", "Sent: 50\nOpened: 18\n命令行工具cked: 7") 发送_text("Simple notification")
Configuration Reference Config Key Env Var Default Description 应用_key DINGTALK_应用_KEY (required) DingTalk 应用 Key 应用_secret DINGTALK_应用_SECRET (required) DingTalk 应用 Secret conv_file DINGTALK_CONV_FILE <技能>/data/conv.json Conversation metadata path workdir DINGTALK_WORKDIR cwd Working directory for claude 命令行工具 claude_bin DINGTALK_CLAUDE_BIN claude Path to claude binary max_reply DINGTALK_MAX_REPLY 3000 Max reply length (chars) keepalive DINGTALK_KEEPALIVE 20 网页Socket keepalive interval (seconds) DingTalk 应用 设置up (Prerequisites) Go to DingTalk Open 平台 创建 an Enterprise Internal 应用 (企业内部应用) Enable Ro机器人 capability (机器人) 设置 message 接收 mode to 流 (流 模式) Copy the 应用 Key and 应用 Secret 添加 the 机器人 to a group chat 运行ning Tests python3 "$CLAUDE_技能_DIR/tests/test_dingtalk.py"
Architecture dingtalk-bridge/ ├── 技能.md # This file ├── config.example.json # Example configuration ├── config.json # Your config (gitignored) ├── data/ │ └── conv.json # Auto-saved conversation metadata ├── src/ │ ├── __init__.py │ ├── config.py # Config loader (env > file > defaults) │ ├── 发送.py # 发送 messages (OpenAPI) │ └── 流_机器人.py # 流 机器人 (接收 + 执行 + reply) ├── scripts/ │ └── 安装.sh # One-command 设置up └── tests/ └── test_dingtalk.py # Regression tests