Skip to content

Instantly share code, notes, and snippets.

@jlengstorf
Created February 19, 2021 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlengstorf/470c02e1909e5c473ba7400935ee51c2 to your computer and use it in GitHub Desktop.
Save jlengstorf/470c02e1909e5c473ba7400935ee51c2 to your computer and use it in GitHub Desktop.
An example of a serverless function that sends an SMS message using Twilio (deployable to Netlify Functions).
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
exports.handler = async () => {
const response = await client.messages.create({
// RIP Mitch Hedberg
body: 'Is a hippopotamus a hippopotamus... or a really cool opotamus?',
from: '+15552888588',
to: '+15558675309',
});
return {
statusCode: 200,
body: JSON.stringify(response),
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment