I'd like to be able to send a Sid to a number and have the function used for that number retrieve the information for that Sid. Specifically, I'd like to be able to retrieve the 'from' phone number for that specific SMS message (determined by the Sid). I can't seem to get anything more than the AccountSid and Sid from the fetch call.
What I have so far (modified for simplicity of this question):
exports.handler = function(context, event, callback) {
var Sid = event.Body;
let client = context.getTwilioClient();
// without the 'fetch()' it gets only the AccountSid and Sid, with the 'fetch()' it doesn't seem to get anything?
let promise = client.messages(`${Sid}`).fetch();
var x;
console.log(promise);
// saw that it was returning a promise with the fetch so tried to use it here somehow, but nothing returned or worked
promise.then(m => {
x = m;
});
console.log(x);
// do something, create a response message and send
callback(null, twiml);
};
What am I doing wrong or need to do in order to get the details of the message with the "sid"?