top of page
Google Sheets Integration

Google Sheets Integration

Manage phonebook data in a Google Sheet using the google-sheets-integration Velo package

Intermediate.png

Intermediate

8K

Published:

March 9, 2021

Girl Enjoying her Drink

by

Anchor 1
Hire a Developer

Example Description

In this example, we used the Google Sheets integration Velo package to interact with a Google spreadsheet. Using input elements on the site, you can add a name and phone number to a spreadsheet or get and display the phone number associated with a name listed in the sheet.

 

For more information about this Velo Package, please see the Readme in the package folder located in the Code Files section of your site.

Example Code

Tab 1

.

Tab 2

.

Tab 3

.

This code solution can be complicated.

How We Built It

We installed the Velo package on our site, and followed the steps described in the Setup section of the package’s readme file.


Page Elements

 

We added the following elements to our site:


  • 2 text inputs for entering the name and phone number to add to the sheet.

  • Button to trigger the addition.

  • Text element to enter the name whose phone number you want to get.

  • Button to trigger the get.

  • Text element for displaying the retrieved phone number and validation messages.

 


Code

 

We added the following code to a web module (.jsw file) on the backend of our site:


  1. Import the wix-secrets-backend module to work with secrets from the Secrets Manager .

  2. Import the getValues() and appendValues() functions from the Velo package.

  3. Define the range of the Google spreadsheet.

  4. Add a function to get a phone number from the sheet: Validate the name passed to the function, get the Google Sheet ID from the Secrets Manager, use the getValues() package function to loop through the names in the sheet, and if the name exists in the sheet return the phone number associated with the name.

  5. Add a function to append a phone entry to the sheet: Validate the input values, get the Google Sheet ID from the Secrets Manager, and use the appendValues() package function to add the new name and phone number to the sheet.

 

We added the following to our page code:


  1. Import the wrapper functions from the web module.

  2. When a site visitor enters a name and phone number and clicks the Add button, collapse the message text, call the backend function to append the data to the sheet, clear the input values, and show a success or error message.

  3. When a site visitor enters a name and clicks the Get button, collapse the message text, call the backend function to get the associated phone number, and display the retrieved number or an error message.

APIs We Used

Non-code example.

Non-code example.

Non-code example.

Related Articles

Hire a Developer

Velo solutions are powerful tools, but building them on your own can be challenging. Let an experienced Velo development shop build it for you, so you can keep working on your site or business.

Related Examples

Did this help?

Yes

|

No

Thanks for your feedback!

Salesforce Integration

Salesforce Integration

Manage account data records in Salesforce using the salesforce-integration Velo package

Intermediate.png

Intermediate

Twitter Integration

Twitter Integration

Tweet and get the latest tweet using the twitter-integration Velo package

Intermediate.png

Beginner

Twilio SMS Integration

Twilio SMS Integration

Integrate with Twilio to send SMS messages

Intermediate.png

Intermediate

Anchor 2
bottom of page