Send notification from Google Sheets to Mobile using Pushover (Guide)

Several of my Spreadsheets perform scripts on a timely basis (e.g. monthly) and I want to be notified when this occurs.To acheive this I have written a function in Google Scripts that will send a notificaiton to my mobile via Pushover.

Before starting this guide, create a free account at https://pushover.net/ and download the iOS or Android app on your Mobile.

Create Application in Pushover

  1. Login to Pushover and note down your User Key

  2. Note down your User Key

  3. Scroll to the bottom of the page and select Create an Application/API Token

  4. On the following webpage, enter the following information:
    • Name: Google Sheet Alert
    • Description: An Alert from Google Sheets
    • URL: leave blank
    • Icon: download this image and select it

  5. Fill out the following page

  6. Check the box and select Create Application

  7. Note down your API Token/Key

  8. Note down your API Token/Key

Setup Google Sheets

  1. This script will put data from Sheet1. The title will be in cell A2, and contents of the message in both B2 and C2 as shown in the image below.

  2. Screenshot of Google Sheet

  3. Once Sheet1 is setup as above, select Tools and then Script Editor

  4. Select Tools and then Script Editor

  5. The Script Editor page should open with a single file called Code.gs

The Google Script

Note: For this section, anything that comes after // is a comment, and wont be performed by the script


function Pushover() {

var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName(‘Sheet1’);

//assign the values in A2, B2, and C2 to variables
var title = sheet.getRange(‘A2’).getDisplayValue();
var contents1 = sheet.getRange(‘B2’).getDisplayValue();
var contents2 = sheet.getRange(‘C2’).getDisplayValue();

//setup the Pushover API call
var baseUrl = https://api.pushover.net/1/messages.json";

var parameters = {
‘token’ : ‘API_KEY_HERE’, //paste your API Key between the single quotation marks
‘user’ : ‘USER_KEY_HERE’, //paste your User Key between the single quotation marks
‘title’ : ‘Cell A2 contains: ‘ + title,
‘message’ : ‘Cell B2 contains: ‘ + contents1 + ‘and Cell C2 contains: ‘ + contents2
};

var options = {
‘method’ : ‘POST’,
‘payload’ : parameters
};

//send the Pushover API call
UrlFetchApp.fetch(baseUrl,options);

}

You should now receive a notification on your Mobile similar to the below:

Your Mobile will now receive a notification