WeCom Notification Skill
Overview
Send notifications to group chats via WeCom robot Webhook, supporting text, images (Markdown format), and Markdown rich text.
Quick Start
Installation
CODEBLOCK0
Usage
CODEBLOCK1
Features
- - ✅ Text notifications
- ✅ Image notifications (Markdown format)
- ✅ Markdown rich text
- ✅ @all mention support
- ✅ Automatic retry on failure
- ✅ Complete error handling
- ✅ Both CLI and code-based invocation
Webhook URL Format
CODEBLOCK2
2. Call in Code
CODEBLOCK3
3. Message Format Examples
Text message:
CODEBLOCK4
Markdown message:
CODEBLOCK5
Examples
Example 1: Send Simple Notification
CODEBLOCK6
Example 2: Send Notification with Image
CODEBLOCK7
Example 3: Send Markdown Format Notification
CODEBLOCK8
Error Handling
Common Errors
- 1. Invalid Webhook URL: Check if the URL format is correct
- Network connection failure: Check network connectivity and firewall settings
- Insufficient permissions: Check if the robot has permission to send messages
- Content too long: WeCom message content limit is 2048 characters
Error Response
CODEBLOCK9
Testing
Test Connection
CODEBLOCK10
View Configuration
CODEBLOCK11
Integration with Other Skills
Call from Python
CODEBLOCK12
Security Considerations
- 1. Protect Webhook URL: The Webhook URL contains sensitive information. Do not share it publicly.
- Access control: Set minimum required permissions for the robot.
- Content moderation: Avoid sending sensitive or inappropriate content.
- Rate limiting: Comply with WeCom's message sending rate limits.
企业微信通知技能
概述
通过企业微信机器人Webhook向群聊发送通知,支持文本、图片(Markdown格式)和Markdown富文本。
快速开始
安装
bash
复制到OpenClaw技能目录
cp -r qywx-notify ~/.openclaw/skills/
安装依赖
cd ~/.openclaw/skills/qywx-notify
npm install
使用方法
bash
发送文本通知
openclaw skill qywx-notify send \
--webhook 你的webhook地址 \
--content 你好,这是一条测试通知
发送带图片的通知
openclaw skill qywx-notify send \
--webhook 你的webhook地址 \
--content 请查看图片 \
--image https://example.com/image.jpg
发送Markdown格式通知
openclaw skill qywx-notify send \
--webhook 你的webhook地址 \
--content ## 重要通知\n\n- 项目更新\n- 会议提醒 \
--msgtype markdown \
--title 每日简报
功能特性
- - ✅ 文本通知
- ✅ 图片通知(Markdown格式)
- ✅ Markdown富文本
- ✅ @所有人提醒支持
- ✅ 失败自动重试
- ✅ 完善的错误处理
- ✅ 支持CLI和代码调用
Webhook地址格式
https://{你的域名}/weai-core/v1/qywx/webhook-messages/bot/{机器人令牌}
2. 代码调用
javascript
const QywxNotifySkill = require(./index.js);
const skill = new QywxNotifySkill(config);
// 发送通知
const result = await skill.send({
webhook: 你的webhook地址,
content: 系统运行正常,
image: https://example.com/status.jpg,
mentionAll: true
});
console.log(result);
3. 消息格式示例
文本消息:
json
{
msgtype: text,
text: {
content: 你好,请查看图片:
,
mentioned_list: [@all]
}
}
Markdown消息:
json
{
msgtype: markdown,
markdown: {
content: # 重要通知\n\n- 项目更新\n- 会议提醒\n\n
}
}
示例
示例1:发送简单通知
bash
openclaw skill qywx-notify send \
--webhook 你的webhook地址 \
--content 维护通知:今晚20:00-22:00系统升级,请提前保存工作。
示例2:发送带图片的通知
bash
openclaw skill qywx-notify send \
--webhook 你的webhook地址 \
--content 月度报告已生成,请查阅: \
--image https://example.com/reports/202503/report.jpg \
--mentionAll true
示例3:发送Markdown格式通知
bash
openclaw skill qywx-notify send \
--webhook 你的webhook地址 \
--content ## 项目进度\n\n✅ 已完成:\n- 需求分析\n- 原型设计\n\n⏳ 进行中:\n- 开发工作\n\n📅 下周计划:\n- 测试验收 \
--msgtype markdown \
--title 项目周报
错误处理
常见错误
- 1. 无效的Webhook地址:检查URL格式是否正确
- 网络连接失败:检查网络连接和防火墙设置
- 权限不足:检查机器人是否有发送消息的权限
- 内容过长:企业微信消息内容限制为2048字符
错误响应
json
{
success: false,
message: 发送失败:企业微信API错误:无效的webhook地址(错误码:400),
error: {
errcode: 400,
errmsg: 无效的webhook地址
}
}
测试
测试连接
bash
openclaw skill qywx-notify test --webhook 你的webhook地址
查看配置
bash
openclaw skill qywx-notify config
与其他技能集成
从Python调用
python
import subprocess
import json
def sendqywxnotification(webhook, content, image=None):
发送企业微信通知
cmd = [openclaw, skill, qywx-notify, send]
cmd.extend([--webhook, webhook])
cmd.extend([--content, content])
if image:
cmd.extend([--image, image])
try:
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
return json.loads(result.stdout)
except subprocess.CalledProcessError as e:
print(f发送失败:{e.stderr})
return None
安全注意事项
- 1. 保护Webhook地址:Webhook地址包含敏感信息,请勿公开分享。
- 访问控制:为机器人设置最小必要权限。
- 内容审核:避免发送敏感或不适当的内容。
- 频率限制:遵守企业微信的消息发送频率限制。