已有业务系统
ERP、CRM、订单系统、监控告警、日报程序或内部审批工具。
不依赖 WorkBuddy、Codex 或其他桌面 Agent。ERP、CRM、监控告警、报表程序和内部工具,只需生成 UTF-8 Payload JSON,再调用用户电脑上已安装的微信本地通知助手。
第三方系统负责产生消息和附件,微信本地通知助手只负责在用户当前 Windows 桌面会话中执行预览或发送。
ERP、CRM、订单系统、监控告警、日报程序或内部审批工具。
写入联系人、正文、附件路径、send 和 operation_id。
使用子进程校验或执行 Payload,并读取退出码和 Result JSON。
用户确认后,由当前已登录的 Windows 微信完成触达。
先生成 Payload,再校验、预览并读取 Result V1。以下命令全部保持 send=false,不会操作微信。
# 1. 业务系统生成 request-001.json
{
"schema_version": "1.0",
"contacts": ["文件传输"],
"message": "订单系统:订单 A1024 已完成。",
"files_dir": null,
"recursive": false,
"max_files": 10,
"send": false,
"delay_seconds": 5,
"batch_delay_seconds": 5,
"operation_id": "order-A1024-preview"
}
# 2. 校验 Payload;不操作微信或授权额度
$exe = "$env:LOCALAPPDATA\WechatSender\wechat-sender.exe"
$payload = "D:\YourApp\requests\request-001.json"
$validateResult = "D:\YourApp\results\request-001.validate.json"
$previewResult = "D:\YourApp\results\request-001.preview.json"
New-Item -ItemType Directory -Force -Path "D:\YourApp\results" | Out-Null
& $exe --validate-payload $payload --output-json $validateResult
if ($LASTEXITCODE -ne 0) { throw "Payload validation failed" }
# 3. 执行 send=false 预览
& $exe --payload-json $payload --output-json $previewResult
$exitCode = $LASTEXITCODE
# 4. 读取 Result V1,不匹配整段中文输出
$result = Get-Content -LiteralPath $previewResult -Raw -Encoding UTF8 |
ConvertFrom-Json
$result.execution_stage
$result.deliveries
$exitCode
无需改变现有业务逻辑。只在流程末端把已经生成的收件人、正文和附件整理成 Payload。
订单完成后,ERP 生成“订单 A1024 已出库”,发送给负责销售或客户服务群。
服务器指标超过阈值后,告警系统生成摘要,先由值班人员确认,再发到运维微信群。
报表程序生成 Excel 或 PDF,Payload 的 files_dir 直接填写完整文件路径。
来自数据库、网页、邮件或模型的内容不能直接进入 send=true。调用方必须保留一个可见的确认环节。
新集成必须显式使用 schema_version="1.0";文件使用 UTF-8 编码,message 与 files_dir 至少提供一个。
{
"schema_version": "1.0",
"contacts": ["文件传输"],
"message": "日报已生成,请查收。",
"files_dir": "D:\\Reports\\daily.pdf",
"recursive": false,
"max_files": 10,
"send": false,
"delay_seconds": 5,
"batch_delay_seconds": 5,
"operation_id": "report-20260815-001"
}| 字段 | 要求 | 用途 |
|---|---|---|
| schema_version | 新集成必填,固定 1.0 | 启用 Payload V1 严格校验;无此字段的合法 RC4 Payload 进入兼容模式。 |
| contacts | 必填,string[] | 联系人或群名称;客户端每批最多处理 9 个。 |
| message | 条件必填 | 消息正文;与 files_dir 至少存在一个。 |
| files_dir | string 或 null | 单个文件完整路径,或目录路径。 |
| max_files | 可选,默认 10;范围 1–10 | 单次附件安全上限;超出范围或实际附件超限时在发送动作前失败。 |
| send | 默认 false | false 仅预览;true 才会操作微信。 |
| operation_id | 真实发送强烈要求 | 用于授权额度预留幂等,不代表微信消息只投递一次。 |
| delay_seconds | 默认 5 | 同一批相邻收件人的等待秒数。 |
| batch_delay_seconds | 默认 5 | 相邻批次之间的等待秒数。 |
普通用户可以用联系人名单文件完成简单批量调用;业务系统开发者仍应优先使用 Payload JSON。
适合人工维护名单、固定正文、临时批量预览或发送,不需要编写 JSON。
适合 Python、C#、Node.js 等程序,支持 operation_id、附件、重试控制和任务留痕。
适合一次简单调用。注意:不带 --send 时会写入微信草稿,不是纯预览。
ablink
888# 预览:不操作微信
& "$env:LOCALAPPDATA\WechatSender\wechat-sender.exe" `
--contacts-file "D:\tmp\contacts.txt" `
"明天上午8点开会。"
# 仅在用户明确确认后真实发送
& "$env:LOCALAPPDATA\WechatSender\wechat-sender.exe" `
--contacts-file "D:\tmp\contacts.txt" `
"明天上午8点开会。" `
--send调用方只依赖安装路径、Payload/Result V1、退出码和稳定错误码。不要导入内部 Python 模块,也不要直接访问授权中心。
import json, os, subprocess, uuid
from pathlib import Path
exe = Path(os.environ["LOCALAPPDATA"]) / "WechatSender" / "wechat-sender.exe"
request_dir = Path(os.environ["LOCALAPPDATA"]) / "YourApp" / "sender-requests"
result_dir = Path(os.environ["LOCALAPPDATA"]) / "YourApp" / "sender-results"
request_dir.mkdir(parents=True, exist_ok=True)
result_dir.mkdir(parents=True, exist_ok=True)
operation_id = str(uuid.uuid4())
payload = {
"schema_version": "1.0",
"contacts": ["文件传输"],
"message": "CRM:客户跟进记录已更新。",
"files_dir": None,
"recursive": False,
"max_files": 10,
"send": False,
"delay_seconds": 5,
"batch_delay_seconds": 5,
"operation_id": operation_id,
}
payload_path = request_dir / f"{operation_id}.json"
result_path = result_dir / f"{operation_id}.preview.json"
payload_path.write_text(json.dumps(payload, ensure_ascii=False), encoding="utf-8")
process = subprocess.run(
[str(exe), "--payload-json", str(payload_path),
"--output-json", str(result_path)],
shell=False, timeout=300, check=False
)
result = json.loads(result_path.read_text(encoding="utf-8"))
print(process.returncode, result["execution_stage"])
print(result["deliveries"])
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { spawnSync } from "node:child_process";
import { randomUUID } from "node:crypto";
import { join } from "node:path";
const exe = join(process.env.LOCALAPPDATA, "WechatSender", "wechat-sender.exe");
const requestDir = join(process.env.LOCALAPPDATA, "YourApp", "sender-requests");
const resultDir = join(process.env.LOCALAPPDATA, "YourApp", "sender-results");
mkdirSync(requestDir, { recursive: true });
mkdirSync(resultDir, { recursive: true });
const operationId = randomUUID();
const payloadPath = join(requestDir, `${operationId}.json`);
const resultPath = join(resultDir, `${operationId}.preview.json`);
const payload = {
schema_version: "1.0",
contacts: ["文件传输"],
message: "监控系统:API 延迟超过阈值。",
files_dir: null,
recursive: false,
max_files: 10,
send: false,
delay_seconds: 5,
batch_delay_seconds: 5,
operation_id: operationId
};
writeFileSync(payloadPath, JSON.stringify(payload, null, 2), "utf8");
const process = spawnSync(exe, [
"--payload-json", payloadPath, "--output-json", resultPath
], {
shell: false, windowsHide: true, timeout: 300000
});
const result = JSON.parse(readFileSync(resultPath, "utf8"));
console.log(process.status, result.execution_stage);
console.log(result.deliveries);
V2.1.0 RC2 通过 --output-json 原子写入顶层结果和逐联系人状态;人类可读标准输出只用于诊断。
{
"schema_version": "1.0",
"app_version": "2.1.0-rc2",
"operation_id": "order-A1024-preview",
"mode": "preview",
"status": "succeeded",
"execution_stage": "preview_completed",
"started_at": "2026-08-16T11:15:50.352+08:00",
"completed_at": "2026-08-16T11:15:50.359+08:00",
"summary": {
"total": 1,
"pending": 0,
"succeeded": 1,
"failed": 0,
"uncertain": 0
},
"deliveries": [{
"index": 1,
"contact": "文件传输",
"status": "previewed",
"execution_stage": "preview_completed",
"error_code": null,
"message": "预览完成,未操作微信。",
"started_at": null,
"completed_at": null
}],
"validation_errors": [],
"warnings": [],
"error": null
}| Delivery 状态 | 含义 | 自动重试 |
|---|---|---|
| previewed | 预览完成,没有操作微信发送。 | 不适用 |
| send_action_completed | 本地桌面发送动作完成;不是微信服务器或收件人回执。 | 不得仅凭此状态重复发送 |
| failed | 当前联系人失败;结合 error_code 和 execution_stage 判断。 | 重新确认后决定 |
| uncertain | 发送动作已开始或可能已经发生。 | 禁止 |
error.code / error.retryable常见稳定错误码包括 PAYLOAD_INVALID、ATTACHMENT_LIMIT_EXCEEDED、WECHAT_WINDOW_NOT_FOUND、SEND_PARTIAL_FAILED、SEND_RESULT_UNCERTAIN 和 TRIAL_QUOTA_EXHAUSTED。
微信自动化依赖当前用户桌面、前台窗口和已经登录的个人微信客户端。
不适合 Windows Service、Session 0、无人登录服务器或纯后台容器。
同一时间只启动一个 wechat-sender.exe,避免多个程序争夺微信窗口和剪贴板。
第三方系统不保存授权码,也不直接调用授权中心数据库或 Supabase 接口。
首次真实发送仍需用户明确确认;任何 uncertain 结果都不得自动重试。