Using a Garmin Inreach to receive automated news/rss/reddit content at sea

We opted to increase our Garmin Inreach plan to “unlimited messages” for our Atlantic crossing in order to keep in touch and receive our FastSeas weather routing.

(Speaking of unlimited messages, please feel free to send us a message from our map page any time while we’re at sea!) share.garmin.com/speck

With unlimited messages, this got us thinking how nice it would be to have world news/reddit/inspirational quotes sent to us automatically while at sea.

Here’s the solution we found:

Using the free web service “If This Then That” (IFTTT), we can automatically check websites like BBC, Reddit, and RSS feeds for updated content.

When an update is found in one of these sources, IFTTT sends an email with the content to a gmail address.

When the email is received, Gmail applies a label to the email.

Using Google Apps Script, we can have Google search through these labeled emails and strip out the text we want to send to the Inreach (just the title of each post to keep each message under the 160 character sms limit). This script can be set to run once per minute. (See update and code at bottom of page). A special thank you to ismailzai.com where the inspiration for this script came from.

The script then sends an email to an existing Google Voice <> Inreach message thread.

This delivers the message to the Inreach and syncs to the Earthmate iOS app with just the content we are looking for. Excellent!

World News, Inspirational Quotes, r/TodayILearned while at sea!

Update: be careful about how many automated messages you send to your Inreach. It is possible to back up your Inreach inbox causing subsequent inbound messages to be delayed (in our testing, a message is delivered to the Inreach one every 10-13 minutes). To avoid this issue, we have switched to a request based model.

This involved reworking the Gmail Labels and the Google code. See updated code below.

Show full script code


//This script was created and adapted to search for a "request" email, then sends a number of news emails/sms to a google voice/garmin inreach device
//I made a separate gmail account for this project, just in case.
//Make sure a collection of "content" emails are labeled as the "gmailMessageLabel" - in this example, "InreachMessage", and that a filter is set in gmail to categorize "inreachRequest" labels

function parseEmailByLabel() {
  var gmailRequestLabel = "InreachRequest",
        gmailMessageLabel = "InreachMessage",
        gmailParsedLabel = "sentToInreach",
        gmailRequestObject = GmailApp.getUserLabelByName(gmailRequestLabel),
        gmailMessageObject = GmailApp.getUserLabelByName(gmailMessageLabel),
        gmailParsedLabelObject = GmailApp.getUserLabelByName(gmailParsedLabel),
        threadsRequest = gmailRequestObject.getThreads(),
        threadsMessages = gmailMessageObject.getThreads(),
        messages,
        numberToSend,
        message,
        inreachAddress,
        newBody;
  
  Logger.log("Starting");

  if (threadsRequest) {
    // handle each thread (see https://developers.google.com/apps-script/reference/gmail/gmail-thread)
        for (var i = 0; i < threadsRequest.length; i++) {
            messages = threadsRequest[i].getMessages();
            // handle the most recent message (see https://developers.google.com/apps-script/reference/gmail/gmail-message)
             message = messages[(messages.length)-1];
                
            //get body, strip out just text we want, forward to imreach address
              
              inreachAddress = message.getFrom();
              Logger.log("found return address:");
              Logger.log(inreachAddress);
              
              
              newBody=message.getPlainBody();
            // Logger.log(newBody);
              
              var splitBody = newBody.split('\n'); // This will become an array now
              
              //send an email containing the content to the inreach google voice conversation thread
              numberToSend = splitBody[2];
              Logger.log(numberToSend);
              message.markRead();
            
          
            // remove the label on the thread and archive
           threadsRequest[i].removeLabel(gmailRequestObject);
           threadsRequest[i].addLabel(gmailParsedLabelObject);
           threadsRequest[i].moveToArchive();
          
        }
    if (threadsRequest.length == 0){
      Logger.log("no request found");
    }
  }
  
  Logger.log("-------");
  Logger.log("number to send:");
  Logger.log(numberToSend);
  Logger.log("-------");
    
  if (numberToSend){
    if (numberToSend<10){
      if (threadsMessages) {
        // handle each thread (see https://developers.google.com/apps-script/reference/gmail/gmail-thread)
        for (var i = 0; i < numberToSend; i++) {
            messages = threadsMessages[i].getMessages();
            // handle each message (see https://developers.google.com/apps-script/reference/gmail/gmail-message)
              
          
              message = messages[0];
              
              //get body, strip out just text we want, forward to imreach address
              
              newBody=message.getPlainBody();
            // Logger.log(newBody);
              
              var splitBody = newBody.split('\n'); // This will become an array now
              
              //send an email containing the content to the inreach google voice conversation thread
              
              MailApp.sendEmail(inreachAddress,
                  "",
                  splitBody[2]);
                  
              Logger.log("Sent:");
              Logger.log(splitBody[2]);
                // mark the message as read
                message.markRead();
            
            // remove the label on the thread and archive
           threadsMessages[i].removeLabel(gmailMessageObject);
           threadsMessages[i].addLabel(gmailParsedLabelObject);
           //threadsMessages[i].moveToArchive();
           Utilities.sleep(1000);
        
          }
        }
    }
  }
}