So I've forked off another component of this idea, and that is to receive confirmation sms that the individual got their schedule via text.
I have it working where upon executing the script, it will gather all the sms received by the Twilio API that day, but what would be really cool is to be able to have it set the value of dataAll.messages adjacent to a column with the name of the individual who the phone number belongs to.
Initially I was thinking another sheet with a set of columns for name/phone number to reference, but maybe it's easier than that.
If I fill columns 1 & 2 (A & B) with a static list of names and phone numbers, could I get the else if segment (or a new loop) to compare dataAll.messages.from to column 2 (or hidden table/other sheet) and then setValue of adjacent columns with the corresponding .date .time. .body ?
// example
var theSheet = SpreadsheetApp.getActiveSheet();
var theRow = 3;
var startColumn = 2;
var dataAll = JSON.parse(response.getContentText());
for (i = 0; i < dataAll.messages.length; i++) {
theColumn = startColumn;
// -------------------------------------
// Date and Time
rowDate = dataAll.messages[i].date_sent;
var theDate = new Date (rowDate);
var today = new Date();
today.setHours(0,0,0,0);
if(isNaN(theDate.valueOf())) {
theDate = 'Not a valid date-time';
theColumn++;
theColumn++;
}
else if (theDate > today) {
theSheet.getRange(theRow, theColumn).setValue(dataAll.messages[i].from);
theColumn++;
theDate.setHours(theDate.getHours()+hoursOffset);
theSheet.getRange(theRow, theColumn).setValue(theDate);
theColumn++;
theSheet.getRange(theRow, theColumn).setValue(theDate);
theColumn++;
theSheet.getRange(theRow, theColumn).setValue(dataAll.messages[i].body);
theRow++
}
// example