Google sheet is a very popular and handy application used to store, analyze and process data. If you would to monitor and save web page changes in a Google spreadsheet, you can use Distill’s webhook actions after adding the webpage in your Watchlist.
Here are the steps that you can follow:
Sheet1
). You can also add a header in the first row.Extensions -> Apps Script editor
to open the script editor. Rename the script from “Untitled project” to something suitable. (e.g. “DistillAlertToSheet”).
Remove the current content from the script editor and replace with the following:
function doPost(e) {
var postJSON = e.postData.getDataAsString();
var data = JSON.parse(postJSON);
writeToSheet(data);
if(typeof e !== 'undefined')
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
function writeToSheet(params) {
var ss = SpreadsheetApp.openById("<GOOGLE_SHEET_ID>");
var ws = ss.getSheetByName("<SHEET_NAME>");
// format time in PST. change it to use your own timezone
var ts = Utilities.formatDate(new Date(params.ts), 'PST', "MM/dd/yyyy HH:mm:ss");
// following line saves three fields: timestamp, name, and text
// it can be changed to save custom fields received from Distill
ws.appendRow([ts, params.name, params.text]);
}
Open the spreadsheet and copy its ID as shown below. It is between two forward slashes. Once copied, replace
From the menu bar, click Deploy -> New deployment
. This will open a configuration window.
Web app
to change script’s type.Anyone
.Deploy
.
You will be taken to autorization window. Click on Autorize Access
and proceed. Choose the Google account and click Allow
.
Note down the Web app URL as shown below and click Done
.
Check out: Webhook actions on changes to learn more about how webhooks work in Distill.
Follow these steps to configure the webhook action to send data to the spreadsheet:
Webhook Call
action under Actions
.Enter the URL in Webhook Call
action.
You can create the webhook fields that you want to see in the spreadsheet. Click on the Options
button under Webhook URL to view and edit the fields to be sent to the Web app
created earlier.
By default id
, name
, uri
and text
fields are added. Add ts
(timestamp when page change was found) with {{sieve_data.ts}}
as the value.
Save Options
.
Now you are all set to see the updated web page content in your Google Sheet. As a test, you can add a test monitor for https://www.timeanddate.com/ and check out the data in your Google Sheet after adding the Webhook action.