Skip to content

Instantly share code, notes, and snippets.

@GeeH
Created July 29, 2020 17:17
Show Gist options
  • Save GeeH/990dec1e28ed07a96545d34784794872 to your computer and use it in GitHub Desktop.
Save GeeH/990dec1e28ed07a96545d34784794872 to your computer and use it in GitHub Desktop.
--- incoming function ---
const got = require('got');
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.MessagingResponse();
const message = event.Body;
const url = 'https://geeh.ngrok.io?move=' + message;
got('https://geeh.ngrok.io?move=' + message, {json: true}).then(response => {
twiml.message(response.body.result);
callback(null, twiml);
}).catch(error => {
console.log(error.response.body);
callback(error);
});
};
--- outgoing function ---
exports.handler = function(context, event, callback) {
context.getTwilioClient().messages.create({
to: 'whatsapp:+447446188852',
from: 'whatsapp:+14155238886',
body: 'You haven\'t played games with me in ages :('
}).then(msg => {
callback(null, msg.sid);
}).catch(err => callback(err));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment