xuliang2024/wechat-notify-agent
DevOps & Self-hostingSelf-hosted servicesSelf-hosted gateway that turns one HTTP request into a WeCom or personal WeChat push notification.
What it does
WeCom Notify is a self-hosted push gateway that accepts one HTTP request and delivers the message to personal WeChat through an enterprise WeChat (WeCom) self-built app or a group robot webhook. It targets AI coding agents (Claude Code, Cursor, Codex), CI/CD pipelines, training scripts, cron jobs and alerting hooks that need a reliable "task finished" ping without relying on a paid third-party relay like Server酱 or PushPlus.
The service is a Starlette API plus PostgreSQL. Requests are authenticated with a wk_live_ API key, queued in PostgreSQL using SKIP LOCKED, and drained by a sending worker that serializes access_token refreshes and retries with backoff. Message state moves through queued, sending, sent, partial, failed and dead, and errors come back as a structured {code, message, detail, fix} contract so an agent can report the cause. Secrets are stored encrypted with AES-256-GCM; API keys are kept only as hashes.
Quick start
Prerequisites: Docker and Docker Compose.
git clone https://github.com/xuliang2024/wechat-notify-agent.git
cd wechat-notify-agent
cp .env.example .env
MASTER_KEY=$(python3 -c 'import os; print(os.urandom(32).hex())')
DB_PASS=$(python3 -c 'import secrets; print(secrets.token_urlsafe(18))')
sed -i.bak -e "s/^WECOM_MASTER_KEY=$/WECOM_MASTER_KEY=${MASTER_KEY}/" -e "s/^POSTGRES_PASSWORD=change_me_strong_password$/POSTGRES_PASSWORD=${DB_PASS}/" .env && rm -f .env.bak
docker compose up -d
curl -s http://127.0.0.1:8000/healthz
The health check returns {"ok":true,"service":"wecom-notify",...}. Open http://127.0.0.1:8000 and follow the built-in wizard to register a console account, add a channel and send a test message. To deliver to personal WeChat, create a WeCom team with a self-built app, record the corpid, AgentId and Secret, add the server's public egress IP to the app's trusted IP list, and scan the WeChat plugin QR code from the admin console.
Once a channel is verified, the console issues a wk_live_ key and shows the four environment values (WECOM_NOTIFY_URL, WECOM_NOTIFY_KEY, WECOM_NOTIFY_CHANNEL and a verify command) that can be pasted to an agent. A direct send looks like:
curl -X POST "$WECOM_NOTIFY_URL/v1/messages" \
-H "Authorization: Bearer $WECOM_NOTIFY_KEY" \
-H "Idempotency-Key: deploy-20261130-01" \
-H "Content-Type: application/json" \
-d '{"to":["alice"],"content":"order-service: 已部署到 prod"}'
Clients that want to wait for the final state can pass "async": false; the call then blocks up to 10 seconds and returns sent, partial, failed or dead. See the API reference for parameters, limits and status queries, or the AI agent integration section for a Claude Code Stop hook and Python examples.
Constraints
- Python 3.11+ and PostgreSQL 16 are required for local development; Docker Compose bundles both for the self-hosted path. There is no Redis or external message queue.
- The self-built app channel requires the calling server's public egress IP to be whitelisted in the WeCom admin console as a trusted IP, otherwise creation and sending fail with
IP_NOT_TRUSTED(errcode 60020). A group robot webhook channel avoids the IP whitelist. - Message content is plain text capped at 2048 UTF-8 bytes; longer input is rejected with
400 CONTENT_TOO_LONGrather than truncated. WECOM_MASTER_KEYmust be set and kept stable; rotating it requires theWECOM_MASTER_KEYSdual-key format and re-verifying existing channels, or old ciphertext cannot be decrypted.- For production, put HTTPS in front (Caddy or Nginx), set
PUBLIC_BASE_URLandCOOKIE_SECURE=1, and disable public signup withALLOW_REGISTRATION=0. - WeChat popups require the personal WeChat account to follow the WeChat plugin QR code; if the WeCom app is also installed, turn off "receive messages only in WeCom".
- Licensed under MIT.
HotRepo's take
The project entered HotRepo's new-project list on 2026-12-02, gaining 13 stars over roughly 1.5 hours of observation and reaching 114 stars and 26 forks. That is a short window, so it shows early attention rather than sustained adoption. The implementation choices fit the stated workload: PostgreSQL SKIP LOCKED instead of Redis, an idempotency key with replay handling, per-recipient rate limiting at 20 messages per minute, and a serialized token refresh all address known failure modes of WeCom push scripts. Whether the operator needs those guarantees depends on whether notifications are best-effort or part of a production alert path; for the latter, the self-hosted path and trusted-IP requirement are the main deployment friction.
Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.
You might also like
- novuhq/novuOpen-source notification and agent communication infrastructure that routes messages to inbox, email, SMS, push, chat, Slack and Teams through one API.
- traccar/traccarSelf-hosted GPS tracking server for fleets, assets or personal trackers, connecting 200+ device protocols to one dashboard and API.
- IceWhaleTech/CasaOSTurn a home server into a personal cloud with a web UI for installing Docker apps, managing files and drives.
- TouchWorkStation/omarchy-serverTurns an Omarchy Arch machine into a browser-managed home server for self-hosted apps, files, VMs and remote desktop.
- serveroshq/panelA self-hosted web panel for deploying, monitoring and backing up Linux servers you already own.