Skip to content

Instantly share code, notes, and snippets.

@kimberleehowley
Created October 3, 2019 22:12
Show Gist options
  • Save kimberleehowley/6c51955f9895c4b9109a6ded7fc1dcc4 to your computer and use it in GitHub Desktop.
Save kimberleehowley/6c51955f9895c4b9109a6ded7fc1dcc4 to your computer and use it in GitHub Desktop.
Responding to a text to a Twilio number from Azure (for Mean Girls Day app)
// We're using Twilio in this app, and getting ready to send a message response
const MessagingResponse = require('twilio').twiml.MessagingResponse;
// We're exporting our function from Azure
module.exports = function (context) {
// Logging what's happening in Azure
context.log('JavaScript HTTP trigger function processed a request.');
// Create a new TwiML response
const response = new MessagingResponse();
// Send a string in that response, in this case, "It's October 3rd"
response.message("It's October 3rd.");
// Log that response to the console
console.log(response)
// The format of the response we're sending back to Twilio
context.res = {
status: 200,
body: response.toString(),
headers: { 'Content-Type': 'application/xml' },
isRaw: true
};
// End the function once executed
context.done();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment