Install
openclaw skills install @thcjp/customer-crmopenclaw skills install @thcjp/customer-crm版本: v1.0 | 优先级: P1 | 状态: 🟢 可用 | 来源: DEF-44公众号引流闭环(合并customer-source-tracker)
| 来源 | 标识 | 触发条件 |
|---|---|---|
| 公众号 | wechat_official | wx_reply_message回复用户时自动记录 |
| 闲鱼 | xianyu | confirm_delivery_by_buyer确认下载时自动记录 |
| 抖音 | douyin | content-matrix发布后用户私信时记录 |
| 快手 | kuaishou | content-matrix发布后用户私信时记录 |
| 直接访问 | direct | 无来源标识时默认 |
data/xianyu_agent_states/tenant_{tenant_id}_state.json → customer_sources 字段data/config/wx_source_tracker.json → openid → source=wechat_officialdaily-briefing Cron(在daily-briefing执行时追加来源归因统计)来源识别
归因统计
复购推荐
本工作流声明xianyu-auto-reply→customer-crm→repurchase-guide的完整闭环链路,满足R-98闭环连接规范。xianyu-auto-reply在消息处理流程的步骤6.6主动同步客户档案到customer-crm,customer-crm维护客户视图供repurchase-guide复购推荐使用。
xianyu-auto-reply(消息处理)
│
└─[步骤6.6同步]──> customer-crm(客户档案建立/更新)
│
├─[来源归因]──> daily-briefing(归因统计)
│
└─[客户视图]──> repurchase-guide(复购推荐)
│
└─[复购消息]──> xianyu-auto-reply(发送复购引导)
| 触发事件 | 触发条件 | 同步字段 | 来源 |
|---|---|---|---|
| 首次咨询 | customer_status=free(首次消息) | buyer_id+source=xianyu+free | xianyu-auto-reply步骤6.6 |
| 状态升级 | consulting→ordered(付款成功) | +ordered+total_spent+total_orders | xianyu-auto-reply步骤6.6 |
| 复购触发 | ordered→repurchased(二次咨询) | +repurchased+last_interaction | xianyu-auto-reply步骤6.6 |
| 确认收货 | confirm_delivery_by_buyer事件 | +delivery_confirmed+source=xianyu | xianyu-agent-mcp事件 |
{action:record_source, customer_id:{buyer_id}, source:xianyu, platform:xianyu, tenant_id:{tenant_id}}data/xianyu_agent_states/tenant_{tenant_id}_state.json的customer_sources字段写入/更新客户记录
data/repurchase_triggers/{buyer_id}.json(原子写入){success:true, data:{recorded:true, source:xianyu, customer_id:{buyer_id}}}| 异常 | 处理 | 错误码 |
|---|---|---|
| xianyu-auto-reply同步请求customer_id为空 | 返回VALUE_ERROR,跳过同步 | CRM-ERR-01 |
| 租户状态文件不存在 | 创建新文件并初始化空customer_sources | CRM-ERR-03 |
| 复购触发写入失败 | 跳过复购触发,不影响主同步流程,记录warning | CRM-ERR-06 |
| customer-crm不可用 | xianyu-auto-reply主流程继续,记录warning日志(R-98异步最终一致) | - |
{
"action": "record_source",
"customer_id": "xianyu_user_12345",
"source": "xianyu",
"platform": "xianyu",
"tenant_id": "default"
}
支持action: record_source(记录来源)/get_customer_profile(获取客户档案)/recommend_repurchase(复购推荐)/attribute_stats(归因统计)
{
"success": true,
"data": {
"customer_id": "xianyu_user_12345",
"source": "xianyu",
"recorded": true,
"by_source": {
"wechat_official": 45,
"xianyu": 120,
"douyin": 30,
"direct": 15
},
"repurchase_recommendation": [
{"product": "AI写作Prompt包", "reason": "曾购买AI工具类商品"}
]
},
"error": null,
"code": "CRM-SUCCESS-01"
}
| 异常 | 错误码 | 处理 |
|---|---|---|
| 客户ID为空 | CRM-ERR-01 | 返回VALUE_ERROR,提示提供customer_id |
| 来源类型未知 | CRM-ERR-02 | 默认归类为direct,记录warning |
| 租户状态文件不存在 | CRM-ERR-03 | 创建新文件并初始化空customer_sources |
| 复购推荐无历史数据 | CRM-ERR-04 | 返回空推荐列表,标记new_customer |
| daily-briefing归因失败 | CRM-ERR-05 | 跳过归因统计,不影响主流程 |
输入: {"action":"record_source","customer_id":"xianyu_user_12345","source":"xianyu"}
输出: {"success":true,"data":{"recorded":true,"source":"xianyu"}}
输入: {"action":"attribute_stats","tenant_id":"default"}
输出: {"success":true,"data":{"by_source":{"wechat_official":45,"xianyu":120,"douyin":30,"direct":15},"total_customers":210}}