> For the complete documentation index, see [llms.txt](https://docs.sprinthub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sprinthub.com/en/topics/analyze/integrated-webhooks/integrated-webhooks-common-questions/integrated-webhooks-how-to-connect-a-google-sheet-spreadsheet-to-sprinthub.md).

# Integrated Webhooks - How to connect a Google Sheet spreadsheet to Sprinthub

<figure><img src="/files/01e5138eecf028662b65f9a999182ba86895d7d1" alt=""><figcaption></figcaption></figure>

### Steps **to Connect a Google Sheets Spreadsheet to Sprinthub via Webhooks to send data to Sprinthub**

Here are the basic steps to set up this integration:

#### Pre**paration of the Google Sheets Spreadsheet:**

* Make sure the spreadsheet contains the necessary data to feed Sprinthub, such as lead details like Name, Lastname, email, and WhatsApp.

<figure><img src="/files/bf924945cc706d560aba1e8a0b314bc4ff4ee6b0" alt=""><figcaption></figcaption></figure>

#### C**onfiguration of the Webhook in Sprinthub:**

* Access Sprinthub and go to the Webhook settings; for the integration, we must leave it as follows:

<figure><img src="/files/18d28d64d31875b62c7a088dced681ef1f64b456" alt=""><figcaption></figcaption></figure>

* First, it is necessary to create the keyword to connect the webhook, for example:

```javascript
 'https://sprinthub-api-master.sprinthub.app/api/hook/google-sheets?i=g4&access_token=tdtcX1Hrw5MmTzQiLVA8_AtMA6H-FYA-uM_gnoYPVLS25A4VNT'
```

* Request body: What you want to receive from your spreadsheet, in our case Name, lastname, email, and whatsapp.

{% hint style="info" %}
Remember to include the identifiers so there are no duplicate leads.
{% endhint %}

<figure><img src="/files/012bb937341f2fdf91c32d07037e454c58d90085" alt=""><figcaption></figcaption></figure>

* Automatic lead creation enabled with the tokens to perform the creation.

<figure><img src="/files/06e5a3c1973c92cc7e7f3c73df4e620da2c4ea85" alt=""><figcaption></figcaption></figure>

#### Configura**tion of the Google Sheets Spreadsheet:**

* Open the spreadsheet and navigate to "Extensions" > "Apps Script". A screen will open where you can put your script for how the data will be sent to the webhook.

<figure><img src="/files/d9129d9b8f0e146973246620e45e88dab55df7bc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/d958573276422841e8036b36efd477c4c33efb5e" alt=""><figcaption></figcaption></figure>

* In the Script Editor, write a function that will be triggered whenever a new row is added to the spreadsheet. This function can be configured to send a POST to the Sprinthub webhook URL, with the relevant project data.

<figure><img src="/files/65c85f89c4b032f3eca7a8641d428958354b2677" alt=""><figcaption></figcaption></figure>

Below is the example code:

<pre class="language-javascript"><code class="lang-javascript"><strong>function enviarDadosParaWebhook() {
</strong>  var url = 'https://sprinthub-api-master.sprinthub.app/api/hook/google-sheets?i=g4&#x26;access_token=tdtcX1Hrw5MmTzQiLVA8_AtMA6H-FYA-uM_gnoYPVLS25A4VNT';

  var planilha = SpreadsheetApp.getActiveSpreadsheet();
  var abaAtiva = planilha.getSheetByName('Leads '); 

  if (!abaAtiva) {
    Logger.log('The specified sheet was not found.');
    return;
  }

  var dados = abaAtiva.getDataRange().getValues();

  // Remove the header row
  dados.shift(); // Removes the header

  // Filter empty or incomplete rows
  dados = dados.filter(function(row) {
    // Check if all fields are filled (assuming that name, lastname, email, and whatsapp are in the first four columns)
    return row[0] !== '' &#x26;&#x26; row[1] !== '' &#x26;&#x26; row[2] !== '' &#x26;&#x26; row[3] !== '';
  });

  // Logging for debugging
  Logger.log('Filtered data:', dados);

  // Preparing the data to send in the payload
  var payload = {
    'dados': dados.map(function(row) {
      return {
        'name': row[0],
        'lastname': row[1],
        'email': row[2],
        'whatsapp': row[3]
      };
    })
  };

  // Logging for debugging
  Logger.log('Sent payload:', payload);

  var options = {
    'method' : 'post',
    'contentType': 'application/json',
    'payload' : JSON.stringify(payload),
    'muteHttpExceptions': true  
  };
  }
</code></pre>

#### Testing and Debugging

* After testing and debugging the integration, and verifying that everything is correct. Run it and check whether the call was made in Sprinthub.

<figure><img src="/files/22627017f644c51ea09dcd8857a8b17b99f291c5" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/ec531b5c7417f133dfd3b16b81db2922779d5b1b" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/52ff53668f3d051d6f4ce5cc564025b6668d68c6" alt=""><figcaption></figcaption></figure>

* With the webhook successfully connected, we can add triggers, where editing the spreadsheet will be sent to the files for the webhook:

{% hint style="warning" %}
Disable automatic saving; with it enabled, any row added will be POSTed to the webhook.
{% endhint %}

<figure><img src="/files/9ca042af5d3c988e0fff5093d96337c737546df9" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/b0938a697f9e32114fab74c319423b5f964569be" alt=""><figcaption></figcaption></figure>

* Be attentive to adjustments or improvements that may be necessary based on practical use.

<figure><img src="/files/1508d6c2e9a2a4ca2507852f004a65ad5801e1fd" alt=""><figcaption></figcaption></figure>

**Conclusion**

Integrating a Google Sheets spreadsheet with Sprinthub through webhooks not only simplifies the workflow, but also improves accuracy and efficiency in project management. With the proper automation, you can transform the way your teams collaborate and carry out tasks, making the most of the capabilities of these powerful productivity and management tools.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sprinthub.com/en/topics/analyze/integrated-webhooks/integrated-webhooks-common-questions/integrated-webhooks-how-to-connect-a-google-sheet-spreadsheet-to-sprinthub.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
