Files
2026-05-09 17:52:25 +08:00

36 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Hermes Feishu Bridge
双向桥接服务:
- `POST /feishu/events`:飞书事件回调。收到文本消息后后台调用 Hermes再发回飞书。
- `POST /feishu/events/{app_id}`:多个飞书应用共用桥服务时,按路径指定应用。
- `POST /feishu/notify`Hermes 或内部系统主动通知飞书。必须带 `Authorization: Bearer $FEISHU_NOTIFY_TOKEN``X-Hermes-Feishu-Token`
- `POST /feishu/notify/{app_id}`:主动通知时指定发消息的飞书应用,也可在 JSON 里传 `app_id`
- `GET /health`:健康检查。
## 凭证
不要把 `FEISHU_APP_SECRET``HERMES_API_KEY``FEISHU_NOTIFY_TOKEN` 写入仓库。线上使用 `/etc/hermes-feishu-bridge.env` 或同等级别的部署密钥文件。
## 飞书后台配置
1. 给自建应用开通消息相关权限,例如接收消息事件、获取与发送单聊/群组消息。
2. 事件订阅里添加请求地址:默认应用用 `https://hermes.kang-kang.com/feishu/events`;其它应用用 `https://hermes.kang-kang.com/feishu/events/{app_id}`
3. 如果启用事件加密,需要先给本服务补充解密支持;当前版本按明文事件回调处理。
4. 建议配置 `FEISHU_VERIFICATION_TOKEN`,并保持和飞书后台一致。
5. 如果飞书后台刚切换过 token`FEISHU_VERIFICATION_TOKEN` 可临时用英文逗号配置多个值,兼容旧事件投递和新 URL 校验。
## 主动通知示例
```bash
curl -X POST https://hermes.kang-kang.com/feishu/notify \
-H "Authorization: Bearer $FEISHU_NOTIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"receive_id_type":"chat_id","receive_id":"oc_xxx","text":"任务完成"}'
curl -X POST https://hermes.kang-kang.com/feishu/notify/cli_xxx \
-H "Authorization: Bearer $FEISHU_NOTIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"receive_id_type":"chat_id","receive_id":"oc_xxx","text":"任务完成"}'
```