⌘I

Send submission to Google Sheets spreadsheet

Updated July 14, 2023 ·
pluginsformspree-cligoogle-sheets
Also available in:

Adding the Google Sheets action in the formspree.json file has the same effect as adding the Google Sheets plugin in the Formspree dashboard.

Get your credentials

To use the Google Sheets plugin through CLI we need to create a service account in the Google Cloud console.

1. Create a service account

Visit the Google Cloud Console ensuring that you are signed into the correct Google account. In the top right you’ll see a list of projects.

mceclip0.png

If you already have a project, click the dropdown containing your project name, such as Formspree Test Account. If you don’t have a project, it will appear differently. Clicking on the dropdown will show a modal with the New Projects option.

mceclip1.png

Give a project name and create it

mceclip2.png

2. Create a service account

Access the service account option by searching on the search bar or in the side menu. If you have more than one project, you have to specify which project you want to use.

Click on Create Service Account.

mceclip3.png

Add a service name and description and click Done.

mceclip4.png

You should see the account listed in the dashboard. We’ll need the email account in the table for the formspree.json file.

mceclip5.png

3. Getting your private key

On the service account dashboard click on the Actions column of your last step created account row. Then click on Create Key, select the JSON option, and click Create.

mceclip6.png

This will return to you a file to download containing the private key and another private service account data. Store this information securely. We’ll need it in formspree.json configuration step.

4. Enable Drive and Spreadsheet API

To create a spreadsheet Formspree requires you to use the Google Drive and sheets API using your credentials. For that, you need to enable both APIs on Google Cloud Console.

Select your project and access https://console.cloud.google.com. Write in the search bar Google Drive API. Click Enable on the resulting page to enable the API.

Repeat this step by searching for Google Sheets API.
mceclip0.png

formspree.json configuration

KeyTypeDescription
appStringMust be googlesheets
privateKeyStringThe private_key data that you have in the JSON file generated in Getting your key step.
serviceAccountStringThe service account email that you have received in the Create a service account step. You can see it in the JSON file that contains your service account data as client_email. You can also access the service account dashboard and copy the email column.
typeStringMust be sendToSpreadsheet
sendInvitationToStringOptional. The email that the spreadsheet created by Formspree will be shared. An email will be sent to the email configured there. Default: Your form target email and if not exists your account email. In this sequence. If both do not exist, an error will be shown on the console.

Example

{
  "forms": {
    "support": {
      "name": "Clients Spreadsheet",
      "actions": [
        {
          "app": "googlesheets",
          "privateKey": "$GOOGLE_SHEETS_KEY",
          "serviceAccount": "formspree-test-service-account@formspree-test-account.iam.gserviceaccount.com",
          "type": "sendToSpreadsheet",
          "sendInvitationTo": "other@email.com"
        }
      ]
    }
  }
}

Validation rules

No validation rules are implicitly configured.

Still have questions? or .