配置指南
微信公众号配置
Section titled “微信公众号配置”1. 获取配置信息
Section titled “1. 获取配置信息”在微信公众平台后台获取:
- AppID
- AppSecret
- Token(服务器配置中的 Token)
- EncodingAESKey(可选,用于消息加密)
2. 创建 ConnectorBind
Section titled “2. 创建 ConnectorBind”通过 API 或 Dashboard 创建微信公众号 ConnectorBind:
curl -X POST "https://api.messagerouter.dev/v1/connector-binds" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <API_KEY>" \ -d '{ "type": "wechat_mp", "name": "我的公众号", "category": "Platform", "enabled": true, "config": { "app_id": "wx1234567890", "app_secret": "your_app_secret", "token": "your_token", "encoding_aes_key": "your_aes_key" } }'响应中的 data.bind_id 是该渠道实例的 ID,后续 webhook URL 与回复接口都会使用它。
3. 配置服务器地址
Section titled “3. 配置服务器地址”在微信公众平台“开发 > 基本配置”中设置:
- 服务器地址(URL):
https://api.messagerouter.dev/connectors/<bind_id>/webhook - Token: 与上一步配置的
token一致 - EncodingAESKey: 与上一步配置的
encoding_aes_key一致 - 消息加解密方式: 推荐“安全模式”
点击“提交”后,微信会发送验证请求,系统自动响应验证。
4. 测试接入
Section titled “4. 测试接入”向公众号发送消息,检查:
- 消息是否成功入库(通过
GET /v1/events或 Dashboard「收件箱」查询) - 路由规则是否正确匹配
- Actions 是否正常执行(在 Dashboard「执行日志」查看)
API Key 管理
Section titled “API Key 管理”创建 API Key
Section titled “创建 API Key”在 Dashboard 的「设置」页面创建新的 API Key:
- 在「API Keys」区域输入 Key 名称
- 点击「创建 Key」
- 复制生成的 Key(明文只显示一次)
- 在请求中使用:
Authorization: Bearer <api_key>
- 不要将 API Key 提交到版本控制
- 定期轮换 API Key
- 为不同用途创建不同的 Key
- 及时吊销并删除不再使用的 Key
Dashboard 登录
Section titled “Dashboard 登录”Dashboard 支持 Google、邮箱验证码和邮箱 + 密码登录;没有账号的邮箱验证后会自动注册。登录后可以在「设置」页管理登录方式、密码、两步验证和登录会话。