Skip to content

Instantly share code, notes, and snippets.

@Brodan
Last active September 18, 2017 01:09
Show Gist options
  • Save Brodan/288ff0448c9c981cfb9d89c626929f85 to your computer and use it in GitHub Desktop.
Save Brodan/288ff0448c9c981cfb9d89c626929f85 to your computer and use it in GitHub Desktop.
A Twilio Function snippet for handling Travis CI webhook notifications.
exports.handler = function(context, event, callback) {
let travis_payload = JSON.parse(event.payload);
let message_body = `${travis_payload.repository.name} \
failed to build after changes pushed by \
${travis_payload.committer_name}`;
let client = context.getTwilioClient();
client.messages.create({
to: '+15555555555', // Text this number
from: '+15555555555', // From a valid Twilio number
body: message_body
})
.then(message => {
console.log(message.sid);
callback(null, "OK");
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment