71 lines
1.2 KiB
Markdown
71 lines
1.2 KiB
Markdown
# 飞书消息发送Skill 设计
|
|
|
|
## 1. Skill 定位
|
|
|
|
`飞书消息发送Skill` 负责调用飞书 OpenAPI 或 MCP 工具发送消息,并返回发送结果。
|
|
|
|
英文实现标识建议使用 `FeishuMessageSendSkill`。
|
|
|
|
## 2. 输入
|
|
|
|
```python
|
|
@dataclass
|
|
class FeishuMessageSendInput:
|
|
chat_id: str
|
|
message_type: str
|
|
payload: dict
|
|
```
|
|
|
|
## 3. 输出
|
|
|
|
```python
|
|
@dataclass
|
|
class FeishuMessageSendOutput:
|
|
send_status: str
|
|
message_id: str | None
|
|
raw_response: dict
|
|
error_message: str = ""
|
|
```
|
|
|
|
## 4. 核心方法
|
|
|
|
### 4.1 `run(input) -> FeishuMessageSendOutput`
|
|
|
|
主入口方法。
|
|
|
|
### 4.2 `send_text(chat_id, payload) -> dict`
|
|
|
|
发送文本消息。
|
|
|
|
### 4.3 `send_card(chat_id, payload) -> dict`
|
|
|
|
发送互动卡片。
|
|
|
|
### 4.4 `retry_on_transient_error(request) -> dict`
|
|
|
|
临时错误重试。
|
|
|
|
## 5. 技术实现
|
|
|
|
使用技术:
|
|
|
|
1. 飞书 OpenAPI
|
|
2. 飞书 MCP 工具
|
|
3. HTTP client
|
|
4. 重试策略
|
|
|
|
## 6. 异常处理
|
|
|
|
1. token 失效:发送失败并记录。
|
|
2. chat_id 无效:发送失败。
|
|
3. 网络超时:重试后失败。
|
|
4. payload 非法:发送失败。
|
|
|
|
## 7. 测试要点
|
|
|
|
1. 文本消息 payload 正确。
|
|
2. 卡片消息 payload 正确。
|
|
3. API 失败可记录错误。
|
|
4. 临时错误可重试。
|
|
|