ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

企业微信API开发:SCRM 自动化工作流编排与落地

企业微信API开发:SCRM 自动化工作流编排与落地 官方文档平台介绍 - QiWe API企微 API 开发文档一、业务痛点与技术背景典型企业微信 SCRM SOP新客户添加 → 打标签 → 发送欢迎与资料 → 进入培育序列 → 到期未回复转销售 → 成交打标 → 拉入客户群用脚本硬编码会导致销售规则变更要发版、无法灰度、跨系统补偿困难。应使用可视化/配置化工作流QiWe API 作为 Action Provider。二、核心架构设计与数据流转Trigger: friend_added | order_paid | timer | crm_stage_changed │ ▼ Flow Engine (版本化定义) │ ├─ Condition (标签/阶段/企微群) ├─ Action.qiwe.* (经 Outbound Gateway) ├─ Action.crm.* └─ Wait / Split / Join / Human Task │ ▼ Instance State DB Timeline客户旅程三、关键代码与配置示例3.1 SOP 定义id: new_customer_sop version: 5 trigger: { type: qiwe_event, event: external_friend_added } steps: - id: tag_new action: qiwe.add_tags params: { tags: [新客, 未首购] } - id: welcome action: qiwe.send_text params: { template: ent_welcome_v5 } - id: send_deck action: qiwe.send_file params: { file_asset: product_deck.pdf } - id: wait_2d action: delay params: { days: 2 } - id: check_reply action: condition when: stats.customer_replied false then: - action: crm.assign_owner params: { pool: sales_a } - action: qiwe.send_text params: { template: sales_followup } else: - action: qiwe.add_tags params: { tags: [互动中] }3.2 Action Providerclass QiWeActions: def __init__(self, gateway, client): self.gateway gateway self.client client def add_tags(self, ctx, tags): return self.client.call(/contact/addTag, { guid: ctx[guid], userId: ctx[customer_id], tags: tags, }) def send_text(self, ctx, template): content render(template, ctx) return self.gateway.enqueue({ client_msg_id: f{ctx[instance_id]}:send_text:{template}, guid: ctx[guid], to_id: ctx[customer_id], chat_type: user, priority: 1, kind: text, payload: {content: content}, })3.3 与 CRM 阶段联动onCrmStageChanged(async (e) { if (e.stage won) { await flow.start(post_sale_onboarding, { customerId: e.customerId, guid: e.qiweGuid, }); } });3.4 人工任务高客单报价发送前 → human_task(销售经理审批) 通过 → send_file(报价单) 驳回 → 通知草稿修改者流程 park四、生产环境避坑与安全风控步骤幂等instance_id step_id作为 client_msg_id。版本冻结旧客户继续跑 v5新客可切 v6。Delay 持久化用调度器勿sleep在消费协程。失败策略可配置 retry / skip / park禁止静默吞错。效果分析按 step 漏斗看欢迎语与资料转化。能力清单见文首官方文档。五、本篇交付清单SCRM SOP 配置模型QiWe Action ProviderCRM 联动与人工审批幂等与版本化要点
返回列表