基于the documentation for the TwiML <Leave>
verb,当呼叫者退出队列时,他们的呼叫应在导致他们进入队列的<Enqueue>
之后继续执行呼叫逻辑。就我而言,我的呼叫者通过处理以下TwiML进入队列:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Enqueue>business</Enqueue>
<Say>Sorry, no one is currently available. Please leave a message.</Say>
<Record action="${endpoint}/hangup" timeout="10" transcribeCallback="${endpoint}/voicemailHandler"/>
</Response>
稍后,我正在执行以下Javascript逻辑来触发从队列中删除成员:
await twilioClient
.queues(queueSid)
.members('Front')
.update({url: `${endpoint}/leave`})
/leave
端点将成员定向到TwiML的以下位:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Leave />
</Response>
我遇到了一个问题,一旦执行Javascript,而不是听到<Say>
,呼叫就结束了,呼叫者被断开了。我是否误解了文档?如果是这样,我应该如何重组我的逻辑以获得我想要的结果?
答案 0 :(得分:0)
如艾伦所说,您将需要指定一个waitUrl来处理您的呼叫并发送请假指令。
例如,您可以将waitUrl设置为Twilio Function,以检查呼叫是否在工作时间内进行,如博客文章here所示,TwiML如下所示:< / p>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Enqueue waitUrl="https://zaffre-zorse-5224.twil.io/queue">support</Enqueue>
<Say>Unfortunately, the support line has closed. Please call again tomorrow.</Say>
</Response>
您的Function看起来像这样:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
let moment = require('moment-timezone');
let timezone = event.timezone || 'America/Los_Angeles';
const hour = moment().tz(timezone).format('H');
const dayOfWeek = moment().tz(timezone).format('d');
if ((hour >= 8 && hour < 17) && (dayOfWeek >= 1 && dayOfWeek <= 5)) {
// "open" from 8am to 5pm, PST.
twiml.play('http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3');
} else {
twiml.leave();
}
callback(null, twiml);
};