-
-
Save airbornelamb/a1e5d4d19e0a0a4b55e2cd8c7b8c1174 to your computer and use it in GitHub Desktop.
Voice mail system using Twilio Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = function(context, event, callback) { | |
let twiml = new Twilio.twiml.VoiceResponse(); | |
const OWNER = '+1##########'; //Your mobile number. | |
if(event.From == OWNER){ | |
const gather = twiml.gather({ | |
action:'/callOut' | |
}); | |
gather.say("Please enter the phone number you'd like to call followed by the pound sign."); | |
} else { | |
twiml.sms({from:'+1##########', to:'+1##########'}, `You received a call from ${event.From}.`); //from = Twilio phone number. to = your mobile number. | |
dial = twiml.dial({ | |
callerId:'+1##########', //Your Twilio phone number. | |
action:'/vmail' | |
}); | |
dial.number({ | |
url:'/whisper' | |
}, OWNER); | |
} | |
callback(null, twiml); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = function(context, event, callback) { | |
let twiml = new Twilio.twiml.VoiceResponse(); | |
dial = twiml.dial({ | |
callerId:'+1##########' //Your Twilio number. | |
}); | |
dial.number("+"+event.Digits); | |
callback(null, twiml); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Response /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = function(context, event, callback) { | |
let twiml = new Twilio.twiml.VoiceResponse(); | |
if(event.Digits && event.Digits === null ){ | |
twiml.hangup(); | |
} else { | |
twiml.say("Your call is now being connected."); | |
} | |
callback(null, twiml); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = function(context, event, callback) { | |
let twiml = new Twilio.twiml.VoiceResponse(); | |
if (event.DialCallStatus === "completed" || event.DialCallStatus === "answered") { | |
twiml.hangup(); | |
} | |
//Change this to reflect your own personal message. | |
twiml.say("You have reached my voice mail. Please leave a message."); | |
//Or use play to play a recorded message | |
//twiml.play("https://your-url.io/voicemail.mp3"); | |
twiml.record({ | |
action: "empty-response.xml", //Use a link to a TwiML Bin for this value. | |
method: "GET", | |
maxLength: "200", | |
recordingStatusCallback: "/vmlink" | |
}); | |
twiml.sms({from:'+1##########', to:'+1##########'}, `The last caller did not leave a VMail.`); | |
callback(null, twiml); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = function(context, event, callback) { | |
if (event.RecordingStatus && event.RecordingStatus === 'completed' && event.RecordingDuration > 3){ | |
context.getTwilioClient().messages.create({ | |
to: '+1##########', //Your mobile number. | |
from: '+1##########', //Your Twilio number. | |
body: `The previous missed call left you a voice mail. Duration: ${event.RecordingDuration} secs. Tap the link to listen: ${event.RecordingUrl}.mp3`}) | |
.then(msg => { | |
callback(null, msg.sid); | |
}).catch(err => callback(err)); | |
} else { | |
context.getTwilioClient().messages.create({ | |
to: '+1##########', //Your mobile number. | |
from: '+1##########', //Your Twilio number. | |
body: `The last caller did not leave a VMail.`}).then(msg => { | |
callback(null, msg.sid); | |
}).catch(err => callback(err)); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = function(context, event, callback) { | |
let twiml = new Twilio.twiml.VoiceResponse(); | |
let gather = twiml.gather({ | |
action: "/gather-results", | |
numDigits: "1", | |
timeout: "10" | |
}); | |
gather.say({loop:"2"}, 'You have an incoming call. Press any number key to accept the call, or hang up to send the caller to voice mail.'); | |
twiml.hangup(); | |
callback(null, twiml); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment