Overview
This node triggers workflows based on changes occurring in a Firestore collection. It listens to real-time events such as documents being added, modified, or removed within a specified collection path. The node supports dynamic path parameters, allowing it to respond to changes in collections with variable segments (e.g., users/:userId/orders
). It can also apply query filters to narrow down the documents that trigger events.
Common scenarios:
- Monitoring user activity logs stored in Firestore collections.
- Triggering workflows when new orders are placed or updated in an e-commerce app.
- Reacting to chat messages added or changed in a messaging app.
- Dynamically listening to subcollections for any user or entity by using path parameters.
Practical example:
- Listen to the collection path
users/:userId/orders
for any new order added (added
event) or modified (modified
event). When such an event occurs, the workflow is triggered with details about the changed document.
Properties
Name | Meaning |
---|---|
Collection Path | The Firestore collection path to listen to. Supports colon-prefixed parameters for dynamic segments (e.g., users/:userId/orders ). Fixed paths without parameters are also supported (e.g., users/user123/orders ). |
Path Format Guide | Informational notice explaining how to use colon parameters in paths to create dynamic listeners or fixed segments for static paths. |
Events | The types of document change events to listen for in the collection. Options include: Added (document added), Modified (document modified), and Removed (document removed). Multiple can be selected simultaneously. |
Options | Additional options for the listener: |
- Include Metadata Changes | Boolean flag indicating whether to listen for metadata changes in addition to document data changes. |
- Query Filters | One or more filters to apply to the collection query. Each filter consists of: |
• Field: The document field name to filter on. | |
• Operator: Comparison operator, one of array-contains , == , > , >= , < , <= , != . |
|
• Value: The value to compare the field against. |
Output
The node outputs JSON objects representing Firestore document changes matching the configured criteria. Each output item contains:
id
: The document ID.data
: The document's data fields as key-value pairs.changeType
: The type of change event (added
,modified
, orremoved
).path
: The full Firestore document path.metadata
: An object containing:hasPendingWrites
: Boolean indicating if there are local writes not yet committed.fromCache
: Boolean indicating if the data was fetched from cache.
timestamp
: The timestamp (in milliseconds) when the event was processed.
If metadata changes are included, these flags reflect those updates accordingly.
The node does not output binary data.
Dependencies
- Requires a valid Firebase Admin API credential configured in n8n to authenticate with Firestore.
- Uses the official Firebase Admin SDK for Firestore access.
- The Firestore database must be accessible with the provided credentials.
- No additional environment variables are required beyond the API credential.
Troubleshooting
- Empty Collection Path: If the collection path is empty or contains invalid segments, the node throws an error. Ensure the path is correctly specified and trimmed.
- Invalid Document ID: For operations 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 during initialization with an authentication error. Verify the API key and project settings.
- Listener Setup Errors: Errors during listener setup (e.g., invalid path, permission issues) will cause the node to throw errors. Check Firestore rules and path correctness.
- Dynamic Path Parameters: If dynamic path parameters are used incorrectly or parent paths cannot be resolved, the node will report errors. Follow the path format guide carefully.
- Firestore Listener Errors: Runtime errors from Firestore listeners are logged; ensure network connectivity and Firestore service availability.
- Metadata Changes: Enabling metadata changes may increase event frequency; disable if not needed to reduce noise.