pipeline.md 3.9 KB

微信自动应答 Pipeline

执行流程图

┌──────────────────────────────────┐
│         定时触发 (每10秒)          │
└───────────────┬──────────────────┘
                │
                ▼
┌──────────────────────────────────┐
│  Stage 1: 检查在线状态             │
│  skill: wechat-check-online      │
│  → data=true → 继续               │
│  → data=false → 停止等待重连       │
└───────────────┬──────────────────┘
                │
                ▼
┌──────────────────────────────────┐
│  Stage 2: 增量拉取新消息           │
│  skill: wechat-get-messages      │
│  input: since=上次检查时间         │
│         direction=received       │
│  → 返回新消息数组                  │
└───────────────┬──────────────────┘
                │
                ▼
┌──────────────────────────────────┐
│  Stage 3: 遍历每条新消息           │
│  过滤: 跳过系统消息/表情/自己发的   │
│  过滤: 跳过 weixin/fmessage 等    │
└───────┬───────────────┬──────────┘
        │               │
        ▼               ▼
┌──────────────┐ ┌──────────────┐
│  个人私聊     │ │  群聊         │
│  fromWxid    │ │  @chatroom   │
│  不含@chatroom│ │              │
└──────┬───────┘ └──────┬───────┘
       │                │
       ▼                ▼
┌──────────────┐ ┌──────────────────┐
│ AI生成回复    │ │ 检查是否被@或关键词│
│ 友好个性化    │ │ 触发才回复        │
└──────┬───────┘ └──────┬───────────┘
       │                │
       ▼                ▼
┌──────────────────────────────────┐
│  Stage 4: 发送回复                 │
│  skill: wechat-send-text         │
│  input: toWxid, content          │
└──────────────────────────────────┘

消息来源分类规则

fromWxid 格式 来源类型 存储目录 回复策略
wxid_xxx 个人私聊 personal/{wxid}.jsonl 每条消息都回复
xxx@chatroom 群聊 group/{chatroom}.jsonl 仅被@或关键词触发时回复
gh_xxx 公众号 忽略 不回复
weixin/fmessage 系统 忽略 不回复

回复策略

个人私聊

  • 文字消息 → AI生成个性化回复
  • 图片/语音/视频 → 回复确认("收到图片~")
  • 名片/位置/链接 → 回复确认

群聊

  • 被@时 → AI生成回复
  • 包含关键词("帮我"/"请问")→ AI生成回复
  • 其他消息 → 不回复,避免刷屏

忽略列表

  • 消息类型: system, emoji, location, video, voice
  • 来源wxid: weixin, fmessage, medianote, gh_* (公众号)

状态管理

状态变量 说明
lastCheckTime 上次轮询时间(ISO),用于 since 增量拉取

每次轮询完成后更新 lastCheckTime = 当前时间,下次只拉新消息。