bot-messenger
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "bot-messenger" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-80794ff065d3ea5fba45bfbaa87433eb1ff17be1107529f5ab968633334849e5. Verify the upstream source and version against https://skillhub.cn/skills/user_b22a52ba/bot-messenger before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
A robot messaging skill for DingTalk, Lark (Feishu), and WeCom (Enterprise WeChat), used to send robot messages to these platforms.
Introduction source: third_party · user_b22a52ba · 2.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Translation pending; see source documentation.
- Limits and differences
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: bot-messenger
description: 钉钉、飞书与企业微信机器人消息推送技能。通过自定义机器人 Webhook 地址向群聊发送文本、Markdown、卡片等消息,支持加签安全校验、@指定成员、多平台同时推送。触发关键词:钉钉消息、飞书消息、企业微信消息、发消息到钉钉、发消息到飞书、发消息到企业微信、推送消息、机器人推送、钉钉机器人、飞书机器人、企业微信机器人、webhook推送、群消息、bot
message、dingtalk、feishu、lark、wecom。
source: user
version: 2.0.0
tags:
- bot
- dingtalk
- feishu
- wechat
- wecom
slug: bot-messenger
displayName: Bot Messenger
summary: 钉钉、飞书与企业微信机器人消息推送技能Bot Messenger - 钉钉 & 飞书 & 企业微信机器人消息推送技能
技能概述
通过钉钉、飞书和企业微信的自定义机器人 Webhook 地址,向群聊发送各类消息(文本、Markdown、图片卡片等)。支持加签安全校验、@指定成员、多平台同时推送。
触发关键词
钉钉消息、飞书消息、企业微信消息、发消息到钉钉、发消息到飞书、发消息到企业微信、推送消息、机器人推送、钉钉机器人、飞书机器人、企业微信机器人、webhook推送、群消息、bot message、dingtalk message、feishu message、lark message、企业微信消息、wecom message。
使用前提
钉钉机器人配置
- 打开钉钉群聊 → 右上角「...」→「群设置」→「智能群助手」→「添加机器人」
- 选择「自定义机器人」,设置名称和描述
- 安全设置建议选择「加签」,记录 Webhook 地址和 加签密钥 (Secret)
- Webhook 格式:
https://oapi.dingtalk.com/robot/send?access_token=xxxxxx
飞书机器人配置
- 打开飞书群聊 → 右上角「...」→「设置」→「群机器人」→「添加机器人」
- 选择「自定义机器人」
- 安全设置建议选择「签名校验」,记录 Webhook 地址和 签名密钥 (Secret)
- Webhook 格式:
https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxx
企业微信机器人配置
- 打开企业微信群聊 → 右上角「...」→「消息推送」(原群机器人)→「添加」
- 设置名称,安全设置建议选择「加签」,记录 Webhook 地址和 加签密钥 (Secret)
- Webhook 格式:
https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxx - 注:企业微信 v4.1.41 版本后「群机器人」功能更名为「消息推送」
执行流程
Step 1: 确认配置信息
首次使用时,通过 ask_user_question 向用户确认以下信息:
- 推送平台(钉钉 / 飞书 / 企业微信 / 多选)
- Webhook 地址
- 加签密钥(如有)
- 消息类型(文本 / Markdown)
- 消息内容
- 是否需要 @指定成员(手机号或 userId)
安全提醒:Webhook 地址和加签密钥属于访问凭证,不要写入用户记忆,仅在当前会话中使用。如果用户希望长期保存配置以便复用,引导用户使用环境变量或配置文件方式。
Step 2: 读取配置
用户首次配置后,可将配置保存到工作区 bot_config.json 中,后续调用时自动读取。配置文件格式:
{
"dingtalk": {
"webhook": "https://oapi.dingtalk.com/robot/send?access_token=xxxxxx",
"secret": "SECxxxxxx"
},
"feishu": {
"webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxx",
"secret": "xxxxxx"
},
"wecom": {
"webhook": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxx",
"secret": "SECxxxxxx(可选)"
}
}
Step 3: 构造并发送消息
使用 Python requests 库构造请求,根据平台差异处理签名逻辑。
代码模板
通用发送函数
import requests
import time
import hmac
import hashlib
import base64
import urllib.parse
# ============ 钉钉发送 ============
def dingtalk_sign(secret: str) -> tuple:
"""钉钉加签:生成 timestamp 和 sign"""
timestamp = str(round(time.time() * 1000))
string_to_sign = f"{timestamp}\n{secret}"
hmac_code = hmac.new(
secret.encode("utf-8"),
string_to_sign.encode("utf-8"),
digestmod=hashlib.sha256
).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
return timestamp, sign
def send_dingtalk(webhook: str, secret: str = None, msg_type: str = "text",
content: str = "", title: str = "", at_mobiles: list = None,
at_user_ids: list = None, is_at_all: bool = False):
"""发送钉钉机器人消息"""
url = webhook
if secret:
timestamp, sign = dingtalk_sign(secret)
url = f"{webhook}×tamp={timestamp}&sign={sign}"
at_config = {"isAtAll": is_at_all}
if at_mobiles:
at_config["atMobiles"] = at_mobiles
if at_user_ids:
at_config["atUserIds"] = at_user_ids
if msg_type == "markdown":
payload = {
"msgtype": "markdown",
"markdown": {"title": title, "text": content},
"at": at_config
}
else:
payload = {
"msgtype": "text",
"text": {"content": content},
"at": at_config
}
resp = requests.post(url, json=payload, timeout=10)
result = resp.json()
if result.get("errcode") == 0:
print("钉钉消息发送成功")
else:
print(f"钉钉消息发送失败: {result}")
return result
# ============ 飞书发送 ============
def feishu_sign(timestamp: str, secret: str) -> str:
"""飞书签名校验(按飞书官方 Python 示例实现)
注意:string_to_sign 作为 hmac.new 的 key,空 digest"""
string_to_sign = f"{timestamp}\n{secret}"
hmac_code = hmac.new(
string_to_sign.encode("utf-8"),
digestmod=hashlib.sha256
).digest()
sign = base64.b64encode(hmac_code).decode("utf-8")
return sign
def send_feishu(webhook: str, secret: str = None, msg_type: str = "text",
content: str = "", title: str = ""):
"""发送飞书机器人消息"""
timestamp = str(int(time.time()))
body = {}
if secret:
sign = feishu_sign(timestamp, secret)
body["timestamp"] = timestamp
body["sign"] = sign
if msg_type == "interactive":
body["msg_type"] = "interactive"
body["card"] = {
"header": {
"title": {"tag": "plain_text", "content": title or "通知"},
"template": "blue"
},
"elements": [
{"tag": "markdown", "content": content}
]
}
elif msg_type == "post":
body["msg_type"] = "post"
body["content"] = {
"post": {
"zh_cn": {
"title": title or "",
"content": [[{"tag": "text", "text": content}]]
}
}
}
else:
body["msg_type"] = "text"
body["content"] = {"text": content}
resp = requests.post(webhook, json=body, timeout=10)
result = resp.json()
if result.get("code") == 0 or result.get("StatusCode") == 0:
print("飞书消息发送成功")
else:
print(f"飞书消息发送失败: {result}")
return result
# ============ 企业微信发送 ============
def send_wecom(webhook: str, secret: str = None, msg_type: str = "text",
content: str = "", mentioned_list: list = None,
mentioned_mobile_list: list = None):
"""发送企业微信机器人消息(加签方式与钉钉一致)"""
url = webhook
if secret:
timestamp, sign = dingtalk_sign(secret) # 企业微信加签与钉钉完全一致
url = f"{webhook}×tamp={timestamp}&sign={sign}"
mentioned = {}
if mentioned_list:
mentioned["mentioned_list"] = mentioned_list
if mentioned_mobile_list:
mentioned["mentioned_mobile_list"] = mentioned_mobile_list
if msg_type == "markdown":
payload = {
"msgtype": "markdown",
"markdown": {"content": content},
**mentioned
}
else:
payload = {
"msgtype": "text",
"text": {"content": content},
**mentioned
}
resp = requests.post(url, json=payload, timeout=10)
result = resp.json()
if result.get("errcode") == 0:
print("企业微信消息发送成功")
else:
print(f"企业微信消息发送失败: {result}")
return result
# ============ 便捷函数 ============
def send_to_all(platforms: list, config: dict, content: str, **kwargs):
"""向多个平台同时推送消息"""
results = {}
for platform in platforms:
cfg = config.get(platform, {})
webhook = cfg.get("webhook")
secret = cfg.get("secret")
if not webhook:
print(f"{platform}: 未配置 webhook,跳过")
continue
if platform == "dingtalk":
results[platform] = send_dingtalk(webhook, secret, content=content, **kwargs)
elif platform == "feishu":
results[platform] = send_feishu(webhook, secret, content=content, **kwargs)
elif platform == "wecom":
results[platform] = send_wecom(webhook, secret, content=content, **kwargs)
return results
消息类型说明
| 平台 | 文本 | Markdown | 富文本 | 卡片消息 | @成员 |
|---|---|---|---|---|---|
| 钉钉 | text | markdown | - | ActionCard | 支持 |
| 飞书 | text | - | post | interactive | 不支持(自定义机器人) |
| 企业微信 | text | markdown | - | news/image/file | 支持 |
注意事项
- 频率限制:钉钉每分钟最多 20 条;飞书每分钟最多 60 条;企业微信每分钟最多 20 条
- 内容长度:钉钉 Markdown 不超过 20000 字;飞书消息不超过 30KB;企业微信 Markdown 不超过 4096 字节
- 安全:务必使用加签或 IP 白名单保护 Webhook 地址
- @功能:飞书自定义机器人不支持 @指定成员;钉钉和企业微信均支持
- 配置文件:
bot_config.json包含访问凭证,建议添加到.gitignore中
典型使用场景
- 定时推送日报/周报到工作群
- 系统监控告警通知
- 任务完成提醒
- 数据报告自动推送
- 会议提醒
- 天气/新闻摘要推送
错误处理
| 错误码 | 含义 | 处理方式 |
|---|---|---|
| 钉钉 errcode=31004 | 关键字不匹配 | 检查消息内容是否包含群设置的关键字 |
| 飞书 code=19021 | 签名校验失败 | 检查 secret 是否正确,注意签名算法中 string_to_sign 是 hmac key |
| 企业微信 errcode=301002 | 签名校验失败 | 检查加签密钥是否正确 |
| HTTP 403 | IP 不在白名单 | 将服务器 IP 加入白名单或改用加签方式 |
| HTTP 429 | 发送频率超限 | 降低发送频率,加入间隔 |
Current listing version
2.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决企业办公高频刚需场景,支持钉钉、飞书、企业微信三大平台机器人消息推送
- 提供完整的配置指南和代码模板,显著提升自动化消息推送效率
Highlights
- 触发词覆盖全面,包含平台名称、功能描述、技术关键词等多种变体
- 边界清晰,无明显误触或漏触风险
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
文档中已有典型使用场景章节,但未明确标注为 When to Use
Recommendation: 建议将典型使用场景章节标题改为 When to Use,以符合标准文档结构
Highlights
- 执行流程分步骤清晰,包含配置确认、读取配置、构造发送三个明确阶段
- 提供完整的端到端代码示例和配置文件格式说明
Highlights
- 使用标准库实现,工具来源明确,参数符合各平台官方 API 规范
- 覆盖主要异常场景并提供错误码处理建议,包含安全提醒机制
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 31, 32, 37, 42, 52
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- oapi.dingtalk.com
- open.feishu.cn
- qyapi.weixin.qq.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.