Created
July 29, 2020 17:17
-
-
Save GeeH/990dec1e28ed07a96545d34784794872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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