Google Cloud Firestore

The Google Cloud Firestore modules enable you to work with documents in your Google Cloud Firestore.

Getting Started with Google Cloud Firestore

Prerequisites

The module dialog fields that are displayed in bold (in the Integromat scenario, not in this documentation article) are mandatory!

Connecting Google Cloud Firestore to Integromat

To connect your Google Cloud Firestore to Integromat, you'll need to obtain the project's Client ID and Client Secret in the Google Cloud Platform, and create a new Firebase project via Google Firebase Console.

Obtaining Client ID and Client Secret

1. Sign in to Google Cloud Platform using your Google credentials.

2. Click Select a project > NEW PROJECT

f3VYGLaqZz.gif

3. Enter the desired project name, and click the CREATE button.

1c7mZhfeFU.gif

4. Go to APIs & Services > Library.

ikUYh3USkS.gif

5. Search and enable the following required APIs: 

  1. Google Cloud Firestore API
  2. Firebase Management API
  3. Google Cloud Storage JSON API

The desired service option should display as you type. Click on the API/service you want to connect to Integromat.

kPXtfF4VfR.gif

6. Click the ENABLE button to enable the selected API.

7. Open APIs & Services > Library, and search and enable the two remaining required APIs (see step 5 above).

8. Open the OAuth consent screen settings.

f9lLPdGhuW.gif

9. Choose the External option, and click the CREATE button.

You will not be charged when selecting this option! For more details, please refer to Google's exceptions to verification requirements.

DeMrvxUYqI.gif

10. Fill in the required fields as follows, and then click the Save button:

Application name

Enter the name of the app asking for consent.

For example, Integromat.

Scopes for Google APIs

Click the Add scope button to open the Add scope dialog.

Add required scopes.

f30zuBRUuR.gif

The list of required scopes:

SERVICE/API

REQUIRED SCOPES

  https://www.googleapis.com/auth/cloud-platform
Cloud Firestore API
https://www.googleapis.com/auth/datastore
Google Cloud Storage JSON API
https://www.googleapis.com/auth/devstorage.read_write
Firebase Management API
https://www.googleapis.com/auth/firebase.readonly
Authorized domains integromat.com
You don't need to submit your consent screen and application for verification by Google. Just click the Save button after you fill in the required fields on this page.

2020-07-16_09_52_55-Consent_screen_-_Google_OAuth_Client_-_Google_API_Console.png

11. Go to Credentials. Click on the +CREATE CREDENTIALS, and select the OAuth Client ID option.

LGlFPOSepS.gif

12. Fill in the required fields as follows, and then click the CREATE button to create the application:

Application type Web application
Name e.g. Integromat
Authorized redirect URIs

https://www.integromat.com/oauth/cb/google-custom

LJnyfdFvN5.gif

13. A dialog containing the app's Client ID and Client Secret is displayed. Save them to a safe place for later use.

explorer_tCReFOgixG.png

14. Go to Integromat, open the Create a connection dialog of the desired Google Cloud Firestore module, enter the Client ID and Client Secret from step 13 above in the respective fields, and click Continue.

chrome_18EcTnClHT.png

15. Sign in with your Google account.

16. The This app isn't verified window may appear.

The app = your OAuth client you have created above.

17. Click on the Advanced link, and then on the Go to Integromat (unsafe) link to allow access using your custom OAuth client.

dt7MQOx6gY.gif

18. Click Allow (2x) to grant Integromat permission.

fGXIa286Ss.gif

19. Click the Allow button to confirm your choices.

2020-10-20_18_29_03-Window.png

The connection to your Google Cloud Firestore account has been established.
Now, create a Firebase project and a Firestore database.

Creating a Firebase Project

1. Sign in to Google Firebase Console using your Google credentials.

2. Click Create a project.

2020-10-26_12_11_17-Firebase_console.png

3. Enter the desired project name, and click the Create button. Set Google Analytics settings as needed.

4. Create a Firestore Database. 

oqnhxpyRpk.gif

Now, you can build your scenario using the Google Cloud Firestore modules.

Documents

Watch New Documents

Retrieves document details when a document is created in the specified collection.

Connection Establish a connection to your Google Cloud Firestore account.
Input the collection path Select whether to specify the project, database, and collection manually (By Mapping) or using a drop-down menu (By Dropdown).
Collection Path

Enter the collection path in the following format:

projects/{project_id}/databases/{database_id}/documents/{collection_id}

For example: projects/nifty-anyway-295114/databases/(default)/documents/TestCollection

Limit Enter the maximum number of documents Integromat will return during one execution cycle.
Mask Specify field paths on a document you want to return. If a document has a field that is not present in this mask, that field will not be returned in the response.

Create a Document

Creates a new document.

Connection Establish a connection to your Google Cloud Firestore account.
Input the collection path Select whether to specify the project, database, and collection manually (By Mapping) or using a drop-down menu (By Dropdown).
Collection Path

Enter the collection path in the following format:

projects/{project_id}/databases/{database_id}/documents/{collection_id}

For example: projects/nifty-anyway-295114/databases/(default)/documents/TestCollection

Document Fields

Specify the name and value of the document's field(s) you want to add to the collection.

Field Name Enter the name of the document's field.
Value Type Select the value type, and specify the field's value.
Document ID

Specify the document ID. If not specified, an ID will be assigned by the service. For best performance, let Firestore assign the ID, or make sure to avoid hotspots. For best compatibility with the API, avoid using special characters.

Mask

Specify field paths on a document you want to return. If a document has a field that is not present in this mask, that field will not be returned in the response.

Get Documents

Retrieves specified documents.

Connection Establish a connection to your Google Cloud Firestore account.
Project Select the project or enter the project ID of the project you want to retrieve documents from.
Documents

Specify the documents you want to retrieve.

Enter the document path in the following format:

projects/{project_id}/databases/{database_id}/documents/{document_path}

For example: projects/nifty-anyway-293ad4/databases/(default)/documents/Test/FhmIXJYB7fQ0iURF2F4I

Limit

Set the maximum number of documents Integromat will return during one execution cycle.

Consistency Selector

Select the consistency mode for this transaction.

  • Transaction
    Reads documents in a transaction.
  • New Transaction
    Starts a new transaction, and reads the documents.
  • Read Time
    Reads documents as they were at the given time. This may not be older than 270 seconds. Refer to the list of supported date and time formats.

List Documents

Retrieves all documents in the collection.

Connection Establish a connection to your Google Cloud Firestore account.
Input the collection path Select whether to specify the project, database, and collection manually (By Mapping) or using a drop-down menu (By Dropdown).
Collection Path

Enter the collection path in the following format:

projects/{project_id}/databases/{database_id}/documents/{collection_id}

For example: projects/nifty-anyway-295114/databases/(default)/documents/TestCollection

Limit Enter the maximum number of documents Integromat will return during one execution cycle.
Show Missing Select if the list should show missing documents. A missing document is a document that does not exist but has sub-documents. These documents will be returned with a key, but will not have the fields Document.create_time, or Document.update_time set.
Order By Specify the field to order results by.
Mask Specify field paths on the document you want to return. If a document has a field that is not present in this mask, that field will not be returned in the response.
Consistency Selector

Select the consistency mode for this transaction.

  • Transaction
    Reads documents in a transaction.
  • New Transaction
    Starts a new transaction, and reads the documents.
  • Read Time
    Reads documents as they were at the given time. This may not be older than 270 seconds. Refer to the list of supported date and time formats.

List Collection IDs

Connection Establish a connection to your Google Cloud Firestore account.

Input the document path

Select whether to specify the project, database, and collection manually (By Mapping) or using a drop-down menu (By Dropdown).
Document Path

Enter the document path in the following format:

projects/{project_id}/databases/{database_id}/documents/{document_path}

For example: projects/nifty-anyway-293ad4/databases/(default)/documents/Test/FhmIXJYB7fQ0iURF2F4I

Limit Set the maximum number of collection IDs Integromat will return during one execution cycle.

Query Documents

Runs a query.

Connection Establish a connection to your Google Cloud Firestore account.

Input the document path

Select whether to specify the project, database, and collection manually (By Mapping) or using a drop-down menu (By Dropdown).
Document Path

Enter the document path in the following format:

projects/{project_id}/databases/{database_id}/documents/{document_path}

For example: projects/nifty-anyway-293ad4/databases/(default)/documents/Test/FhmIXJYB7fQ0iURF2F4I

(Select)

Fields

Specify the fields you want to return. If no fields are specified, all fields will be returned.

(From)

Collection ID

Specify the collection to query. Enter the collection ID. When set, selects only collections with this ID.

All Descendants Select the No option to select only collections that are immediate children of the parent specified in the query request. When enabled, this option selects all descendant collections.
Where Set up the filter settings. Refer to the list of operators.
Order By Specify the field you want to order results by.
Limit Enter the maximum number of documents Integromat will return during one execution cycle.

Every query requires an Index.
For the most basic queries, Firestore creates indexes by default.

But, some queries require you to set up an Index manually. Follow the steps below to set up the Index.

1. After sending a request that requires setting up the Index manually, the Firestore module will provide a link in the Error Message.

2020-10-23_12_49_24-Window.png

2. Open the link in your browser. You will be redirected to Firestore > Indexes.

2020-10-23_12_54_47-Window.png

3. Click the Create Index button. Wait a few minutes until Firestore completes the index creation.

2020-10-23_12_56_29-Window.png

4. Now, the Query Documents module will work without an error.

2020-10-23_12_58_39-Window.png

Update a Document

Updates or inserts a document.

Connection Establish a connection to your Google Cloud Firestore account.

Input the document path

Select whether to specify the project, database, and collection manually (By Mapping) or using a drop-down menu (By Dropdown).
Document Path

Enter the document path in the following format:

projects/{project_id}/databases/{database_id}/documents/{document_path}

For example: projects/nifty-anyway-293ad4/databases/(default)/documents/Test/FhmIXJYB7fQ0iURF2F4I

Add or Update Fields

Specify document's fields you want to add or update.

Add: Enter the name that does not exist in the document, and specify the desired value

Update: Enter the name of the existing field, and specify the new value.

Delete Fields

Specify the fields you want to remove from the document. If the field is in both Add or Update Fields and Delete Fields, the field will be updated and NOT deleted. None of the fields may contain a reserved name.

Mask

Specify field paths on a document you want to return. If a document has a field that is not present in this mask, that field will not be returned in the response.

Delete a Document

Deletes a single document.

Connection Establish a connection to your Google Cloud Firestore account.

Input the document path

Select whether to specify the project, database, and collection manually (By Mapping) or using a drop-down menu (By Dropdown).
Document Path

Enter the document path in the following format:

projects/{project_id}/databases/{database_id}/documents/{document_path}

For example: projects/nifty-anyway-293ad4/databases/(default)/documents/Test/FhmIXJYB7fQ0iURF2F4I

Storage

Paid Firestore account: Blaze Plan is required to use the Storage modules

Backup to Google Cloud Storage

Exports a copy of all or a subset of documents from Google Cloud Firestore to Google Cloud Storage.

Please read the How to Backup a Firestore Database, the No-code Way article.

Restore from Google Cloud Storage

Imports documents into Google Cloud Firestore. Existing documents with the same name are overwritten.

Make an API Call

Allows you to perform a custom API call.

Connection Establish a connection to your Google Cloud Firestore account.
URL

Enter a path relative to https://firestore.googleapis.com.
For example: /v1beta2/projects/{project_id}/databases/(default)/indexes.

For the list of available endpoints, refer to the Cloud Firestore API Documentation.
Method

Select the HTTP method you want to use:

GET
to retrieve information for an entry.

POST
to create a new entry.

PUT
to update/replace an existing entry.

PATCH
to make a partial entry update.

DELETE
to delete an entry.

Headers Enter the desired request headers. You don't have to add authorization headers; we've already done this for you.
Query String Enter the request query string.
Body Enter the body content for your API call.

Example of Use - List Documents

The following API call returns all documents in the specified collection in your Cloud Firestore account:

URL:
/v1/projects/{project_id}/databases/(default)/documents/{collection_id}/

Method:
GET

2020-10-23_15_05_33-Window.png

The result can be found in the module's Output under Bundle > Body > documents
In our example, 3 documents were returned:

2020-10-23_15_10_57-Window.png

Popular use cases from our blog

automated-data-collection-crm-illustration

How to Automate Data Collection - Part 5: CRM Systems

automated-data-collection-chatbot-marketing-illustration

How to Automate Data Collection - Part 4: Chatbot Marketing

automated-data-collection-paid-ads-illustration

How to Automate Data Collection - Part 3: Paid Ads

automated-data-collection-email-illustration

How to Automate Data Collection - Part 2: Email Marketing Segmentation

personalized-customer-experience-illustration-integromat

5 Automated Solutions to Personalize Customer Experience

data-collection-automation-forms-pt-1

How to Automate Data Collection - Part 1: Online Forms

Didn’t find what you were looking for?

Expert

Find an expert

We feature a network of 450+ certified partners across the globe who are ready to help

Find an expert

Automate any workflow in your business

Sign up for a free account today. No credit card required, no time limits on free plan.