在呼叫中心场景中,传统人工外呼效率低下、成本高企,而通过简单 API 调用即可发起 AI 代理电话,能显著提升自动化水平。Microsoft 的 Call-Center-AI 项目提供了一个完整的解决方案,支持 outbound(外呼)和 inbound(接听)模式,用户只需配置 Azure 电话号码,即可让 AI bot 实时对话、转录并集成外部工具。该方案的核心在于 API 驱动的灵活性,避免了复杂 IVR 系统,适用于保险理赔、IT 支持等低中复杂度任务。
API 发起外呼的核心机制
项目通过 POST /call 接口触发 AI 代理拨打电话,参数高度可配置化。典型 curl 请求如下:
curl --header 'Content-Type: application/json' --request POST --url https://xxx/call \
--data '{
"bot_company": "Contoso",
"bot_name": "Amélie",
"phone_number": "+11234567890",
"task": "Help the customer with their digital workplace...",
"agent_phone_number": "+33612345678",
"claim": [
{"name": "hardware_info", "type": "text"},
{"name": "first_seen", "type": "datetime"},
{"name": "building_location", "type": "text"}
]
}'
这里,bot_company 和 bot_name 定义代理身份,便于个性化提示;phone_number 是目标客户号码;task 是英文任务描述,作为 LLM system prompt 的核心上下文;agent_phone_number 用于可选的人工转接;claim schema 支持 text/datetime/email/phone_number 类型,AI 会引导用户填充结构化数据。证据显示,这种 schema 驱动的对话能自动生成 claim、reminders 和 synthesis,确保数据合规。
落地参数建议:
- task 长度控制在 100-200 字,聚焦目标(如“收集理赔信息”),避免泛化。
- claim 字段不超过 5-8 个,优先必填项(如姓名、时间),可选 description 辅助 LLM 理解。
- 支持覆盖默认 schema(如 caller_email、caller_name),API 调用时动态覆盖。
对于 inbound,用户拨打配置的 Azure 电话号码,bot 自动接听,使用默认 task(如“Help the customer with their insurance claim”)。
电话号码配置与直拨 bot
关键在于 Azure Communication Services(ACS)资源:
- 创建资源组(e.g., ccai-rg)。
- 新建 ACS 资源,同名,启用系统托管身份。
- 购买电话号码:支持 inbound/outbound,支持 voice/SMS,选择区域(如 West Europe)。
部署后,号码关联 Event Grid → 队列 → App 服务,实现事件驱动。bot 可自定义声音,如 fr-FR-DeniseNeural 或 zh-CN-XiaoqiuNeural,通过 config.yaml 的 conversation.initiate.lang 配置,支持多语言检测(pronunciations_en 列表)。
自定义语音:集成 Azure Custom Neural Voice,添加 custom_voice_endpoint_id,提升品牌一致性。风险控制:号码需 E164 格式(如 +1xxxxxxxxxx),测试时用免费号码避免费用。
实时对话转录与工具集成
对话流:用户语音 → STT(Cognitive Services,实时)→ LLM(gpt-4o-mini/nano,默认 fast 模型)→ tool calls(如 RAG 查询)→ TTS → ACS 播放。支持流式传输,断线后 resume。
转录存储在 Cosmos DB,包括 messages(action: talk/persona/style/tool_calls)、claim、next action、reminders、synthesis(long/short/satisfaction)。LLM 使用 structured output,过滤 jailbreak,检测有害内容(Content Safety 阈值 0-7)。
工具集成要点:
- RAG:AI Search 索引(fields: answer/context/vectors@1536 ADA),每消息搜索 400 tokens。
- Reminders:自动生成 due_date_time,如 “2024-12-11T14:30:00”。
- Feature flags(App Configuration,TTL 60s):
recording_enabled=true、slow_llm_for_chat=false、vad_threshold=0.5。
优化参数清单:
| 参数 |
默认值 |
建议调优 |
| answer_hard_timeout_sec |
15 |
复杂任务增至 30 |
| phone_silence_timeout_sec |
20 |
客服场景 15-25 |
| vad_silence_timeout_ms |
500 |
噪声环境 800 |
| recognition_retry_max |
3 |
≥3 防误识 |
| callback_timeout_hour |
3 |
0 禁用 |
报告接口:/report/{phone_number},展示历史、claim、reminders。
部署与监控落地
部署分 remote(Azure Container Apps,ghcr.io/clemlesne/call-center-ai:main)和 local(Rust/uv Python,devtunnel)。config.yaml 关键:
- llm.fast.model: gpt-4o-mini(低成本,高性能)。
- conversation.default_initiate.claim/task:默认 inbound。
- prompts.tts.hello_tpl:多模板随机,提升自然度。
监控:App Insights 追踪 call.answer.latency、aec.dropped;成本估算(1000 calls@10min):~$720/month,主要 Cosmos RU/s 和 Speech。
回滚策略:feature flags 热更新;PTU 部署 Azure OpenAI 减延迟 50%。
快速上手清单:
- Azure 准备:资源组、ACS、号码、OpenAI。
- make deploy name=ccai-rg。
- 测试 API:curl POST /call。
- Inbound:拨打号码。
- 监控:make logs;Insights 仪表盘。
- 定制:config.yaml → App Config。
来源:https://github.com/microsoft/call-center-ai(POC,非生产);相关讨论见 CSDN/HN 热度追踪。
此方案参数化强,落地周期短,适用于中小团队快速验证 AI 电话代理。(字数:1256)