我正在使用 Python 和 Django 关注 Dynamic Call Center来构建一个简单的Django呼叫中心。我正在处理拨出和来电,如下所示:
@csrf_exempt
def CallTaskRouter(request):
response = VoiceResponse()
if 'phoneNumber' in request.POST:
dial = response.dial(caller_id=TWILIO_NUMBER, answer_on_bridge='true')
dial.number(request.POST['phoneNumber'],
status_callback_event='initiated ringing answered completed',
status_callback='https://my-url/status',
status_callback_method='GET')
else:
response = VoiceResponse()
gather = response.gather(numDigits=1, action='https://my-url/support/enqueue', method="POST")
gather.say("To speak to support, press one.", language='en-US')
gather.say("To speak to sales, press two.", language='en-US')
response.append(gather)
return HttpResponse(
str(response), content_type='application/xml; charset=utf-8'
)
我想在客户的电话“响铃”时通知用户,并且我想在接听电话后启动通话时间计数器。我使用 js 来设置“设备”并像这样发起调用:
device = new Twilio.Device(data.token, {
codecPreferences: ['opus', 'pcmu'],
fakeLocalDTMF: true,
enableRingingState: true,
});
function callCustomer(phoneNumber) {
numberToCall = phoneNumber;
var params = { phoneNumber: phoneNumber};
newConnection = device.connect(params);
newConnection.on('ringing', function(){
initiateCallTime();
console.log('Ringing')
});
};
即使我遵循了文档中的所有查询(answer_on_bridge='true',enableRingingState:true),连接仍以“打开”状态开始(我使用 connection.status() 函数来查找)并且没有想到预期状态值(“待处理”、“连接中”、“正在响铃” ...)
我错过了什么吗?请帮忙