问题描述
我们有一个 Windows 服务,可以自动发送多个语音电话来进行约会提醒。
var call = CallResource.Create(
machineDetection: "DetectMessageEnd",asyncAmd: "true",twiml: new Twiml(message),to: new PhoneNumber(toPhone),from: new PhoneNumber(FromPhone));
上面使用的消息是使用下面的 Twiml 动态生成的。
<Response>
<Pause length="1"/>
<Say voice="alice">Hello {name},</Say>
<Pause length="1"/>
<Say voice="alice">Your appointment is scheduled for {date} at {time}.</Say>
<Pause length="1"/>
<Gather timeout="3" numDigits="1" action="https://6f8137e0cb9a.ngrok.io/Voice/gather?aid=12345" method="GET">
<Say voice="alice">To confirm this appointment press 1,to cancel press 2,or you may hang up.</Say>
</Gather>
</Response>
它工作正常,当接听电话时,但如果没有应答,则转到语音信箱时。我想发送一个不同的 Twiml,如下所示
<Response>
<Pause length="1"/>
<Say voice="alice">Hello {name},</Say>
<Pause length="1"/>
<Say voice="alice">Your appointment is scheduled for {date} at {time}.</Say>
<Pause length="1"/>
<Say voice="alice">To confirm or cancel this appointment call 18888888888.</Say>
</Response>
这甚至可以用 Twilio 实现吗?
解决方法
这里是 Twilio 开发者布道者。
这绝对有可能!在您的原始脚本中,它显示您正在使用 asyncAmd,这意味着即使机器检测继续进行,您的初始消息也会开始播放。如果检测到机器,则 AMD 会提醒您。
为此,您需要向出站调用提供一个 asyncAmdStatusCallback
parameter,指向一个 URL,当您从 AMD 获得结果时,该 URL 可以接收网络钩子。
该网络钩子将接收参数,包括 CallSid
和您的 AccountSid
,最重要的是 AnsweredBy
参数。为 AMD 使用 DetectMessageEnd
时,AnsweredBy
参数可以是“machine_end_beep”、“machine_end_silence”、“machine_end_other”、“human”、“fax”和“unknown”中的任何一个。
对于机器结果,如果您想留言,现在需要update your call with new TwiML。
var call = CallResource.Update(
twiml: new Twiml(MACHINE_MESSAGE),pathSid: CALL_SID
);
让我知道这是否有帮助。