Monday 24 February 2014

Google: Send SMS with Google Spreadsheet for FREE!


 Please follow the steps below to send messages with Google Spreadsheet for FREE:

1.  Create a Gmail account by going to https://accounts.google.com/SignUp

2.  Sign-in to the Google account that you have created.

3.  Associate the phone number that you would like to send the SMS for free with Google Calendar as detailed in http://support.google.com/calendar/bin/answer.py?hl=en&answer=45351

4.  Copy the Google sheet titled Send SMS - Andres Cheah into your Google Drive by going to https://docs.google.com/spreadsheet/ccc?key=0AheF94DrPSPgdE1xWnkxREhrald1TjlocVdmUHhGSlE&newcopy=true.

5.  Put your messages in cell B2 and your email address in cell B3.

6.  You’ll find a new Send SMS menu in your Google Spreadsheet toolbar. Click Send and you’ll get a pop-up asking for authorization. Grant the necessary access. ( * Note: This step only needs for the first time. )

7.  Go to the Send SMS menu again and choose “Send” to send the messages. After you have clicked the "Send" button, here are the results that you may observe:
  • There is going to be a pop-up which indicates that you have successfully sent the messages in the Google Spreadsheet.
  • The person with the phone number that you have associated with the Google Calender will receive a SMS with the messages you have typed in the Google Spreadsheet.
  • The date, time and messages are going to be logged in the Google Spreadsheet titled Send SMS.
  • An event with the messages detail is going to be created in the Google Calender.

Google Script:

/**   Send SMS by Andres Cheah                       **/
/**   ============================================   **/

/**   Details at http://mkcheah88.blogspot.com       **/

function onOpen() {
 
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
 
  var menu = [
    {name: "Send", functionName: "init"},
    {name: "✖ Uninstall (Stop GoogleScript)", functionName: "removeJobs"},
    null
  ];
 
  sheet.addMenu("➪ Send SMS", menu);  
}


function init() {  
 
  removeJobs(true);
 
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
 
  var messages = sheet.getActiveSheet().getRange("B2").getValue();
 
  // Setup trigger that runs every 1 minutes
 
  ScriptApp.newTrigger("SendSMS")
  .timeBased()
  .everyMinutes(1)
  .create();
 
  sheet.toast("Your message has been sent successfully. "
              + "Send SMS with Google Spreadsheet again anytime!", "Sent", -1);

  logMessage(messages, " <<Powered by Google SMS>>");

}


function logMessage(message, google) {

  // Log messages in Google Spreadsheet
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var time  = new Date();
 
  sheet.appendRow([time, google + " : " + message]);
 
  var alert = "Text Message: " + message + google;
 
  // Send email to the email address stated in the spreadsheet
  MailApp.sendEmail(sheet.getRange("B3").getValue(), google, alert);
 
  // Send SMS to the phone number registered in Google Calender
    time = new Date(time.getTime() + 15000);
    CalendarApp.createEvent(alert, time, time).addSmsReminder(0);
 
  return;
}


function removeJobs(quiet) {  
 
  PropertiesService.getScriptProperties().deleteAllProperties();
 
  // Delete all Script Triggers
 
  var triggers = ScriptApp.getProjectTriggers();
 
  for (i=0; i<triggers.length; i++) {
    ScriptApp.deleteTrigger(triggers[i]);
  }
 
  // Inform the user, default is "YES"
 
  if (! quiet) {
   
    SpreadsheetApp.getActiveSpreadsheet()
    .toast("The GoogleScript has been stopped. " + "Send SMS with Google Spreadsheet again anytime!", "Stopped", -1);
   
  }  
}



/**   Send SMS by Andres Cheah                       **/
/**   ============================================   **/

/**   Details at http://mkcheah88.blogspot.com       **/

Reference:
1.  Monitor your Website’s Uptime with Google Docs

No comments:

Post a Comment