> ## Documentation Index
> Fetch the complete documentation index at: https://help.treble.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Treble.ai Integration with Google Sheets

> Connect your conversations with spreadsheets to automatically save and update data.

Hello!
In this guide you'll learn how to connect **Treble** with **Google Sheets** to **update** and **get variables** from a Google spreadsheet.

This integration allows you to automate data management for your Treble conversations using a Google Sheets spreadsheet as a database.

## Activate the integration

1. Create a spreadsheet in **Google Sheets**.

   *Recommended:* leave it with **public edit permission**.

<Tip>
  If you prefer to keep it private, you'll find the instructions to do so below.
</Tip>

2. In Treble's **Conversation Flow Editor**, click on the puzzle icon <Icon icon="puzzle-piece" iconType="solid" />.

3. Select the **Google Sheets** option.

4. Paste the **URL** of your spreadsheet in the text field.

<img src="https://mintcdn.com/trebleai/Ztu_Dm5jEzojdr31/images/sheets-1.gif?s=32139df7b58be8a528c4847985544bde" alt="Activate sheets integration" width="2368" height="1150" data-path="images/sheets-1.gif" />

## Required format in the sheet

This integration requires your spreadsheet to have the following two columns in the first row:

`country_code` and `cellphone` which are used to identify each user. The following columns are used to get or save information about that user.

<img src="https://mintcdn.com/trebleai/Ztu_Dm5jEzojdr31/images/sheets-2.png?fit=max&auto=format&n=Ztu_Dm5jEzojdr31&q=85&s=5bfc027a6a6536c3b1c0f03ece9ff133" alt="Sheets format" width="500px" data-path="images/sheets-2.png" />

## Query variables from Sheets

To **get a variable** from the spreadsheet, you must use the following format within the conversation:

`sheets_nombre_variable`

For example, if you have a column `name`, you can use the variable `sheets_name` to greet the user:

```text theme={null}
Hello {{sheets_name}}, how are you?
```

<img src="https://mintcdn.com/trebleai/Ztu_Dm5jEzojdr31/images/sheets-3.png?fit=max&auto=format&n=Ztu_Dm5jEzojdr31&q=85&s=9ac1ad9f571605819c99f5b13a6a0466" alt="Query sheets variable" width="400px" data-path="images/sheets-3.png" />

## Save responses in Sheets

To save what the user responds in the conversation, use the same variable format `sheets_nombre_variable`, and check the **"Save response as variable"** option in the flow.

<img src="https://mintcdn.com/trebleai/Ztu_Dm5jEzojdr31/images/sheets-4.png?fit=max&auto=format&n=Ztu_Dm5jEzojdr31&q=85&s=85e13a515ce60158bbc159c00ebfed13" alt="Save sheets variable" width="1710" height="1178" data-path="images/sheets-4.png" />

## Save the response time

If you want to record when a response was saved, create another column with the `time_` prefix

For example:

* If you have the variable `name`, create another column called `time_name`.

Treble will automatically save the date and time when the user responds.

<img src="https://mintcdn.com/trebleai/Ztu_Dm5jEzojdr31/images/sheets-5.png?fit=max&auto=format&n=Ztu_Dm5jEzojdr31&q=85&s=03ebf662a6255cace116ccc66cb2e048" alt="Save response time sheets" width="1124" height="316" data-path="images/sheets-5.png" />

## Sheets with restricted permissions

If you don't want your sheet to be public, you must share it with **Treble's three official email addresses**:

```text theme={null}
treble-sheets@treble-ai.iam.gserviceaccount.com
treble-sheets@treble-ai-2.iam.gserviceaccount.com
treble@treble-ai-sheets.iam.gserviceaccount.com
```

<img src="https://mintcdn.com/trebleai/Ztu_Dm5jEzojdr31/images/sheets-6.png?fit=max&auto=format&n=Ztu_Dm5jEzojdr31&q=85&s=0d15404e16560f99b85d4ff9a3dafa65" alt="Save response time sheets" width="565" height="331" data-path="images/sheets-6.png" />

## Limitations

* **Maximum supported columns**: up to column ZZ.
* **Google Sheets rate limit**:
  * G Suite: 5 requests per second
  * Regular Gmail: 1 request per second

If those limits are exceeded, some data may be lost.
