我有一个运行中的JS客户端软件电话,可以接受来自拨打Twilio号码的人的来电。 作品:有人-> Twilio号码->网络电话
需要帮助:
我仅使用TwiML函数。这可能吗?
TwiML功能-1个功能令牌,下面1个语音电话-
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';
if(event.To == '+1XXXXXXXXXX')
{
const dial = twiml.dial({
callerId: event.From,
});
dial['client']({}, 'TwiMLDOCI');
console.log("twiml" + twiml.toString());
}
else {
//const dial = twiml.dial({ callerId: context.CALLER_ID, });
//dial[attr]({}, event.To);
}
}
else
{
twiml.say('No dialing To no. found!');
}
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);
}