I am migrating from Tropo to Twilio. I have a need to send an SMS to a monitored phone number while parsing a voice call (menu system).
The flow should be:
1. Incoming Voice call
2. Function sends SMS to one or more cell phones //alerts there is a voice call
3. Voice IVR system takes over and processes call
Using the Twilio Runtime functions (twilio's hosted node.js) I seem to be unable to combine both of these needs into a single function as the callback looks for a single twiml object. Further I also seem to be unable to send an SMS from within a voice call.
Is there example code anywhere, or is there solid documentation that might help me achieve my goal?
The following code works, but I have been advised by Twilio tech support not to use the SMS verb as its future viability is not guaranteed.
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say("Hello World"); // respond to voice caller
twiml.sms({to:"+19735551212"},"Hello SMS!!"); // send SMScallback(null, twiml);
}