Skip to content

Repository files navigation

简体中文 | English

📡 webhook-worker

A generic notification relay for devices without public network access — receive alerts via Telegram, DingTalk, Feishu, Bark, ServerChan, PushPlus. Powered by Cloudflare Workers, zero cost, zero server.

Cloudflare Workers Zero Server Zero Cost


✨ Features

  • 🚀 One-click deploy — Fork → fill Secrets → auto-deploy, 5 minutes and you're done
  • 🔒 Secure verification — Secret embedded in URL prevents forged requests
  • 📡 Multi-channel push — Supports the following platforms; configure only what you need
Channel Environment Variables Notes
Telegram TELEGRAM_BOT_TOKEN + TELEGRAM_CHAT_ID HTML formatting supported
DingTalk DINGTALK_WEBHOOK Optional signing secret: DINGTALK_SECRET
Feishu (Lark) FEISHU_WEBHOOK Webhook URL
Bark BARK_KEY iOS push. Optional custom server: BARK_URL
ServerChan SERVERCHAN_KEY WeChat push
PushPlus PUSHPLUS_TOKEN WeChat push
  • 💸 Completely free — Cloudflare Workers free tier offers 100K requests/day, plenty for personal use
  • 🌍 Global edge network — Low latency via Cloudflare CDN
  • 🔌 Generic input — Works with any device or script that can make an HTTP request (GET, POST, JSON, FormData)
  • 📝 Flexible message — Pass a message or content field for custom text, or let the worker auto-format all fields as key: value pairs
  • 🏷️ Custom title — Set a title field (defaults to "Webhook 通知")

📖 Beginner's Guide

From scratch, step by step. All you need:

  • A GitHub account
  • A Cloudflare account (free)
  • A device or script that can send HTTP requests

Step 1: Fork this repository

  1. Click the Fork button at the top right of this repository
  2. Confirm the fork is created under your account

Step 2: Get your Cloudflare API Token

  1. Log into Cloudflare Dashboard
  2. Click your avatar → My ProfileAPI Tokens
  3. Click Create Token
  4. Select the Edit Cloudflare Workers template
  5. Under Account Resources, select your account
  6. Click Continue to summaryCreate Token
  7. ⚠️ Copy the token immediately — it's only shown once!

Step 3: Get your Cloudflare Account ID

  1. On the Cloudflare Dashboard homepage
  2. Find Account ID in the right sidebar and copy it

Step 4: Set GitHub Secrets

  1. Go to your forked repository
  2. SettingsSecrets and variablesActions
  3. Click New repository secret and add each one:

Required:

Name Value Where to get it
CLOUDFLARE_API_TOKEN The token from Step 2 Cloudflare API Tokens
CLOUDFLARE_ACCOUNT_ID The ID from Step 3 Cloudflare Dashboard
WEBHOOK_SECRET A custom secret, e.g. mySecret123 Make one up and remember it

Notification channels (configure at least one):

Using Telegram as an example:

Name Value Where to get it
TELEGRAM_BOT_TOKEN e.g. 123456:ABC-DEF... Create a Bot via @BotFather on Telegram
TELEGRAM_CHAT_ID e.g. -1001234567890 Get it from @userinfobot on Telegram

Other channels:

Name Description
DINGTALK_WEBHOOK DingTalk group robot webhook URL
DINGTALK_SECRET DingTalk robot signing secret (optional)
FEISHU_WEBHOOK Feishu (Lark) group robot webhook URL
BARK_KEY Bark app push key
BARK_URL Custom Bark server URL (optional, default https://api.day.app)
SERVERCHAN_KEY ServerChan SendKey
PUSHPLUS_TOKEN PushPlus Token

💡 Tip: Only configure the channels you want to use. For example, if you only use Telegram, just fill in TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID.

Step 5: Auto-deploy

Once your Secrets are set, any push to main triggers automatic deployment. You can:

  • Option 1: Make a small change (e.g., add a space) and push to main
  • Option 2: Go to ActionsDeploy to Cloudflare WorkersRun workflow

Wait for the Action to complete (usually 1-2 minutes).

Step 6: Get your Worker domain

  1. Log into Cloudflare Dashboard
  2. Click Workers & Pages on the left
  3. Click webhook-worker — you'll see the domain, e.g. webhook-worker.<your-subdomain>.workers.dev
  4. Note this domain

Step 7: Send a notification

Make a POST or GET request to:

https://webhook-worker.<your-subdomain>.workers.dev/<YOUR_WEBHOOK_SECRET>/notify

Example — POST JSON (recommended):

curl -X POST 'https://webhook-worker.<your-subdomain>.workers.dev/mySecret123/notify' \
  -H 'Content-Type: application/json' \
  -d '{
    "title": "Server Alert",
    "message": "CPU temperature too high!"
  }'

Example — GET (for simple scripts):

curl 'https://webhook-worker.<your-subdomain>.workers.dev/mySecret123/notify?title=Disk+Warning&message=/dev/sda1+is+95%25+full'

Example — auto-format (no message field, just pass data):

curl -X POST 'https://webhook-worker.<your-subdomain>.workers.dev/mySecret123/notify' \
  -H 'Content-Type: application/json' \
  -d '{
    "device": "raspberry-pi-4",
    "event": "high_temperature",
    "temperature": 82,
    "threshold": 75
  }'

This will produce a notification with fields formatted as:

device: raspberry-pi-4
event: high_temperature
temperature: 82
threshold: 75

Step 8: Test

curl 'https://webhook-worker.<your-subdomain>.workers.dev/mySecret123/notify?title=Test&message=Hello+from+webhook-worker'

If you received a message on your configured channels, congratulations — you're all set! 🎉

📝 Request Format

Field Type Required Description
title string No Notification title (default: "Webhook 通知")
message string No Custom message body, used as-is
content string No Alias for message
Any other fields varies No Auto-formatted as key: value pairs

Supported request methods:

  • POST with Content-Type: application/json
  • POST with Content-Type: application/x-www-form-urlencoded (FormData)
  • GET with query parameters

mikufans 录播姬 Webhook v2 配置

在 mikufans 录播姬中建议使用 Webhook v2,不建议使用 v1。Webhook v2 会发送包含 EventTypeEventData 的 JSON,当前 Worker 会自动识别这种格式。

Webhook v2 地址填写:

https://你的-worker域名/你的WEBHOOK_SECRET/notify

当前 Worker 默认只推送 StreamStarted 开播事件,并格式化为适合 Telegram 阅读的直播通知。

StreamEndedRecordingStartedRecordingFinishedFileOpeningFileClosed 等其他事件会被忽略并返回 HTTP 200,避免录播姬因为未收到成功响应而重试。

如果想推送下播事件,可以在代码里把 StreamEnded 加入 BILILIVE_RECORDER_ALLOWED_EVENT_TYPES 允许列表,并补充对应的格式化逻辑。

🔧 Channel Setup Guides

Telegram (Recommended)
  1. Search for @BotFather on Telegram, send /newbot
  2. Give your bot a name, and you'll receive a Bot Token (format: 123456:ABC-DEF...)
  3. Create a group or find your private chat, add the bot
  4. Send a message to the bot (otherwise it can't initiate messages)
  5. Visit https://api.telegram.org/bot<TOKEN>/getUpdates to get the chat_id
  6. Add TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID to GitHub Secrets
DingTalk
  1. DingTalk desktop → Group settings → Smart group assistant → Add robot → Custom
  2. Select Sign for security, copy the signing secret
  3. Copy the Webhook URL
  4. Add DINGTALK_WEBHOOK and DINGTALK_SECRET to GitHub Secrets
Feishu (Lark)
  1. Feishu desktop → Group settings → Add robot → Custom robot
  2. Select Custom keywords for security, enter a keyword (or leave empty for webhook-only mode)
  3. Copy the Webhook URL
  4. Add FEISHU_WEBHOOK to GitHub Secrets
Bark (iOS)
  1. Download Bark from App Store
  2. Open the app, copy the push key (the string after the registration code)
  3. Add BARK_KEY to GitHub Secrets
  4. If using a self-hosted server, also add BARK_URL
ServerChan (WeChat Push)
  1. Visit ServerChan, log in with WeChat
  2. Copy your SendKey
  3. Add SERVERCHAN_KEY to GitHub Secrets
PushPlus (WeChat Push)
  1. Visit PushPlus, log in with WeChat
  2. Copy your Token
  3. Add PUSHPLUS_TOKEN to GitHub Secrets

🏗️ How It Works

┌──────────────┐   POST/GET https://worker/<secret>/notify    ┌──────────────────┐
│ Your device   │ ──────────────────────────────────────────►  │ Cloudflare Worker │
│ (no public    │                                              └────────┬─────────┘
│  IP / sensor  │                                                       │
│  / script)    │                                                 ┌─────┼─────┐
└──────────────┘                                                │     │     │
                                                           ┌────▼────┐┌────▼────┐ │
                                                           │Telegram ││DingTalk │ │
                                                           └─────────┘└─────────┘ │
                                                              │    │             │
                                                           ┌──▼────▼──┐  ┌──────▼───┐
                                                           │Bark/etc  │  │ PushPlus │
                                                           └──────────┘  └──────────┘
  1. Your device or script sends an HTTP request to the Worker with your custom data
  2. Worker verifies the secret in the URL
  3. Worker formats the notification (or uses your message field directly)
  4. Worker pushes to all configured notification channels in parallel
  5. Returns the aggregated result from all channels

🛠️ Local Development

# Clone the repository
git clone https://github.com/chius-me/webhook-worker.git
cd webhook-worker

# Install dependencies
npm install

# Local development (requires .dev.vars for environment variables)
npm run dev

# Manual deploy
npm run deploy

Create a .dev.vars file in the project root:

WEBHOOK_SECRET=mysecret123
TELEGRAM_BOT_TOKEN=123456:ABC-DEF
TELEGRAM_CHAT_ID=-1001234567890

🔑 Setting Cloudflare Secrets Manually

If you're not using GitHub Actions, set secrets directly with wrangler:

npx wrangler secret put WEBHOOK_SECRET
npx wrangler secret put TELEGRAM_BOT_TOKEN
npx wrangler secret put TELEGRAM_CHAT_ID
# Add other channels as needed

❓ FAQ

Worker responds "webhook-worker is running" but no notifications?

Check the following:

  1. Are your notification channel tokens/keys correct?
  2. Does your request URL contain the correct WEBHOOK_SECRET?
  3. Check the response body for details on each channel's result
How to view Worker logs?

Cloudflare Dashboard → Workers & Pages → webhook-worker → Logs (real-time)

Is the Cloudflare Workers free tier enough?

The free tier offers 100K requests/day. Even with frequent notifications, it's more than enough for personal use.

Can I push to multiple channels at the same time?

Yes! As long as you configure the environment variables for each channel, the Worker will push to all configured channels in parallel.

Backwards compatible with ddns-go?

Yes! ddns-go's original IP change data (ipv4Addr, ipv4Result, etc.) will still work — they're just auto-formatted as key-value pairs instead of having a custom template. The notification will still contain all the information.

📄 License

GNU General Public License v3.0

About

A generic notification relay for devices without public network access

Resources

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages