Skip to content

Instantly share code, notes, and snippets.

@kimberleehowley
Last active October 3, 2019 22:22
Show Gist options
  • Save kimberleehowley/445c478f91ac9fb2461287215d6c1fda to your computer and use it in GitHub Desktop.
Save kimberleehowley/445c478f91ac9fb2461287215d6c1fda to your computer and use it in GitHub Desktop.
Playing an audio file in response to a call to a Twilio number from Azure
// Use Twilio in this app
const VoiceResponse = require('twilio').twiml.VoiceResponse;
// Export the function from Azure
module.exports = function (context) {
// Log the response in Azure
context.log('JavaScript HTTP trigger function processed a request.');
// Create a new TwiML response, this time using voice
const twiml = new VoiceResponse();
// Play the secret link that's disguised
twiml.play('https://your-twilio-asset-link-here');
// Let Twilio know what we're responding with
context.res = {
status: 200,
body: twiml.toString(),
headers: {'Content-Type': 'application/xml' },
isRaw: true
};
// We're done!
context.done();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment