企业微信 iPad 协议核心:外部联系人消息如何实时回调进业务系统

SEO 摘要:本文讲清企业微信 iPad 协议如何把外部联系人消息实时回调进业务系统,涵盖官方应用 API 与 iPad 协议的区别、回调架构、验签去重、客服/工单/AI 三条业务路由,并突出极客互动 API 平台在实例保活、开放调用、回调转发与日志追踪上的能力。

目录

  • [一、先把技术栈说清楚:官方应用 API ≠ iPad 协议](#一、先把技术栈说清楚:官方应用 API ≠ iPad 协议)
  • [二、iPad 协议的消息平面:外部联系人是一等公民](#二、iPad 协议的消息平面:外部联系人是一等公民)
  • [三、回调架构:协议会话 → 平台 → 客服 / 工单 / AI](#三、回调架构:协议会话 → 平台 → 客服 / 工单 / AI)
  • 四、把外部联系人回调收成「会话事件」
  • 五、场景:同一条外部联系人消息,三条业务出路
  • [六、联调清单(针对 iPad 协议,不是针对官方回调)](#六、联调清单(针对 iPad 协议,不是针对官方回调))
  • 七、本篇小结

官方企业微信应用 API 擅长通讯录、应用消息、审批。

客服、售后、私域跟进真正卡的,是另一件事:外部联系人正在跟坐席对话,消息能不能像 iPad 企微客户端一样实时进你的系统。

这就是 企业微信 iPad 协议 存在的位置:把一台「企微 iPad 客户端会话」跑在协议服务上,扫码上线后,收发、会话、群发控制台、消息推送都按客户端能力走。

极客互动 API 控制台把这层协议产品化:实例保活、开放调用、回调转发、日志可追,一个 uuid 就能把「在线坐席」接进你的业务系统,无需自建协议栈、无需维护客户端环境。

本文只讲 iPad 协议最值钱的一段------外部联系人消息如何实时回调。没有这条神经,后面的群发、工单、AI 自动客服都是空转。

csharp 复制代码
API调用:
  sdk_doc_url: "https://www.jikehudong.com"
  # 说明:该地址为自研企微API工具集文档地址,封装了客户联系、回调事件、消息推送常用接口,支持快速调试

一、先把技术栈说清楚:官方应用 API ≠ iPad 协议

#mermaid-svg-mAee7UZG3InK6Qt9{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-mAee7UZG3InK6Qt9 .error-icon{fill:#552222;}#mermaid-svg-mAee7UZG3InK6Qt9 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-mAee7UZG3InK6Qt9 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-mAee7UZG3InK6Qt9 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-mAee7UZG3InK6Qt9 .marker.cross{stroke:#333333;}#mermaid-svg-mAee7UZG3InK6Qt9 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-mAee7UZG3InK6Qt9 p{margin:0;}#mermaid-svg-mAee7UZG3InK6Qt9 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-mAee7UZG3InK6Qt9 .cluster-label text{fill:#333;}#mermaid-svg-mAee7UZG3InK6Qt9 .cluster-label span{color:#333;}#mermaid-svg-mAee7UZG3InK6Qt9 .cluster-label span p{background-color:transparent;}#mermaid-svg-mAee7UZG3InK6Qt9 .label text,#mermaid-svg-mAee7UZG3InK6Qt9 span{fill:#333;color:#333;}#mermaid-svg-mAee7UZG3InK6Qt9 .node rect,#mermaid-svg-mAee7UZG3InK6Qt9 .node circle,#mermaid-svg-mAee7UZG3InK6Qt9 .node ellipse,#mermaid-svg-mAee7UZG3InK6Qt9 .node polygon,#mermaid-svg-mAee7UZG3InK6Qt9 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-mAee7UZG3InK6Qt9 .rough-node .label text,#mermaid-svg-mAee7UZG3InK6Qt9 .node .label text,#mermaid-svg-mAee7UZG3InK6Qt9 .image-shape .label,#mermaid-svg-mAee7UZG3InK6Qt9 .icon-shape .label{text-anchor:middle;}#mermaid-svg-mAee7UZG3InK6Qt9 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-mAee7UZG3InK6Qt9 .rough-node .label,#mermaid-svg-mAee7UZG3InK6Qt9 .node .label,#mermaid-svg-mAee7UZG3InK6Qt9 .image-shape .label,#mermaid-svg-mAee7UZG3InK6Qt9 .icon-shape .label{text-align:center;}#mermaid-svg-mAee7UZG3InK6Qt9 .node.clickable{cursor:pointer;}#mermaid-svg-mAee7UZG3InK6Qt9 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-mAee7UZG3InK6Qt9 .arrowheadPath{fill:#333333;}#mermaid-svg-mAee7UZG3InK6Qt9 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-mAee7UZG3InK6Qt9 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-mAee7UZG3InK6Qt9 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-mAee7UZG3InK6Qt9 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-mAee7UZG3InK6Qt9 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-mAee7UZG3InK6Qt9 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-mAee7UZG3InK6Qt9 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-mAee7UZG3InK6Qt9 .cluster text{fill:#333;}#mermaid-svg-mAee7UZG3InK6Qt9 .cluster span{color:#333;}#mermaid-svg-mAee7UZG3InK6Qt9 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-mAee7UZG3InK6Qt9 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-mAee7UZG3InK6Qt9 rect.text{fill:none;stroke-width:0;}#mermaid-svg-mAee7UZG3InK6Qt9 .icon-shape,#mermaid-svg-mAee7UZG3InK6Qt9 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-mAee7UZG3InK6Qt9 .icon-shape p,#mermaid-svg-mAee7UZG3InK6Qt9 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-mAee7UZG3InK6Qt9 .icon-shape .label rect,#mermaid-svg-mAee7UZG3InK6Qt9 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-mAee7UZG3InK6Qt9 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-mAee7UZG3InK6Qt9 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-mAee7UZG3InK6Qt9 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 你的业务
极客互动控制台
企业微信 iPad 协议
官方应用 API
自建应用 / 通讯录 / 应用消息
协议服务上的 iPad 客户端会话
在线实例 uuid
外部联系人会话
消息实时推送
扫码登录 / 二次验证
POST /open/wxwork/{action}
POST /api/upstream/callback
客服工作台
售后工单
AI 自动客服

维度 官方应用 API 企业微信 iPad 协议(本平台)
登录形态 corpid + secret,应用身份 坐席扫码,客户端会话在线
外部联系人聊天 能力边界受应用权限约束 贴近 iPad 企微里「客户会话」
实时性 多为事件订阅 / 主动拉取 协议侧推送到回调地址
典型场景 组织架构、应用通知 客服、售后、群发执行、AI 坐席
调用入口 企微开放平台 POST /open/wxwork/{action} + uuid

一句话:官方 API 是「应用在说话」,iPad 协议是「这个坐席账号在工作」。

客服和售后要的是后者。

合规前提:只接入本企业有权使用的账号;实例、二维码、消息内容仅供该账号业务使用。


二、iPad 协议的消息平面:外部联系人是一等公民

在调试台目录里,和「客户正在说话」直接相关的积木包括:

能力 action 客服场景里干什么
外部联系人列表 GetExternalContacts 把客户同步进坐席库 / CRM
会话列表 GetSessionList 工作台左侧会话,补偿漏推
发文本 SendTextMsg 人工或 AI 回复客户
发卡片 / 图片 / 文件 SendLinkMsg / SendCDNImgMsg / SendCDNFileMsg 报价单、物流截图、说明书
语音转文字 SpeechToTextEntity 语音售后进工单正文
标记已读 MarkAsRead 对齐客户端小红点
绑定回调 SetCallbackUrl 控制台保存回调时由平台调用

实时路径不要靠轮询 GetSessionList。列表接口用来冷启动和对账,热路径必须是回调。

javascript 复制代码
const BASE = process.env.GEEK_API_BASE;   // 极客互动 API 网关
const TOKEN = process.env.GEEK_API_TOKEN; // 控制台签发的访问令牌
const UUID = process.env.WX_UUID;         // iPad 协议在线实例

async function wx(action, body = {}) {
  const res = await fetch(`${BASE}/open/wxwork/${action}`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ uuid: UUID, ...body }),
  });
  const json = await res.json();
  if (String(json.errcode) !== '0') {
    throw new Error(`${action}: ${json.errmsg || JSON.stringify(json)}`);
  }
  return json;
}

// 坐席上班:拉一页外部联系人,写入本地客户表
async function warmupCustomers() {
  return wx('GetExternalContacts', { limit: 50, strSeq: '' });
}

// 仅用于对账,不是实时收消息
async function warmupSessions() {
  return wx('GetSessionList', { limit: 100, star_index: 0 });
}

// 绑定回调:保存时平台向上游 SetCallbackUrl,之后消息实时推到你的网关
async function bindCallback(callbackUrl) {
  return wx('SetCallbackUrl', { callback_url: callbackUrl });
}

// 发送文本:人工 / AI 回复统一出口,便于审计与限流
async function replyText(toUserid, content, isRoom = false) {
  return wx('SendTextMsg', { send_userid: toUserid, isRoom, content });
}

// 语音售后:先转文字,再进工单正文
async function voiceToTicketText(mediaId) {
  return wx('SpeechToTextEntity', { media_id: mediaId });
}

// 对齐客户端小红点
async function markRead(sessionId) {
  return wx('MarkAsRead', { session_id: sessionId });
}

uuid 不是「租户 ID」,是这一路 iPad 协议会话。客服排班换人、多坐席并行,就是多实例、多回调,不要把 A 的客户消息接到 B 的地址上。

uuid 不是「租户 ID」,是这一路 iPad 协议会话。客服排班换人、多坐席并行,就是多实例、多回调,不要把 A 的客户消息接到 B 的地址上。


三、回调架构:协议会话 → 平台 → 客服 / 工单 / AI

客服/工单/AI 消息队列 业务Webhook 极客互动平台 iPad协议实例 外部联系人 客服/工单/AI 消息队列 业务Webhook 极客互动平台 iPad协议实例 外部联系人 #mermaid-svg-thgFhro4eYJ6PAVH{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-thgFhro4eYJ6PAVH .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-thgFhro4eYJ6PAVH .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-thgFhro4eYJ6PAVH .error-icon{fill:#552222;}#mermaid-svg-thgFhro4eYJ6PAVH .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-thgFhro4eYJ6PAVH .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-thgFhro4eYJ6PAVH .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-thgFhro4eYJ6PAVH .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-thgFhro4eYJ6PAVH .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-thgFhro4eYJ6PAVH .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-thgFhro4eYJ6PAVH .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-thgFhro4eYJ6PAVH .marker{fill:#333333;stroke:#333333;}#mermaid-svg-thgFhro4eYJ6PAVH .marker.cross{stroke:#333333;}#mermaid-svg-thgFhro4eYJ6PAVH svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-thgFhro4eYJ6PAVH p{margin:0;}#mermaid-svg-thgFhro4eYJ6PAVH .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-thgFhro4eYJ6PAVH text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-thgFhro4eYJ6PAVH .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-thgFhro4eYJ6PAVH .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg-thgFhro4eYJ6PAVH .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-thgFhro4eYJ6PAVH .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-thgFhro4eYJ6PAVH #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-thgFhro4eYJ6PAVH .sequenceNumber{fill:white;}#mermaid-svg-thgFhro4eYJ6PAVH #sequencenumber{fill:#333;}#mermaid-svg-thgFhro4eYJ6PAVH #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-thgFhro4eYJ6PAVH .messageText{fill:#333;stroke:none;}#mermaid-svg-thgFhro4eYJ6PAVH .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-thgFhro4eYJ6PAVH .labelText,#mermaid-svg-thgFhro4eYJ6PAVH .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-thgFhro4eYJ6PAVH .loopText,#mermaid-svg-thgFhro4eYJ6PAVH .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-thgFhro4eYJ6PAVH .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-thgFhro4eYJ6PAVH .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-thgFhro4eYJ6PAVH .noteText,#mermaid-svg-thgFhro4eYJ6PAVH .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-thgFhro4eYJ6PAVH .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-thgFhro4eYJ6PAVH .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-thgFhro4eYJ6PAVH .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-thgFhro4eYJ6PAVH .actorPopupMenu{position:absolute;}#mermaid-svg-thgFhro4eYJ6PAVH .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-thgFhro4eYJ6PAVH .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-thgFhro4eYJ6PAVH .actor-man circle,#mermaid-svg-thgFhro4eYJ6PAVH line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-thgFhro4eYJ6PAVH :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 发「订单发货了吗」 POST /api/upstream/callback 写回调日志 POST + X-Geek-Signature 验签 / msg_id 去重 / 200 投递会话事件 路由:人工 / 工单 / AI /open/wxwork/SendTextMsg 协议发送 坐席回复

控制台操作要点:

  1. 选已登录的 iPad 协议实例(不是整个企业)。
  2. 填写公网可 POST 的地址;保存时平台向上游 SetCallbackUrl。
  3. 联调可先填平台根地址,自动落到 /api/upstream/callback。
  4. 生产填你的客服网关;平台用 HMAC-SHA256 转发,头为 X-Geek-Signature。
  5. 本机用 natapp 等穿透;localhost 协议侧到不了。

地址 404、HTTPS 证书过期,绑定会失败。先保证「协议能推到平台」,再保证「平台能推到工单系统」。


四、把外部联系人回调收成「会话事件」

先收件箱,再业务。验签、按 msg_id 去重、立刻 200,消费放到队列。iPad 协议重试时,同一句客户消息进两次,AI 就会复读。

javascript 复制代码
import express from 'express';
import crypto from 'crypto';

const app = express();
app.use(express.json({ type: '*/*' }));
const SECRET = process.env.GEEK_CALLBACK_SECRET;

function signOk(raw, header) {
  if (!SECRET || !header) return false;
  const digest = crypto.createHmac('sha256', SECRET).update(raw).digest('hex');
  try {
    return crypto.timingSafeEqual(Buffer.from(digest), Buffer.from(header));
  } catch {
    return false;
  }
}

function asJson(body) {
  const inner = body?.json;
  if (typeof inner === 'string') {
    try { return JSON.parse(inner); } catch { return {}; }
  }
  return inner && typeof inner === 'object' ? inner : body;
}

// 简易内存去重:生产建议换 Redis SETNX + TTL
const seen = new Set();
function firstTime(msgId) {
  if (!msgId) return true;
  if (seen.has(msgId)) return false;
  seen.add(msgId);
  return true;
}

app.post('/hooks/wxwork-ipad', (req, res) => {
  const raw = JSON.stringify(req.body);
  const header = req.header('x-geek-signature') || req.header('X-Geek-Signature') || '';
  if (SECRET && !signOk(raw, header)) return res.status(401).json({ ok: false });

  const uuid = req.body?.uuid || req.body?.json?.uuid;
  const type = String(req.body?.type ?? req.body?.json?.type ?? 'message');
  const json = asJson(req.body);
  const msgId = json?.msg_id;

  // 幂等:同一 msg_id 只处理一次,避免 AI 复读
  if (!firstTime(msgId)) return res.json({ ok: true, dup: true });

  enqueueIpadEvent({
    protocol: 'wxwork-ipad',
    uuid,
    type,
    msgId,
    from: json.from_userid || json.send_userid || json.user_id,
    roomId: json.roomid || 0,
    content: json.content || '',
    raw: json,
  });

  // 立刻 200,消费交给队列
  res.json({ ok: true });
});

// 登录类回调:坐席掉线时灰掉输入框
app.post('/hooks/wxwork-ipad/login', (req, res) => {
  const json = asJson(req.body);
  const online = String(json.status ?? '').toLowerCase() === 'online';
  setAgentOnline(json.uuid, online);
  res.json({ ok: true });
});

字段名以控制台「回调日志」里的真实 payload 为准,上线前把一条外部联系人文本、一条群消息、一条登录成功分别存进 fixtures/。

字段名以控制台「回调日志」里的真实 payload 为准,上线前把一条外部联系人文本、一条群消息、一条登录成功分别存进 fixtures/。

登录类回调(如登录成功 / 二次验证)不是噪音:坐席 iPad 会话掉线,客服台必须立刻灰掉输入框,避免 AI 对着离线 uuid 狂发。


五、场景:同一条外部联系人消息,三条业务出路

javascript 复制代码
async function routeExternalMessage(evt, ctx) {
  const text = String(evt.content || '');
  const customer = await ctx.crm.findByVid(evt.from);

  // 0) 转人工关键词:优先于一切自动逻辑
  if (/转人工|人工客服|找客服/.test(text)) {
    await ctx.desk.push({ ...evt, priority: 'high' });
    await ctx.wx('SendTextMsg', {
      send_userid: evt.from,
      isRoom: false,
      content: '已为您转接人工客服,请稍候。',
    });
    return;
  }

  // 1) 售后工单:物流 / 退款 / 发票
  if (/(发货|物流|退款|发票|坏了|不工作)/.test(text)) {
    const ticket = await ctx.tickets.open({
      source: 'wxwork-ipad',
      uuid: evt.uuid,
      customerId: evt.from,
      title: text.slice(0, 40),
      body: text,
    });
    await ctx.wx('SendTextMsg', {
      send_userid: evt.from,
      isRoom: false,
      content: `已为您创建售后单 ${ticket.no},专员会在工作时间内跟进。`,
    });
    return;
  }

  // 2) 人工客服:排队中的会话优先进坐席
  if (customer?.preferHuman || ctx.queue.hasAgent(evt.uuid)) {
    await ctx.desk.push(evt);
    return;
  }

  // 3) AI 自动客服:其余进模型,回复仍走 iPad 协议发送
  const answer = await ctx.ai.reply({
    customerId: evt.from,
    history: await ctx.crm.recentTurns(evt.from),
    text,
  });
  await ctx.wx('SendTextMsg', {
    send_userid: evt.from,
    isRoom: false,
    content: answer.text,
  });
  await ctx.crm.appendTurn(evt.from, { role: 'ai', text: answer.text });
}

要点:

  • 工单系统认「客户 vid + 原文」,iPad 协议只负责把话筒接到工单。
  • 人工优先于 AI。 客户说「转人工」或坐席已接起,模型立刻闭嘴。
  • AI 不直连协议。 模型出文案,SendTextMsg 才是出口,方便审计和限流。
  • 回复落库。 每轮 AI 回复写回 CRM,下一轮上下文才连贯。

要点:

  • 工单系统认「客户 vid + 原文」,iPad 协议只负责把话筒接到工单。
  • 人工优先于 AI。 客户说「转人工」或坐席已接起,模型立刻闭嘴。
  • AI 不直连协议。 模型出文案,SendTextMsg 才是出口,方便审计和限流。

语音售后可先 SpeechToTextEntity 再进 routeExternalMessage,工单正文才搜得到。


六、联调清单(针对 iPad 协议,不是针对官方回调)

  1. 控制台确认实例状态为在线(iPad 会话活着)。
  2. 保存回调并「测试连通」。
  3. 用外部联系人(不要只用企业内部同事)给该坐席发「发货了吗」。
  4. 回调日志出现该 uuid 的消息;业务网关 200。
  5. 调用日志出现一条 SendTextMsg。
  6. 同一句重试,客户只收到一次确认。
  7. 退出登录后再发,系统应停止自动回复并告警「实例离线」。

七、本篇小结

  • 企业微信 iPad 协议的核心资产,是在线坐席会话 + 外部联系人实时消息。
  • 回调是热路径,GetSessionList 是冷启动。
  • 同一条客户消息可以进客服台、售后工单或 AI,但出口统一走 /open/wxwork/*。
相关推荐
天空属于哈夫克316 小时前
智能客服升级:让企业微信私域服务更高效
人工智能·企业微信
天空属于哈夫克318 小时前
新手入门企业微信API:从零了解接口开发
企业微信
微信ipad协议开发19 小时前
微信最新协议API接口指南
微信·个人微信开发·微信api·微信最新协议·个微机器人·wechat接口开发
天空属于哈夫克31 天前
物流信息自动化:企业微信让客户跟进更简单
大数据·自动化·企业微信
天空属于哈夫克34 天前
企业微信API自动化:让重复工作交给程序
机器人·自动化·企业微信
天空属于哈夫克34 天前
企业微信API机器人开发:打造自动化助手
机器人·自动化·企业微信
天空属于哈夫克34 天前
企业微信二次开发:解锁更多自动化应用场景
运维·自动化·企业微信
天空属于哈夫克34 天前
企业微信API机器人:让业务自动化更简单
机器人·自动化·企业微信
天空属于哈夫克34 天前
企业微信API二次开发:解锁业务自动化新可能
机器人·自动化·企业微信