Overview
This node is a Firestore Trigger designed to start an n8n workflow when changes occur in a Google Firestore database. It listens for real-time events on specified Firestore collections or documents, enabling workflows to react immediately to data additions, modifications, or deletions.
Common scenarios where this node is beneficial include:
- Automating notifications or updates when user data changes.
- Syncing Firestore data with other systems upon document creation or update.
- Monitoring chat messages or orders in real-time to trigger downstream processes.
Practical examples:
- Listen to the "users/:userId/orders" collection path to trigger a workflow whenever an order is added, modified, or removed for any user.
- Monitor a specific document like "settings/appConfig" to react instantly when configuration changes.
Properties
Name | Meaning |
---|---|
Collection Path | The Firestore collection path to listen to. Supports dynamic segments using colon parameters (e.g., users/:userId/orders ) to create listeners that respond to any matching document path. |
Path Format Guide | Guidance on how to format the collection path, explaining the use of colon parameters for dynamic paths and fixed segments for static paths. |
Options | Additional options to customize the listener behavior: |
- Include Metadata Changes | Boolean flag to specify whether metadata changes (such as local cache updates) should also trigger the listener. |
- Query Filters | A set of filters to apply to the collection query. Each filter includes: |
• Field: The document field name to filter on. | |
• Operator: Comparison operator, one of: Array Contains, Equal, Greater Than, Greater Than or Equal, Less Than, Less Than or Equal, Not Equal. | |
• Value: The value to compare the field against. |
Output
The node outputs JSON objects representing Firestore document changes. Each output item contains:
id
: The Firestore document ID.data
: The document's data fields as key-value pairs.changeType
(for collection listeners): The type of change event —"added"
,"modified"
, or"removed"
.path
: The full Firestore path of the document.metadata
: An object containing:hasPendingWrites
: Boolean indicating if there are local writes not yet committed to the server.fromCache
: Boolean indicating if the data was fetched from the local cache.
timestamp
: The timestamp (in milliseconds) when the event was processed.exists
(for document listeners): Boolean indicating if the document currently exists.
If binary data were supported, it would be summarized here; however, this node only outputs JSON data representing Firestore documents and their metadata.
Dependencies
- Requires a valid API authentication token credential for Firebase Admin SDK access.
- Needs proper configuration of Firebase project credentials within n8n.
- Uses the official Firebase Admin Firestore SDK to connect and listen to Firestore events.
- No additional external services beyond Firestore are required.
Troubleshooting
Common Issues
- Empty or invalid collection path: The node throws an error if the collection path is empty or contains empty segments. Ensure the path is correctly formatted without leading/trailing slashes and no empty parts.
- Missing Document ID for document listener: When listening to a single document, the document ID must be provided and non-empty.
- Credential validation failure: If the Firebase credentials are invalid or misconfigured, the node will fail to initialize the Firebase app.
- Listener setup errors: Errors during listener setup may occur due to incorrect paths, permissions, or network issues.
Error Messages and Resolutions
"Collection path cannot be empty"
: Provide a valid collection path."Document ID cannot be empty"
: Specify the document ID when using the document listener operation."Firebase credential validation failed"
: Verify the API key credential configuration in n8n."Firebase authentication error: Could not load Firebase credentials..."
: Check that the Firebase credentials file or environment variables are correctly set up.- Listener errors logged as
"Firestore listener error"
or"Firestore document listener error"
usually indicate permission issues or connectivity problems; verify Firestore rules and network access.