Skip to main content
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.
If you prefer to keep it private, you’ll find the instructions to do so below.
  1. In Treble’s Conversation Flow Editor, click on the puzzle icon .
  2. Select the Google Sheets option.
  3. Paste the URL of your spreadsheet in the text field.
Activate sheets integration

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.
There’s an optional third column, business_scope_id, for contacts who write in without sharing their phone number. See contacts without a phone number below.
Sheets format

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:
Query sheets variable

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. Save sheets variable

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. Save response time sheets

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:
Save response time sheets

Contacts without a phone number

Since WhatsApp started allowing people to write in using a username, some contacts arrive without a phone number. For those cases Meta provides an identifier called a BSUID, and the Sheets integration supports it. The rule is simple: if there’s a phone number, the row is identified by the phone; when there isn’t, it’s identified by the BSUID.

How it works

  • Treble looks for a column in your sheet named exactly business_scope_id.
  • If it doesn’t exist, Treble creates it automatically the first time a contact without a phone number arrives. There’s nothing to set up in advance.
  • A row counts as valid if it has either a phone number or a BSUID. Rows with neither are treated as empty.
  • When adding a BSUID-only contact, the country_code and cellphone cells are left empty and business_scope_id is filled in.
If Treble can’t create the column — for example because the sheet is shared as read-only — the contact is not added and the row is skipped.If you expect contacts without phone numbers, create the business_scope_id column yourself and make sure the service accounts have edit access (see sheets with restricted permissions).
The column name must be exactly business_scope_id, lowercase.

WhatsApp usernames and BSUID

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.