Overview
This node triggers workflows based on changes in Google Firestore, a NoSQL document database. It can listen to either an entire collection or a specific document within a collection. When relevant events occur—such as documents being added, modified, or removed—the node activates and passes the changed data downstream.
Common scenarios:
- Automatically processing new user signups by listening to a "users" collection.
- Monitoring updates to orders in a nested path like "users/:userId/orders".
- Reacting to changes in chat messages under "chats/:chatId/messages".
- Triggering workflows when a particular document is updated, e.g., a settings document.
Practical example:
You want to send a notification every time a new order is placed by any user. You configure this node to listen to the collection path users/:userId/orders for "added" events. Whenever a new order document is created, the workflow runs with the order details.
Properties
| Name | Meaning |
|---|---|
| Operation | Choose between listening to a whole collection or a single document. Options: Listen to Collection, Listen to Document. |
| Collection Path | The Firestore collection path to listen to. Supports dynamic segments using colon parameters (e.g., users/:userId/orders). For fixed paths, use normal segments (e.g., users/user123/orders). |
| Document ID | (Only for "Listen to Document") The ID of the specific document to listen to within the collection path. |
| Events | (Only for "Listen to Collection") Select which document events to listen for: Added, Modified, Removed. |
| Options | Additional options: |
| - Include Metadata Changes | Whether to also listen for metadata changes on documents. |
| - Query Filters | Add filters to limit which documents trigger the workflow based on field values and comparison operators (e.g., equal, greater than). |
| Verbose Logging | Enable detailed debug logging about Firestore connection and event handling. |
Output
The node outputs an array of items where each item contains a json object representing a Firestore document snapshot that triggered the event.
- Each
jsonobject corresponds to a document's data at the time of the event. - If multiple documents change simultaneously (e.g., batch updates), multiple items are emitted.
- The output does not include binary data.
Example output item structure:
{
"json": {
/* Firestore document fields and values */
}
}
Dependencies
- Requires a valid Google Firebase Admin API credential with access to Firestore.
- Needs proper configuration of the Firebase project ID and optional database ID.
- Uses Firestore SDK internally to establish listeners on collections or documents.
- n8n environment must have network access to Firestore services.
Troubleshooting
- Empty Collection Path or Document ID: The node throws an error if the collection path or document ID (for document listening) is empty. Ensure these fields are correctly filled.
- Credential Validation Failed: If the provided Firebase credentials are invalid or lack necessary permissions, the node will report a validation failure. Verify the API key and service account permissions.
- Listener Not Triggering: Check that the specified events (added, modified, removed) match the expected Firestore operations. Also, confirm query filters do not exclude all documents unintentionally.
- Verbose Logging: Enable verbose logging to get detailed insights into connection issues or event reception problems.
- Cleanup Errors: Occasionally, errors during listener cleanup or Firebase app shutdown may appear in logs but usually do not affect functionality.