语音通话(插件)
通过插件为 OpenClaw 提供语音通话功能。支持外呼通知和带呼入策略的多轮对话。
当前支持的提供商:
twilio(语音编程 + 媒体流)telnyx(通话控制 v2)plivo(语音 API + XML 传输 + GetInput 语音)mock(开发/无网络)
快速理解模型:
- 安装插件
- 重启 Gateway
- 在
plugins.entries.voice-call.config下配置 - 使用
openclaw voicecall ...或voice_call工具
运行位置(本地 vs 远程)
语音通话插件在 Gateway 进程内运行。
如果你使用远程 Gateway,请在运行 Gateway 的机器上安装/配置插件,然后重启 Gateway 以加载它。
安装
选项 A:从 npm 安装(推荐)
openclaw plugins install @openclaw/voice-call
之后重启 Gateway。
选项 B:从本地文件夹安装(开发用,不复制)
openclaw plugins install ./extensions/voice-call
cd ./extensions/voice-call && pnpm install
之后重启 Gateway。
配置
在 plugins.entries.voice-call.config 下设置配置:
{
plugins: {
entries: {
"voice-call": {
enabled: true,
config: {
provider: "twilio", // 或 "telnyx" | "plivo" | "mock"
fromNumber: "+15550001234",
toNumber: "+15550005678",
twilio: {
accountSid: "ACxxxxxxxx",
authToken: "...",
},
telnyx: {
apiKey: "...",
connectionId: "...",
// 来自 Telnyx Mission Control Portal 的 Telnyx webhook 公钥
//(Base64 字符串;也可通过 TELNYX_PUBLIC_KEY 设置)。
publicKey: "...",
},
plivo: {
authId: "MAxxxxxxxxxxxxxxxxxxxx",
authToken: "...",
},
// Webhook 服务器
serve: {
port: 3334,
path: "/voice/webhook",
},
// Webhook 安全(隧道/代理推荐使用)
webhookSecurity: {
allowedHosts: ["voice.example.com"],
trustedProxyIPs: ["100.64.0.1"],
},
// 公开暴露(选择一种)
// publicUrl: "https://example.ngrok.app/voice/webhook",
// tunnel: { provider: "ngrok" },
// tailscale: { mode: "funnel", path: "/voice/webhook" }
outbound: {
defaultMode: "notify", // notify | conversation
},
streaming: {
enabled: true,
streamPath: "/voice/stream",
preStartTimeoutMs: 5000,
maxPendingConnections: 32,
maxPendingConnectionsPerIp: 4,
maxConnections: 128,
},
},
},
},
},
}
注意事项:
- Twilio/Telnyx 需要可公开访问的 webhook URL。
- Plivo 需要可公开访问的 webhook URL。
mock是本地开发提供商(无网络调用)。- Telnyx 需要
telnyx.publicKey(或TELNYX_PUBLIC_KEY),除非skipSignatureVerification为 true。 skipSignatureVerification仅用于本地测试。- 如果使用 ngrok 免费版,将
publicUrl设置为准确的 ngrok URL;签名验证始终强制执行。 tunnel.allowNgrokFreeTierLoopbackBypass: true仅在tunnel.provider="ngrok"且serve.bind为环回(ngrok 本地代理)时允许 Twilio webhook 使用无效签名。仅用于本地开发。- ngrok 免费版 URL 可能会更改或添加插入式行为;如果
publicUrl漂移,Twilio 签名将失败。生产环境首选稳定域名或 Tailscale funnel。 - 流媒体安全默认值:
streaming.preStartTimeoutMs关闭从未发送有效start帧的套接字。streaming.maxPendingConnections限制预启动套接字总数。streaming.maxPendingConnectionsPerIp限制每个源 IP 的预启动套接字数。streaming.maxConnections限制打开的媒体流套接字总数(待处理 + 活动)。
过期通话回收器
使用 staleCallReaperSeconds 结束从未收到终止 webhook 的通话(例如,未完成的通知模式通话)。默认值为 0(禁用)。
推荐范围:
- 生产环境: 通知风格流程为
120–300秒。 - 将此值高于
maxDurationSeconds以便正常通话可以完成。好的起点是maxDurationSeconds + 30–60秒。
示例:
{
plugins: {
entries: {
"voice-call": {
config: {
maxDurationSeconds: 300,
staleCallReaperSeconds: 360,
},
},
},
},
}
Webhook 安全
当代理或隧道位于 Gateway 前面时,插件会重建用于签名验证的公开 URL。这些选项控制信任哪些转发头。
webhookSecurity.allowedHosts 白名单转发头中的主机。
webhookSecurity.trustForwardingHeaders 无白名单信任转发头。
webhookSecurity.trustedProxyIPs 仅当请求的远程 IP 匹配列表时才信任转发头。
Twilio 和 Plivo 启用了 webhook 重放保护。重放的有效 webhook 请求会被确认但跳过副作用。
Twilio 对话轮次在 <Gather> 回调中包含每轮令牌,因此陈旧/重放的语音回调无法满足更新的待处理转录轮次。
使用稳定公开主机的示例:
{
plugins: {
entries: {
"voice-call": {
config: {
publicUrl: "https://voice.example.com/voice/webhook",
webhookSecurity: {
allowedHosts: ["voice.example.com"],
},
},
},
},
},
}
通话的 TTS
语音通话使用核心 messages.tts 配置(OpenAI 或 ElevenLabs)进行通话中的流式语音传输。你可以使用相同结构在插件配置中覆盖它 — 它会与 messages.tts 深度合并。
{
tts: {
provider: "elevenlabs",
elevenlabs: {
voiceId: "pMsXgVXv3BLzUgSXRplE",
modelId: "eleven_multilingual_v2",
},
},
}
注意事项:
- Edge TTS 在语音通话中被忽略(电话音频需要 PCM;Edge 输出不可靠)。
- 启用 Twilio 媒体流时使用核心 TTS;否则通话回退到提供商原生语音。
更多示例
仅使用核心 TTS(无覆盖):
{
messages: {
tts: {
provider: "openai",
openai: { voice: "alloy" },
},
},
}
仅为通话覆盖为 ElevenLabs(其他地方保持核心默认):
{
plugins: {
entries: {
"voice-call": {
config: {
tts: {
provider: "elevenlabs",
elevenlabs: {
apiKey: "elevenlabs_key",
voiceId: "pMsXgVXv3BLzUgSXRplE",
modelId: "eleven_multilingual_v2",
},
},
},
},
},
},
}
仅为通话覆盖 OpenAI 模型(深度合并示例):
{
plugins: {
entries: {
"voice-call": {
config: {
tts: {
openai: {
model: "gpt-4o-mini-tts",
voice: "marin",
},
},
},
},
},
},
}
呼入通话
呼入策略默认为 disabled。要启用呼入通话,请设置:
{
inboundPolicy: "allowlist",
allowFrom: ["+15550001234"],
inboundGreeting: "Hello! How can I help?",
}
自动响应使用 agent 系统。使用以下选项调整:
responseModelresponseSystemPromptresponseTimeoutMs
CLI
openclaw voicecall call --to "+15555550123" --message "Hello from OpenClaw"
openclaw voicecall continue --call-id <id> --message "Any questions?"
openclaw voicecall speak --call-id <id> --message "One moment"
openclaw voicecall end --call-id <id>
openclaw voicecall status --call-id <id>
openclaw voicecall tail
openclaw voicecall expose --mode funnel
Agent 工具
工具名称:voice_call
操作:
initiate_call(message, to, mode?)continue_call(callId, message)speak_to_user(callId, message)end_call(callId)get_status(callId)
此仓库在 skills/voice-call/SKILL.md 中附带了匹配的技能文档。
Gateway RPC
voicecall.initiate(to?,message,mode?)voicecall.continue(callId,message)voicecall.speak(callId,message)voicecall.end(callId)voicecall.status(callId)