我正在创建一个使用Twilio客户端的软电话解决方案。
因此,入站由我的服务器端PHP脚本接收,该脚本使用这个Twiml对调用进行排队:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say language="pt-BR">Olá Rodrigo, em breve você será atendido.</Say>
<Enqueue action="http://xxxx/_api/external/twilio/ura_queueaction.php" waitUrl="http://xxxx/_api/external/twilio/ura_wait.php">CAcb486a96ecd4f458ac0287568d122035</Enqueue>
</Response>
……因此,在调用排队之后,调用了我的web钩子,现在我有了这个调用的队列:
QueueSid "QU34063a138b999bfb28c0b732e84a5a7f"
现在,我的内部通知系统通知了我们intranet中的内部用户,因此,使用...so设备对象,我需要将本地“代理”连接到排队的调用……我正在尝试使用以下方法来完成这一任务:
var params = {
To: queuesid
};
if (device) {
device.connect(params);
}
没有返回错误,在控制台和我收到一条消息,呼叫已启动,但立即断开连接.我还尝试将第一个入站调用的callsid作为参数发送,结果相同。
我在互联网上搜索一个可能的“参数”列表,查找device.connect("PARAMS")....found nothing。
这里有好的灵魂能帮我吗?
发布于 2019-07-11 11:49:24
当我启动这个调用时,我将其命名为"queue-"...like:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say language="pt-BR">Olá Rodrigo, em breve você será atendido.</Say>
<Enqueue action="http://xxxx/_api/external/twilio/ura_queueaction.php" waitUrl="http://xxxxx/_api/external/twilio/ura_wait.php">queue-CAdc202422b5cadcda115bb44912920e3e</Enqueue>
</Response>
因此,我将twilio函数代码更改为:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
if(event.To) {
// Wrap the phone number or client name in the appropriate TwiML verb
// if is a valid phone number
//const attr = isAValidPhoneNumber(event.To) ? 'number' : 'client';
re = /^(.*?)-(.*?)+$/;
var myRe = new RegExp(re, "g");
var type = myRe[0];
var destin = myRe[1];
const dial = twiml.dial({
callerId: context.CALLER_ID,
});
if(type == "phone"){
dial['number']({}, destin);
}
if(type == "client"){
dial['client']({}, destin);
}
if(type == "queue"){
twiml.dial().queue(event.To)
}
//dial[attr]({}, event.To);
} else {
twiml.say('Thanks for calling!');
}
callback(null, twiml);
};
/**
* Checks if the given value is valid as phone number
* @param {Number|String} number
* @return {Boolean}
*/
function isAValidPhoneNumber(number) {
return /^[\d\+\-\(\) ]+$/.test(number);
}
但即使如此,我也无法连接到排队的call....any线索?
发布于 2019-07-11 16:46:26
我成功了!
问题确实是关于twilio函数..。在这里,解决方案:
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
if(event.To) {
// Wrap the phone number or client name in the appropriate TwiML verb
// if is a valid phone number
//const attr = isAValidPhoneNumber(event.To) ? 'number' : 'client';
re = /^(.*?)-(.*)+$/;
var myRe = re.exec(event.To);
var type = myRe[1];
var destin = myRe[2];
if(type == "phone"){
const dial = twiml.dial({
callerId: context.CALLER_ID,
record: 'record-from-ringing-dual'
});
dial['number']({}, destin);
}
if(type == "client"){
const dial = twiml.dial({
callerId: context.CALLER_ID,
record: 'record-from-ringing-dual'
});
dial['client']({}, destin);
}
if(type == "queue"){
const dial = twiml.dial({
callerId: context.CALLER_ID,
record: 'record-from-ringing-dual'
});
dial['queue']({url: 'http://xxxx/_api/external/twilio/ura_dequeue.php?queue='+destin}, event.To);
//console.log(myRe);
}
//dial[attr]({}, event.To);
} else {
twiml.say('Thanks for calling!');
}
callback(null, twiml);
};
https://stackoverflow.com/questions/56973468
复制相似问题