我正在尝试实现Twilio功能,以(1)将呼叫转接到我的个人电话,(2)在发送“提示”短信之前,以及(3)在连接前说悄悄话。我已经能够设置Twilio来执行前面3件事中的任何2件事,但不能同时做这3件事!
exports.handler = function(context, event, callback) {
// Get an initialized Twilio API client
const client = context.getTwilioClient();
twilioClient.messages.create({
to: 'PERSONAL_PHONE',
from: 'TWILIO_PHONE',
body: 'Incoming!!!'
}).then(function() {
const twiml = new Twilio.twiml.VoiceResponse();
twiml.dial.number({ url: WHISPER_URL }, 'PERSONAL_PHONE');
callback(null, twiml);
});
};
实现此功能时,它将发送SMS,但呼叫永不连接(主叫方听到错误消息)。
非常感谢您在这里上一堂课:)
谢谢!
答案 0 :(得分:0)
顺便说一句,我找到了解决方法:
exports.handler = function(context, event, callback) {
// Get an initialized Twilio API client
const client = context.getTwilioClient();
twilioClient.messages.create({
to: 'NUMBER',
from: 'TWILIO_PHONE',
body: 'Incoming!!!'
}).then(function() {
const twiml = new Twilio.twiml.VoiceResponse();
const dialobj = twiml.dial();
dialobj.number({url:'WHISPER_URL'},'NUMBER');
callback(null, twiml);
});
};