Skip to main content

webhook-notify

通用Webhook通知工具,支持钉钉、企业微信、Slack、飞书等多种平台的webhook消息发送,以及自定义HTTP POST请求。适用于告警通知、自动化触发、系统监控等场景。

来源信息

仓库
LeoYeAI/openclaw-master-skills
最近来源活动
2026年7月20日 02:04
检测到的 SKILL.md 语言
中文
星标
2,151
分支
325

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

文件资源管理器
4 个文件

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
webhook-notify
description
通用Webhook通知工具,支持钉钉、企业微信、Slack、飞书等多种平台的webhook消息发送,以及自定义HTTP POST请求。适用于告警通知、自动化触发、系统监控等场景。
metadata
{"clawdbot":{"emoji":"🔔","requires":{"anyBins":"[Truncated]"},"os":["linux","darwin","win32"]}}
# Webhook 通知工具 一个统一的webhook发送工具,支持多种主流平台的webhook通知。 ## 支持的平台 | 平台 | 消息类型 | 支持功能 | |------|---------|---------| | **钉钉** | Text/Markdown/Link/ActionCard | @用户、@所有人、按钮交互 | | **企业微信** | Text/Markdown/Image/File/News | 图文消息、@用户 | | **飞书** | Text/Post/Interactive/ShareCard | 富文本、卡片、按钮 | | **Slack** | Text/Block/Attachment | 格式化消息、按钮 | | **自定义HTTP** | JSON/Form-Data/Raw | 完全自定义请求 | ## 快速开始 ### 1. 发送钉钉消息 ```powershell # 文本消息 $webhook = "https://oapi.dingtalk.com/robot/send?access_token=YOUR_TOKEN" Send-WebhookDingTalk -WebhookUrl $webhook -Message "【告警】系统异常" -AtAll $true # Markdown 消息 Send-WebhookDingTalk -WebhookUrl $webhook -Type markdown -Title告警" -Content "## 内容`n详情:xxx" # 包含附件的卡片消息 Send-WebhookDingTalk -WebhookUrl $webhook -Type actionCard -Title "告警详情" -Text "系统CPU使用率超过90%" -Buttons @(@{title="查看详情";url="https://example.com"}) ``` ### 2. 发送企业微信消息 ```powershell $webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY" # 文本消息 @指定用户 Send-WebhookWeCom -WebhookUrl $webhook -Message "告警信息" -AtUsers @("13800138000") # Markdown 消息 Send-WebhookWeCom -WebhookUrl $webhook -Type markdown -Content "**告警**`n系统异常,请及时处理" ``` ### 3. 发送飞书消息 ```powershell $webhook = "https://open.feishu.cn/open-apis/bot/v2/hook/YOUR_WEBHOOK" # 文本消息 Send-WebhookFeishu -WebhookUrl $webhook -Message "【openclaw】告警" # 富文本卡片 Send-WebhookFeishu -WebhookUrl $webhook -Type post -Title "系统告警" -Content @(@{tag="text";text="CPU使用率:95%"}) ``` ### 4. 发送Slack消息 ```powershell $webhook = "https://hooks.slack.com/services/YOUR/WEBHOOK/URL" # 简单文本 Send-WebhookSlack -WebhookUrl $webhook -Message "System Alert: CPU high" # 格式化消息 (Block Kit) Send-WebhookSlack -WebhookUrl $webhook -Type block -Blocks @( @{type="section";text=@{type="mrkdwn";text="*Alert*`nCPU: 95%"}} @{type="actions";elements=@(@{type="button";text=@{type="plain_text";text="View"};url="https://example.com"})} ) ``` ### 5. 自定义HTTP请求 ```powershell # 完全自定义 Send-WebhookCustom -Url "https://your-webhook.com/endpoint" ` -Method POST ` -ContentType "application/json" ` -Body @{message="custom webhook data"} ` -Headers @{"X-Custom-Header"="value"} ``` --- ## 函数参考 ### Send-WebhookDingTalk 发送钉钉webhook消息。 **参数**: - `WebhookUrl` (string): webhook地址 - `Message` (string): 文本消息内容 - `Type` (string): 消息类型 `text`|`markdown`|`actionCard`,默认 `text` - `Title` (string): 消息标题(用于markdown和actionCard) - `Content` (string): markdown内容 - `Text` (string): actionCard的文本内容 - `BtnOrientation` (string): 按钮方向 `0`横向|`1`纵向 - `Buttons` (array): 按钮列表 `@(@{title="btn1";url="url1"})` - `AtMobiles` (array): @的手机号列表 - `AtUserIds` (array): @的userId列表 - `IsAtAll` (bool): 是否@所有人 - `Keyword` (string): 添加关键字(安全限制) **示例**: ```powershell # 文本消息 @所有人 Send-WebhookDingTalk -WebhookUrl $url -Message "【openclaw】告警" -IsAtAll $true # Markdown @指定用户 Send-WebhookDingTalk -WebhookUrl $url -Type markdown -Title "告警" -Content "系统异常" -AtMobiles @("13800138000") # ActionCard带按钮 Send-WebhookDingTalk -WebhookUrl $url -Type actionCard -Title "告警" ` -Text "CPU使用率:95%" ` -Buttons @(@{title="查看详情";url="https://example.com"}, @{title="忽略";url="https://example.com/ignore"}) ``` --- ### Send-WebhookWeCom 发送企业微信webhook消息。 **参数**: - `WebhookUrl` (string): webhook地址 - `Message` (string): 文本消息内容 - `Type` (string): 消息类型 `text`|`markdown`|`image`|`news`|`file` - `Content` (string): markdown内容 - `MdId` (string): 媒体ID(用于image/file) - `Articles` (array): 图文消息列表 - `AtUsers` (array): @的手机号列表 - `IsAtAll` (bool): 是否@所有人 **示例**: ```powershell # 文本消息 Send-WebhookWeCom -WebhookUrl $url -Message "系统告警" # Markdown Send-WebhookWeCom -WebhookUrl $url -Type markdown -Content "**标题**`n内容" # 图文消息 Send-WebhookWeCom -WebhookUrl $url -Type news -Articles @( @{title="标题";description="描述";url="http://example.com";picurl="http://example.com/img.jpg"} ) ``` --- ### Send-WebhookFeishu 发送飞书webhook消息。 **参数**: - `WebhookUrl` (string): webhook地址 - `Message` (string): 文本消息内容 - `Type` (string): 消息类型 `text`|`post`|`interactive`|`shareCard` - `Title` (string): 卡片标题 - `Content` (array): 富文本内容元素 - `Elements` (array): 交互元素(按钮等) - `AtUsers` (array): @的open_id列表 **示例**: ```powershell # 文本消息 Send-WebhookFeishu -WebhookUrl $url -Message "【openclaw】告警" # 富文本卡片 Send-WebhookFeishu -WebhookUrl $url -Type post -Title "系统告警" -Content @( @{tag="text";text="CPU使用率:95%"} ) # 交互卡片 Send-WebhookFeishu -WebhookUrl $url -Type interactive -Title "确认操作" ` -Elements @(@{tag="button";text=@{tag="plain_text";content="确认"};type="primary";url="https://example.com"}) ``` --- ### Send-WebhookSlack 发送Slack webhook消息。 **参数**: - `WebhookUrl` (string): webhook地址 - `Message` (string): 文本消息内容 - `Type` (string): 消息类型 `text`|`block` - `Blocks` (array): Block Kit块 - `Attachments` (array): 附件列表 - `Channel` (string): 目标频道(覆盖默认) - `Username` (string): 发送者名称 - `IconEmoji` (string): 图标emoji - `IconUrl` (string): 图标URL **示例**: ```powershell # 简单文本 Send-WebhookSlack -WebhookUrl $url -Message "System Alert" # Block Kit Send-WebhookSlack -WebhookUrl $url -Type block -Blocks @( @{type="section";text=@{type="mrkdwn";text="*Alert*`nCPU: 95%"}}, @{type="actions";elements=@(@{type="button";text=@{type="plain_text";text="View"};url="https://example.com"})} ) ``` --- ### Send-WebhookCustom 发送自定义HTTP请求。 **参数**: - `Url` (string): 目标URL - `Method` (string): HTTP方法 `GET`|`POST`|`PUT`|`DELETE`,默认 `POST` - `Body` (object 或 string): 请求体 - `ContentType` (string): Content-Type,默认 `application/json` - `Headers` (hashtable): 请求头 - `Timeout` (int): 超时秒数,默认 30 - `UseBasicAuth` (bool): 使用基础认证 - `Username` (string): 用户名 - `Password` (string): 密码 **示例**: ```powershell # JSON POST Send-WebhookCustom -Url "https://api.example.com/webhook" ` -Body @{event="alert";severity="high"} ` -Headers @{"X-API-Key"="your-key"} # 自定义Header Send-WebhookCustom -Url "https://..." ` -Method PUT ` -Body "raw string body" ` -ContentType "text/plain" ` -Headers @{"Authorization"="Bearer token"} ``` --- ## 高级用法 ### 1. 环境变量配置 为了避免暴露敏感信息,建议将webhook URL存储在环境变量中: **PowerShell 配置**: ```powershell # 临时设置(当前会话) $env:DINGTALK_WEBHOOK = "https://oapi.dingtalk.com/robot/send?access_token=..." $env:WECOM_WEBHOOK = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=..." # 永久设置(系统环境变量) [System.Environment]::SetEnvironmentVariable('DINGTALK_WEBHOOK', 'https://...', 'User') ``` **使用环境变量**: ```powershell Send-WebhookDingTalk -WebhookUrl $env:DINGTALK_WEBHOOK -Message "告警" ``` **Linux/Mac 配置**: ```bash # ~/.bashrc 或 ~/.zshrc export DINGTALK_WEBHOOK="https://oapi.dingtalk.com/robot/send?access_token=..." export WECOM_WEBHOOK="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=..." ``` --- ### 2. 配置文件 创建配置文件 `webhook-config.ps1`: ```powershell # webhook-config.ps1 $Script:WebhookConfig = @{ DingTalk = @{ DefaultUrl = $env:DINGTALK_WEBHOOK Monitoring = @{ Url = $env:DINGTALK_MONITORING_WEBHOOK Keyword = "【openclaw】" } } WeCom = @{ DevTeam = $env:WECOM_DEV_TEAM_WEBHOOK Alert = $env:WECOM_ALERT_WEBHOOK } Slack = @{ Alerts = "https://hooks.slack.com/services/..." } } ``` **使用配置**: ```powershell . .\webhook-config.ps1 Send-WebhookDingTalk -WebhookUrl $WebhookConfig.DingTalk.Monitoring.Url -Message "告警" -Keyword $WebhookConfig.DingTalk.Monitoring.Keyword ``` --- ### 3. 模板化消息 创建消息模板 `message-templates.ps1`: ```powershell # 系统告警模板 function Get-SystemAlertMessage { param( [string]$Severity, [string]$Component, [string]$Details ) $severityIcon = switch ($Severity) { "critical" { "🚨" } "warning" { "⚠️" } "info" { "ℹ️" } default { "📌" } } return @" $severityIcon 系统告警 - 严重等级: $Severity - 组件: $Component - 详情: $Details - 时间: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss") 请及时处理! "@ } # 使用模板 $msg = Get-SystemAlertMessage -Severity "critical" -Component "CPU" -Details "使用率: 95%" Send-WebhookDingTalk -WebhookUrl $env:DINGTALK_WEBHOOK -Message $msg ``` --- ### 4. 批量发送 ```powershell # 发送到多个webhook
在 GitHub 查看
这个 SKILL.md 很大,SkillsMP 这里只预览前一段内容。 在 GitHub 查看