Scheduled Webhook Push Skill
Purpose
Provide a complete workflow for setting up scheduled content push to WeChat Work (企业微信) group webhooks. This skill handles webhook configuration, flexible schedule patterns, content formatting, and automation creation.
When to Use
- - User wants to push content to a WeChat Work group webhook on a schedule
- User mentions webhook ID/URL and a push frequency (daily, weekly, monthly, or custom)
- User wants to configure recurring automated messages to 企业微信 groups
- User provides a webhook key or full URL and wants to set up automation
Workflow
Step 1: Parse Webhook Configuration
Extract the webhook information from user input. The webhook can be provided in multiple formats:
- 1. Full URL: INLINECODE0
- Key only: INLINECODE1
- From a file: User may specify a file path containing the webhook key/URL
If provided as key only, construct the full URL:
CODEBLOCK0
To validate the webhook, run the validation script:
CODEBLOCK1
Step 2: Determine Schedule Pattern
Parse the user's desired schedule into one of the supported patterns. Refer to references/schedule_patterns.md for the full mapping of natural language to RRULE + date-guard logic.
Supported schedule types:
| Type | Examples | Implementation |
|---|
| Daily | 每天、每日、daily | RRULE: INLINECODE3 |
| Weekly |
每周一、每周五、weekly on Monday | RRULE:
FREQ=WEEKLY;BYDAY=MO;BYHOUR=10;BYMINUTE=0 |
|
Monthly (fixed date) | 每月1日、每月27号、monthly on the 15th | RRULE:
FREQ=HOURLY;INTERVAL=24 + date guard
day == N |
|
Monthly (pattern) | 每月最后一周的周一、first Monday of each month | RRULE:
FREQ=WEEKLY;BYDAY=MO;BYHOUR=10;BYMINUTE=0 + date guard |
Date guard logic for monthly patterns (used in automation prompt):
- - Fixed date (e.g. 每月27日): Add to prompt: INLINECODE8
- Last Monday of month: Add to prompt: INLINECODE9
- First Monday of month: Add to prompt: INLINECODE10
- Last week of month: Add to prompt: INLINECODE11
Step 3: Determine Push Content
Ask the user what content to push, or infer from context. Common content types:
- 1. GitHub Trending — Fetch and summarize trending AI/tech repos
- Custom message — User-provided static or template message
- Data report — Query data and format as report
- URL content — Fetch and summarize a web page
Step 4: Test the Push
Before creating the automation, perform a one-time test push to verify the webhook and content formatting.
Use the push script to send a test message:
CODEBLOCK2
Or use curl directly:
CODEBLOCK3
Verify the response is {"errcode":0,"errmsg":"ok"}.
Step 5: Create the Automation
Use the automation_update tool with the following configuration:
CODEBLOCK4
Automation prompt template:
CODEBLOCK5
Step 6: Confirm to User
After creating the automation, summarize the configuration:
- - Task name: What was created
- Schedule: Human-readable description (e.g. "每月 27 日上午 10:00")
- Webhook: Target webhook (masked key for security: show first 8 and last 4 chars)
- Content: What will be pushed
- Status: Active/Paused
Message Format Reference
WeChat Work webhook supports these message types:
Markdown (recommended for rich content)
CODEBLOCK6
Supported markdown elements:
- - Headers:
#, ##, INLINECODE16 - Bold: INLINECODE17
- Links: INLINECODE18
- Quotes: INLINECODE19
- Color: INLINECODE20
- Line breaks: INLINECODE21
Text (for simple messages)
CODEBLOCK7
Important Notes
- - WeChat Work webhook has a rate limit of 20 messages per minute per webhook
- Markdown message content has a max length of 4096 bytes
- If content exceeds the limit, split into multiple messages
- Always mask webhook keys in user-facing output for security
- The automation scheduling system only supports HOURLY and WEEKLY RRULE frequencies; for monthly schedules, use a date guard in the prompt
定时Webhook推送技能
目的
提供完整的配置流程,用于设置向企业微信群机器人定时推送内容。本技能涵盖Webhook配置、灵活的调度模式、内容格式化以及自动化创建。
使用场景
- - 用户希望按计划向企业微信群机器人推送内容
- 用户提及Webhook ID/URL和推送频率(每日、每周、每月或自定义)
- 用户希望配置向企业微信群发送定期自动消息
- 用户提供Webhook密钥或完整URL并希望设置自动化
工作流程
第一步:解析Webhook配置
从用户输入中提取Webhook信息。Webhook可以以多种格式提供:
- 1. 完整URL:https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- 仅密钥:adeee643-bc8e-4ad1-bb52-83001cd5986e
- 从文件获取:用户可指定包含Webhook密钥/URL的文件路径
如果仅提供密钥,则构建完整URL:
https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={KEY}
为验证Webhook,运行验证脚本:
bash
python3 {SKILLDIR}/scripts/validatewebhook.py urlor_key>
第二步:确定调度模式
将用户期望的调度解析为支持的某种模式。请参考references/schedule_patterns.md获取自然语言到RRULE+日期守卫逻辑的完整映射。
支持的调度类型:
| 类型 | 示例 | 实现方式 |
|---|
| 每日 | 每天、每日、daily | RRULE: FREQ=HOURLY;INTERVAL=24 |
| 每周 |
每周一、每周五、weekly on Monday | RRULE: FREQ=WEEKLY;BYDAY=MO;BYHOUR=10;BYMINUTE=0 |
|
每月(固定日期) | 每月1日、每月27号、monthly on the 15th | RRULE: FREQ=HOURLY;INTERVAL=24 + 日期守卫 day == N |
|
每月(模式) | 每月最后一周的周一、first Monday of each month | RRULE: FREQ=WEEKLY;BYDAY=MO;BYHOUR=10;BYMINUTE=0 + 日期守卫 |
每月模式的日期守卫逻辑(用于自动化提示):
- - 固定日期(例如每月27日):在提示中添加:首先检查今天的日期,如果今天不是每月的 {N} 日,则直接结束,不执行任何操作。
- 本月最后一个周一:在提示中添加:首先检查今天的日期,计算本月最后一个周一的日期(本月最后一天往前找到第一个周一),如果今天不是该日期,则直接结束。
- 本月第一个周一:在提示中添加:首先检查今天的日期,如果今天的日期不在 1-7 号之间,则直接结束。
- 本月最后一周:在提示中添加:首先检查今天的日期,如果今天的日期加 7 后仍在本月内(即不是最后一周),则直接结束。
第三步:确定推送内容
询问用户要推送的内容,或从上下文中推断。常见内容类型:
- 1. GitHub趋势 — 获取并总结热门的AI/技术仓库
- 自定义消息 — 用户提供的静态或模板消息
- 数据报告 — 查询数据并格式化为报告
- URL内容 — 获取并总结网页内容
第四步:测试推送
在创建自动化之前,执行一次性测试推送以验证Webhook和内容格式。
使用推送脚本发送测试消息:
bash
python3 {SKILLDIR}/scripts/pushto_webhook.py \
--webhook \
--format markdown \
--message
或直接使用curl:
bash
curl -s \
-H Content-Type: application/json \
-d {msgtype:markdown,markdown:{content:}}
验证响应是否为{errcode:0,errmsg:ok}。
第五步:创建自动化
使用automation_update工具,配置如下:
mode: suggested create
name: <基于内容和调度的描述性名称>
prompt: <日期守卫(如需)> + <内容生成步骤> + <通过Webhook推送>
rrule: <从第二步计算出的RRULE>
cwds: <当前工作空间>
status: ACTIVE
自动化提示模板:
{DATEGUARDIF_NEEDED}
执行以下步骤:
- 1. {CONTENTGENERATIONSTEPS}
- 2. 将整理好的内容通过企业微信群机器人 Webhook 推送,Webhook 地址为:{WEBHOOK_URL}
- 3. 推送格式使用 {FORMAT},确保内容格式正确、可读性好。
第六步:向用户确认
创建自动化后,总结配置信息:
- - 任务名称:创建的内容
- 调度:人类可读的描述(例如每月 27 日上午 10:00)
- Webhook:目标Webhook(为安全起见,密钥部分隐藏:显示前8位和后4位字符)
- 内容:将要推送的内容
- 状态:激活/暂停
消息格式参考
企业微信Webhook支持以下消息类型:
Markdown(推荐用于富文本内容)
json
{
msgtype: markdown,
markdown: {
content: # 标题\n> 引用\n
粗体 警告
}
}
支持的Markdown元素:
- - 标题:#、##、###
- 粗体:文本
- 链接:文本
- 引用:> 文本
- 颜色:文本
- 换行:\n
文本(用于简单消息)
json
{
msgtype: text,
text: {
content: 消息内容,
mentioned_list: [@all]
}
}
重要说明
- - 企业微信Webhook每个机器人每分钟限速20条消息
- Markdown消息内容最大长度为4096字节
- 如果内容超出限制,请拆分为多条消息
- 为安全起见,始终在面向用户的输出中隐藏Webhook密钥
- 自动化调度系统仅支持HOURLY和WEEKLY的RRULE频率;对于月度调度,请在提示中使用日期守卫