Skip to content

Instantly share code, notes, and snippets.

@madisp
Created January 22, 2019 12:57
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 madisp/dffdb0cec7e21c275eced8e43054b2a4 to your computer and use it in GitHub Desktop.
Save madisp/dffdb0cec7e21c275eced8e43054b2a4 to your computer and use it in GitHub Desktop.
Twilio SMS forward to Fleep
const convoUrl = 'https://fleep.io/hook/XYZ'; // incoming webhook URL from convo integrations
const got = require('got');
exports.handler = function(context, event, callback) {
console.log(`Incoming msg from ${event.From} body: ${event.Body}`)
got.post(convoUrl, {
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
'message': event.Body,
'user': `${event.From} (Twilio)`
})
})
.then(response => {
console.log("Message success");
let twiml = new Twilio.twiml.MessagingResponse();
callback(null, twiml);
})
.catch(err => {
console.log("Message failure");
console.log(err);
callback(err);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment