Skip to content

Instantly share code, notes, and snippets.

@ChloeCodesThings
Last active March 29, 2019 04:54
Show Gist options
  • Save ChloeCodesThings/4c41eb0fc8399d226edd67629e1ce853 to your computer and use it in GitHub Desktop.
Save ChloeCodesThings/4c41eb0fc8399d226edd67629e1ce853 to your computer and use it in GitHub Desktop.
An Ambivert's Guide to Azure Functions Sample Code- Message Example
const accountSid = process.env.TWILIO_SID;
const authToken = process.env.TWILIO_TOKEN;
const client = require('twilio')(accountSid, authToken);
// This can also be accomplished with a Twilio output binding- you can read more on this at http://aka.ms/AA4n3j3
module.exports = async function (context) {
const twilioOptions = {
from: process.env.SENDER_NUMBER,
body: 'Hey- please call me ASAP. Locked out of apartment ',
to: process.env.RECIPIENT_NUMBER
};
await client.messages
.create(twilioOptions)
.then(message => {
context.log("Message sent");
context.res = {
body: "Text successfully sent"
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment