So, I am not very familiar with this so I am a little confused. I'm trying to use Twilio Functions to create a function that posts an incoming sms message to a third-party API. In general, how would I go about that?
This is what i have right now
exports.handler = function(context, event, callback) {
var got = require('got');
var data = event.Body;
console.log("posting to helpscout: "+requestPayload);
got.post('https://api.helpscout.net/v1/conversations.json',
{
body: JSON.stringify(data),
'auth': {
'user': process.env.API_KEY,
'pass': 'x'
},
headers: {
'Content-Type': 'application/json'
},
json: true
})
.then(function(response) {
console.log(response.body)
callback(null, response.body);
})
.catch(function(error) {
callback(error)
})
}