Hotdry.
ai-systems

Call Center AI 的状态化多轮电话管道:实时对话、Claim 收集与持久化

基于 Microsoft Call Center AI,解析 API 触发状态化多轮电话代理的核心管道,支持实时 ASR/TTS、Claim schema 数据收集、断线续传与人工转接,实现客服全链路自动化。

在客服场景中,构建状态化多轮电话 AI 代理是实现全链路自动化的关键。通过 Microsoft 的 Call Center AI 项目,我们可以快速部署一个支持 API 触发的电话机器人,支持实时语音识别(ASR)、文本转语音(TTS)、结构化 Claim 数据收集,以及断线续传的多轮对话持久化。这种设计避免了传统单次交互的局限,确保复杂客服流程如保险理赔或 IT 支持的连续性。

核心观点在于:状态化管道通过 Cosmos DB 持久化会话历史、Claim 数据和提醒事项,实现多轮对话的上下文保持。证据显示,系统在 inbound/outbound 通话中实时流式处理音频:用户语音经 Azure Cognitive Services 的 Speech-to-Text 转为文本,注入 GPT-4o 或 GPT-4o-mini 模型生成响应,再经 Text-to-Speech 转为语音输出。同时,Redis 缓存加速 RAG 检索,Event Grid 处理事件驱动更新。断线后,系统自动从 DB 加载历史消息、Claim 状态和合成摘要,确保无缝续传。“Conversations are streamed in real-time to avoid delays, can be resumed after disconnections, and are stored for future reference。”

落地参数配置从 Claim schema 开始,这是结构化数据收集的核心。默认 schema 包括 caller_email(email 类型)、caller_name(text)和 caller_phone(E164 格式),可自定义扩展如 incident_datetime(datetime)、hardware_info(text)。API 调用时传入 claim 数组,例如:

"claim": [
  {"name": "hardware_info", "type": "text"},
  {"name": "first_seen", "type": "datetime"},
  {"name": "building_location", "type": "text"}
]

系统验证数据类型,确保合规。提示中注入最新 Claim 数据,如 “# Support status\n {claim}”,指导 LLM 逐步收集缺失字段,直至完整。对于多轮 persistence,会话 ID 基于 phone_number 生成,存储 messages 数组(含 created_at、action、content、persona),next action(如 case_closed)和 reminders(如 due_date_time)。

实时 ASR/TTS 参数优化至关重要。特征标志(App Configuration)控制 vad_threshold(0.5,默认语音活动检测阈值,范围 0.1-1)、vad_silence_timeout_ms(500ms,静音触发)、recognition_stt_complete_timeout_ms(100ms,STT 完成超时)和 phone_silence_timeout_sec(20s,用户静音警告)。LLM 响应有 answer_soft_timeout_sec(4s,发送等待消息)和 answer_hard_timeout_sec(15s,强制中止)。这些参数可动态调整,无需重启,TTL 60s 刷新。监控 Application Insights 中的 call.answer.latency(用户语音结束至 bot 语音开始时延)和 call.aec.droped(回声消除丢帧)。

人工转接与回退机制确保可靠性。通信服务支持 transfer to agent,特征标志 human_agent_fallback 启用。call recording(recording_enabled=true)存 Azure Storage,便于 QA。RAG 通过 AI Search 的 vectors(1536 维,ADA embedding)检索内部文档,注入提示增强领域知识。

部署清单:

  1. Azure 资源:Communication Services(phone number,支持 voice/SMS)、Cosmos DB(RU/s 1k+ 多区域写)、Redis、AI Search(Basic,15GB/index)、OpenAI(gpt-4o-nano 优先,低延迟)。

  2. 配置 config.yaml:conversation.initiate.task(英文任务描述,如 “Help the customer with their insurance claim.”)、claim schema、prompts.tts.hello_tpl(多模板随机化,提升自然度)、llm.fast.model(gpt-4o-nano)。

  3. 部署:make deploy name=my-rg(Bicep IaC,serverless Container Apps)。本地开发用 make tunnel + uv run local.py 测试无电话。

  4. 监控与调优:Insights 追踪 LLM tokens、STT/TTS 延迟。成本估算:1000 通话 ×10min ≈ $720 / 月,主因 Cosmos RU 和 Speech 服务。优化:PTU 降低 LLM TTFT,采样日志减 Monitor 费。

风险控制:作为 POC,生产需加单元测试、多区域、vNET。私有数据用 Content Safety moderation(0-7 级),fine-tuning 历史通话提升准确率(预处理 PII)。

此管道适用于中低复杂度客服,扩展 IVR 或 callback(callback_timeout_hour=3)。通过 API POST /call 传入 phone_number、task、claim,即可触发状态化代理,实现 24/7 自动化。

资料来源

(正文字数:约 950 字)

查看归档