Google Sheets is a Cloud-based Spreadsheet application that allows you to store and organize different types of information in the form of Spreadsheets. Google Sheets supports App Scripting, which allows users to automate their Spreadsheets in various ways. Google Sheets offers the ability to deploy your script as a Web App as one of its features.

When you deploy your script as a web app, you’ll have a URL to which you can make GET or POST requests to initiate your script. You can then receive POST requests using this Google Sheets feature without needing a custom piece of infrastructure that makes it easier to process data from Webhooks

Upon a complete walkthrough of this article, you will learn about the steps involved in building Google Sheets Webhooks Integration in a seamless manner. Read along to learn more about Google Sheets Webhook Integration!

Prerequisites

  • Basic understanding of Spreadsheets.

Steps to Set up Google Sheets Webhooks Integration

Building up Google Sheets Webhooks Integration is a three step process that enables the users to send data from Google Sheets on any event change. Follow the steps given below to set up Google Sheets Webhooks Integration:

Download the Whitepaper on Automating Data Integration
Download the Whitepaper on Automating Data Integration
Download the Whitepaper on Automating Data Integration
Learn the key benefits of automating Data Integration

Step 1: Create and Configure a New Document

The first step involved in setting up Google Sheets Webhooks Integration requires you to create a new script. To build Google Sheets Webhooks Integration, you must first create a new document. Follow the steps given below to create and configure a Google Spreadsheet file:

  • Navigate to your Google Sheets account and select the option Blank to create a new Spreadsheet.
Google Sheets Webhooks - Blank Spreadsheet
Source: Self
  •  Populate the fields in your Spreadsheet.
Google Sheets Webhooks - Populating Fields
Image Source
  • Now, select the option Tools from the Toolbar menu and then click on Script Editor.
Google Sheets Webhooks - Script Editor
Image Source
  • Once you click on the Script Editor option, a new text editor will open up where you can insert any type of script of your own.
  • Paste the following piece of code in the Script Editor. It will just return rows 2-10 as JSON.
function doGet(e) {
var ss = SpreadsheetApp.getActive();
var rng = ss.getActiveSheet().getRange(2, 1, 10, 3)
var vals = rng.getValues()
Logger.log(vals)
return ContentService.createTextOutput(JSON.stringify(vals)).setMimeType(ContentService.MimeType.JSON);
}
function doPost(e) {
return HtmlService.createHtmlOutput(“post request received”);
}
  • Don’t forget to save the document once you have pasted the above code successfully. The final result will look something like the following:
Google Sheets Webhooks - Custom Script
Source: Self

Step 2: Publish Your Script

Once you have created the script, the second step in setting up Google Sheets Webhooks Integration requires you to deploy your script as a web app. Follow the steps to do so:

  • Click on the Publish button in the top bar and select the option Deploy as Web App to publish your script.
  • It is critical that you select “Anyone, even anonymous” in the “Who has access to the app” field on the newly appeared screen to make your data public. 
  • Now click on the Deploy button to publish the script.
  • Once you click on the Deploy button, a new pop-up window will appear which will provide you with the web app link.
Web App URL for Google Sheets Webhooks Integration
Image Source
  • This link will redirect you to a page that will contain all the JSON data fetched by your script.
Google Sheets Webhooks - JSON data
Image Source

Step 3: Create a Webhook

The final step involved in setting up Google Sheets Webhooks Integration requires you to create a new Webhook. There are numerous third-party tools available on the Internet that can be used to create a new Webhook or you can create a Custom Function in Google Sheets to leverage its functionalities to create a new Webhook. Follow the steps given below to create a new Webhook:

  • Navigate back to the Script Editor and paste the code given below to create your own custom function.
function currentTime() {
var d = new Date();
var currentTime = d.toLocaleTimeString()
return currentTime;
}
function CELL_CHANGED(row) {
var options = {
'method' : 'post',
'payload’ : JSON.stringify(row)
};

UrlFetchApp.fetch('http://requestbin.net/r/1hqonni1', options);
return "UpdatedAt: "+ currentTime()
}
  • This Custom Function will get triggered whenever there is a change in the input data.
  • You can now modify the sheet to include a call to the function that returns the entire row.
Google Sheets Webhooks - Return Message
Image Source
  • If you see a successful return message from the function, it means that the Webhook has been sent with the row data as an array. If you bake validation into your script, you can return a useful error message to the user, explaining why some of the input data is invalid, preventing bad data from ever reaching your Webhook.

Once you follow all the above instructions in the correct sequence, you will be able to set up Google Sheets Webhooks Integration in no time!

Simplify Google Sheets & Webhooks ETL & Data Integration using Hevo’s No-code Data Pipeline

Hevo is the only real-time ELT No-code Data Pipeline platform that cost-effectively automates data pipelines that are flexible to your needs. With integration with 150+ Data Sources (40+ free sources), we help you not only export data from sources & load data to the destinations but also transform & enrich your data, & make it analysis-ready.

Start for free now!

Get Started with Hevo for Free

Conclusion

This article provided you with a step-by-step guide on how to set up Google Sheets Webhooks Integration successfully. It also provides in-depth knowledge about the concepts behind every step to help you understand and implement them efficiently.  If you want to integrate data from various data sources such as Google Sheets into your desired Database/destination for free and seamlessly visualize it in a BI tool of your choice, Hevo Data is the right choice for you! It will help simplify the ETL and management process of both the data sources and destinations.

Visit our Website to Explore Hevo

Hevo Data provides its users with a simpler platform for integrating data from 150+ sources such as Google Sheets for Analysis. Hevo also allows integrating data from non-native sources using its in-built Webhooks Connector. It is a No-code Data Pipeline that can help you combine data from multiple sources. You can use it to transfer data from multiple data sources into your Data Warehouse, Database, or a destination of your choice. It also provides you with a consistent and reliable solution to manage data in real-time, ensuring that you always have Analysis-ready data in your desired destination.

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at our unbeatable pricing that will help you choose the right plan for your business needs!

Share your experience of learning about Google Sheets Webhooks Integration! Tell us in the comments section below!

mm
Former Research Analyst, Hevo Data

Rakesh is a Cloud Engineer with a passion for data, software architecture, and writing technical content. He has experience writing articles on various topics related to data integration and infrastructure.

No-code Data Pipeline for Google Sheets