wechat-auto-reply.workflow.json 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {
  2. "name": "wechat-auto-reply",
  3. "displayName": "微信自动应答",
  4. "description": "定时轮询新消息,根据来源(个人/群聊)分类处理,生成智能回复并发送。",
  5. "version": "1.0.0",
  6. "trigger": {
  7. "type": "polling",
  8. "intervalSeconds": 10,
  9. "description": "每10秒轮询一次新消息"
  10. },
  11. "state": {
  12. "lastCheckTime": {
  13. "type": "string",
  14. "description": "上次检查的时间戳(ISO),用于增量拉取",
  15. "default": ""
  16. }
  17. },
  18. "stages": [
  19. {
  20. "id": "check-online",
  21. "name": "检查在线状态",
  22. "skill": "wechat-check-online",
  23. "input": {},
  24. "onFailure": "stop",
  25. "condition": "每次轮询的第一步",
  26. "expect": { "data": true }
  27. },
  28. {
  29. "id": "fetch-new-messages",
  30. "name": "增量拉取新消息",
  31. "skill": "wechat-get-messages",
  32. "input": {
  33. "since": "{{state.lastCheckTime}}",
  34. "direction": "received",
  35. "limit": 50
  36. },
  37. "output": {
  38. "messages": "data",
  39. "description": "收到的新消息数组"
  40. },
  41. "postAction": "更新 state.lastCheckTime 为当前时间"
  42. },
  43. {
  44. "id": "classify-and-reply",
  45. "name": "分类处理并回复",
  46. "type": "forEach",
  47. "items": "{{stages.fetch-new-messages.output.messages}}",
  48. "filter": {
  49. "description": "过滤掉系统消息和自己发的消息",
  50. "conditions": [
  51. "item.type != 'system'",
  52. "item.direction == 'received'"
  53. ]
  54. },
  55. "steps": [
  56. {
  57. "id": "classify-source",
  58. "name": "判断消息来源",
  59. "type": "condition",
  60. "rules": [
  61. {
  62. "if": "item.fromWxid ends with '@chatroom'",
  63. "then": { "sourceType": "group", "replyTo": "item.fromWxid" }
  64. },
  65. {
  66. "else": true,
  67. "then": { "sourceType": "personal", "replyTo": "item.fromWxid" }
  68. }
  69. ]
  70. },
  71. {
  72. "id": "generate-reply",
  73. "name": "AI生成回复内容",
  74. "type": "llm",
  75. "systemPrompt": "你是一个微信智能助手。请根据用户发来的消息生成简短、友好的回复。如果是群聊消息,回复要简洁。如果无法理解内容,回复"收到,稍后回复您"。不要回复系统消息、表情、图片等非文字内容。",
  76. "userPrompt": "来源类型: {{classify-source.sourceType}}\n发送者: {{item.nickName}} ({{item.fromWxid}})\n消息类型: {{item.type}}\n消息内容: {{item.content}}\n\n请生成回复:",
  77. "output": { "replyContent": "llm_response" }
  78. },
  79. {
  80. "id": "send-reply",
  81. "name": "发送回复",
  82. "skill": "wechat-send-text",
  83. "input": {
  84. "toWxid": "{{classify-source.replyTo}}",
  85. "content": "{{generate-reply.replyContent}}"
  86. }
  87. }
  88. ]
  89. }
  90. ],
  91. "replyRules": {
  92. "description": "回复策略规则(龙虾参考)",
  93. "personalChat": {
  94. "description": "个人私聊",
  95. "behavior": "收到文字消息后,用AI生成个性化回复;收到图片/语音/视频等仅回复确认。",
  96. "examples": [
  97. { "received": "你好", "reply": "你好!有什么可以帮你的吗?" },
  98. { "received": "[图片]", "reply": "收到图片,我看看~" },
  99. { "received": "明天几点开会", "reply": "让我帮你查一下,稍等。" }
  100. ]
  101. },
  102. "groupChat": {
  103. "description": "群聊",
  104. "behavior": "仅在被@或关键词触发时回复,避免刷屏。回复简洁。",
  105. "triggerKeywords": ["@助手", "@bot", "帮我", "请问"],
  106. "examples": [
  107. { "received": "@助手 明天天气怎么样", "reply": "明天多云转晴,适合出行!" },
  108. { "received": "随便聊天", "reply": null, "note": "不回复,不相关" }
  109. ]
  110. },
  111. "ignoreTypes": ["system", "emoji", "location", "video", "voice"],
  112. "ignoreWxids": ["weixin", "fmessage", "medianote", "gh_"]
  113. }
  114. }