I am trying to send and receive SMS through Google Apps Script (GAS). GAS doesn't provide native support for sending text messages or checking Google Voice, so I have been looking at integrating with third party APIs - in this case Twilio.
I've been in touch with tech support at Twilio and they haven't been able to answer the question yet. I have also looked far and wide and have not found a functioning GAS example that works with Twilio successfully.
I followed the tutorial at https://developers.google.com/live/shows/11404657/. Then copied a non-functioning code example from the Google Apps Script team that parallels the code in the tutorial: https://github.com/entaq/GoogleAppsScript/blob/master/Twilio/RecieveSMS/RecieveSMS.gs -
My code is copied below:
The second last command, appendrow() works fine, implying that GAS GETs from the Twilio API correctly. The last command, createTextOutput(), however, does not work, which suggests GAS is unable to POST to Twilio in the right format... right?
function doGet(args) {
var spreadsheetID = "<< your spreadsheet ID >>";
var vote = args.parameter.Body;
var from = args.parameter.From;
var actualVote;
switch (vote.toLowerCase()) {
case "a":
actualVote = 'Giants';
break;
case "b":
actualVote = 'Jets';
break;
default:
actualVote = 'Dont care';
}
SpreadsheetApp.openById(spreadsheetID).appendRow([from,actualVote,vote]);
return ContentService.createTextOutput(LanguageApp.translate(args.parameter.Body, "en", "es")).setMimeType(ContentService.MimeType.TEXT);
};
I would be happy to use a workaround (email to SMS for example) BUT I have to both send and receive SMS AND I don't want to have to transfer over to another programming platform as we have already spent 4 months developing our internal operations software through Google Apps Script so the transfer over would be very onerous.
NOTE that this is not a problem with "chunked" XML responses - as was found in this thread: Connect Twilio wtih Google Apps Script - Twilio tech team told me yesterday that they upgraded their servers very recently to accept chunked responses.
Thanks!
