fanchou/webhook-push

No description

1 stars0 forksUpdated Jan 6, 2026
npx skills add fanchou/webhook-push

README

Webhook Push Skill

License: MIT Python 3.9+

Unified webhook messaging skill for WeCom (企业微信), DingTalk (钉钉), and Feishu (飞书) platforms.

Overview

This skill provides a unified interface for sending webhook notifications to three major Chinese enterprise communication platforms:

  • WeCom (企业微信) - Enterprise WeChat
  • DingTalk (钉钉) - Alibaba's enterprise communication platform
  • Feishu (飞书) - ByteDance's collaboration platform

Features

  • Unified Message Model - Send messages using a single, platform-agnostic interface
  • Multi-platform Support - WeCom, DingTalk, and Feishu
  • Rich Message Types - Text, Markdown, Image, Link, Card, File, Feed
  • Automatic Conversion - Messages are automatically converted to platform-specific formats
  • Graceful Degradation - Unsupported features are automatically downgraded
  • Retry Mechanism - Built-in exponential backoff retry logic
  • Rate Limiting - Platform-specific rate limit handling

Installation

pip install webhook-push

Quick Start

from webhook_push import MessageSender, UnifiedMessage

# Create a text message
message = UnifiedMessage(
    content={
        "type": "text",
        "body": {"text": "Hello from webhook-push!"}
    }
)

# Send to a specific platform
sender = MessageSender()
result = await sender.send(message, "dingtalk", webhook_url="https://oapi.dingtalk.com/robot/send?access_token=xxx")
print(result)

Documentation

See the following documents for detailed information:

Usage Examples

Text Message

from webhook_push import MessageSender, UnifiedMessage

message = UnifiedMessage(
    metadata={"message_id": "msg_001"},
    content={
        "type": "text",
        "title": "Notification",
        "body": {"text": "This is a test message"},
        "mentions": [{"type": "mobile", "value": "13800000000"}]
    }
)

Markdown Message

message = UnifiedMessage(
    content={
        "type": "markdown",
        "title": "Daily Report",
        "body": {
            "content": """# Daily Report

## Metrics
- **New Users**: 128
- **Active Users**: 3,421

> Last updated: 18:00"""
        }
    }
)

Card Message

message = UnifiedMessage(
    content={
        "type": "card",
        "body": {
            "card_type": "interactive",
            "config": {"wide_screen_mode": True},
            "elements": [
                {"type": "div", "text": "**Alert**: High CPU usage"}
            ],
            "actions": [
                {
                    "type": "button",
                    "text": "View Details",
                    "url": "https://example.com/alerts",
                    "style": "primary"
                }
            ]
        }
    }
)

WeCom Template Card (text_notice)

from webhook_push import UnifiedMessage, MessageContent

message = UnifiedMessage(
    content=MessageContent(
        type="card",
        body={
            "card_type": "text_notice",
            "title": "系统告警",
            "description": "CPU使用率超过阈值",
            "emphasis": {
                "title": "95%",
                "desc": "当前CPU使用率"
            },
            "horizontal_content_list": [
                {"keyname": "服务器", "value": "web-01"},
                {"keyname": "阈值", "value": "80%"}
            ],
            "jump_list": [
                {"type": 1, "url": "https://example.com/alerts", "title": "查看详情"}
            ],
            "action": {"type": 1, "url": "https://example.com/alerts"}
        }
    )
)

result = await sender.send(message, "wecom")

WeCom News (Article Card)

message = UnifiedMessage(
    content={
        "type": "news",
        "body": {
            "links": [
                {
                    "title": "技术分享: Webhook 最佳实践",
                    "description": "了解如何设计可靠的 webhook 系统",
                    "url": "https://example.com/article",
                    "image_url": "https://example.com/cover.jpg"
                }
            ]
        }
    }
)

result = await sender.send(message, "wecom")

DingTalk Action Card (single button)

message = UnifiedMessage(
    content=MessageContent(
        type="card",
        body={
            "card_type": "single",
            "config": {"hide_avatar": "0"},
            "title": "审批请求",
            "elements": [{"type": "div", "text": "您有一个新的审批请求待处理"}],
            "actions": [
                {"text": "立即审批", "url": "https://example.com/appro

...
Read full README

Publisher

fanchoufanchou

Statistics

Stars1
Forks0
Open Issues0
LicenseMIT License
CreatedJan 5, 2026