Blog
Trigger an AI Agent When Firestore Data Changes
Tutorial
ยท
Quick answer: To trigger an AI agent when Firestore data changes, add the BuildShip Database Trigger to a BuildShip workflow. Pick an event type (document created, updated, deleted or written), enter a document path pattern such as users/{docId}, choose the database and location, and click Connect. It works on any Firestore database in your own Google Cloud project, so there is no Cloud Function to write and no endpoint to wire up. Every matching change starts a run with step-level logs and editable JavaScript or TypeScript on every node.

Why trigger an AI agent from Firestore changes
Most apps keep their state in Firestore, and a lot of useful work starts the moment that state changes. Polling the database on a timer is slow and wasteful. An event-driven workflow reacts to the change itself, so it runs once, right away, with the document that changed.
Here are a few jobs that fit this pattern:
A new order document is created, so you send a confirmation email and update stock.
A user profile is updated, so you sync the change to your CRM.
A new feedback message is added, so an AI step classifies it and writes the category back.
A document is deleted, so you clean up related files and records.

Pick one event type per workflow, or choose Document Written to handle every change in the same workflow.
The BuildShip Database Trigger
BuildShip has a native trigger for Firestore document changes. You find it in the trigger picker under Integrations, as BuildShip Database Trigger. In BuildShipโs own words, it โtriggers workflows when documents are created, updated, deleted, or written. You can specify document paths using exact matches or patterns, and filter events based on document field changes.โ
It runs against any Firestore database in your own Google Cloud project, including named databases, not just the default one. That makes it a good fit if your app already writes to Firestore and you want to react to those writes.
Set it up in five steps
Open your workflow, click the trigger icon at the top and go to the Connect tab. Under Integrations, choose BuildShip Database Trigger.
Choose the Event Type. The options are Document Created (the default), Document Updated, Document Deleted and Document Written. Use Document Written if you want one workflow to handle every change.
Set the Document path pattern. The default is
users/{docId}. Use an exact path to watch one document, or a pattern with wildcards such asorders/{orderId}to watch every document in a collection.Choose the Database. The default is
(default). If you use a named Firestore database, enter its name here.Set the Location. The default is
nam5. Change it to match the location of your Firestore database. Then click Connect.
Two optional fields let you narrow what starts a run. Required Fields and Listener Fields each take a JSON array. Required Fields lets you name fields the document needs to have. Listener Fields lets you filter events based on which fields changed, so a run only starts when something you care about was edited.
Change a document in Firestore, then check the run in your workflow. From there you can add the fields you need from the trigger data as workflow inputs and use them in the next steps.
Build the AI agent: classify new feedback with AI
Here is a small example. When a document lands in a feedback collection, the workflow classifies it and writes the category back. Set the trigger to Document Created with the path pattern feedback/{docId}.
Add an AI node and give it a short instruction, such as โClassify this message as bug, request or question.โ Keyless AI nodes run on your BuildShip credits, or you can bring your own provider key.
Add the Update Firestore Field Value node. Enter your Firebase project ID, set the document path from the trigger data, set the field key to
category, and pass in the AI result.Connect your Firebase project so BuildShip can write to it. In BuildShipโs settings, copy the service account details from the General tab. In your Firebase projectโs IAM & Admin page, grant that service account the Cloud Datastore User and Firebase Admin SDK Administrator Service Agent roles. Google can take a few minutes to apply the change.

A feedback agent, from the new document to the category written back. The trigger is set to Document Created with the path pattern feedback/{docId}.
BuildShip has ready-made nodes for the common Firestore jobs, including Get Firestore Document, Collection Query, Create Document, Update Field Value and Delete Firestore Document. You can see the full list on the Firestore integration page and the Firebase integration page.
If you would rather not wire it by hand, click Build with AI to open Compass, BuildShipโs AI builder, and describe the flow in plain language. It builds on your actual canvas, so you can still test and edit every step.
Stop a workflow from triggering itself
If your workflow updates the same document that started it, that update is a new change and the trigger fires again. In the example above, writing category back to the feedback document is exactly that kind of change. There are two simple ways to guard against it:
Use the trigger settings. Choose Document Created instead of Document Written, so later edits do not start a run. If you need to react to updates, use Listener Fields to limit runs to the fields you actually care about, and leave out the field your workflow writes.
Add a Branch node first. Only continue if the document has no category yet. A document that has already been processed then stops at the first step.
Using both is the safest option for a workflow that writes back to its own trigger document.

Writing category back is a new change. Use the trigger settings and a Branch node together so the agent does not start itself again.
Test it, ship it and watch it run
Run a test from the test panel with a sample document.
Click Ship to make the workflow active.
Change a document in Firestore and watch the run appear.
Open the logging panel at the bottom of the workspace to see what happened. You can switch from the Workflow view to the Node view to read the logs for a single step, and test runs show live logs as they happen. Production logs usually show up within about 45 seconds, and the refresh icon loads them straight away. To add your own messages, use the Log Message to Console node, or call logging.log inside any nodeโs code.
Built for teams that run this in production
Event-driven workflows tend to end up in production, so a few things matter beyond the first test:
Full code access. Open any node to read or change its JavaScript or TypeScript. Nothing is a black box.
Team access control. Role-based access control lets you decide who can view a workflow, who can edit it and who can ship it.
Your own Google Cloud. Workflows run on Google Cloud, and you can run them in your own Google Cloud project.
Agents when you need judgement. For changes that need a decision rather than a fixed rule, a workflow can hand off to an AI agent built with Agent Max, which can call your other workflows as tools.
Already manage your collection in Rowy? The Rowy Trigger is an alternative that starts a workflow from a Rowy tableโs create, update or delete events.

For plain Firestore document changes, the BuildShip Database Trigger is the simple path. Use the Rowy Trigger if the collection already lives in Rowy, or a REST API Call trigger if you need to call BuildShip from your own code.
FAQ
Does BuildShip have a built-in Firestore trigger?
Yes. The BuildShip Database Trigger starts a workflow when a Firestore document is created, updated, deleted or written. You find it under Integrations in the trigger picker, on the Connect tab of your workflow. It works on any Firestore database in your own Google Cloud project.
Can I run a workflow on create, update and delete separately?
Yes. The Event Type setting offers Document Created, Document Updated, Document Deleted and Document Written. Pick one per workflow, or choose Document Written to handle all changes in the same workflow.
Can I watch a specific document or a whole collection?
Yes. The Document path pattern accepts an exact path to watch one document, or a pattern with wildcards, such as orders/{orderId}, to watch every document in a collection.
Can I use a named Firestore database or my own Firebase project?
Yes. Enter the database name in the Database field (the default is (default)) and set the Location to match your database. For nodes that read or write Firestore, copy the service account details from BuildShipโs settings and grant them the Cloud Datastore User and Firebase Admin SDK Administrator Service Agent roles in your Firebase projectโs IAM & Admin page.
How do I stop my workflow from triggering itself?
If a workflow updates the document that started it, that update is a new change. Use Document Created rather than Document Written where you can, use Listener Fields to limit runs to the fields you care about, and add a Branch node at the start that skips documents you have already processed.
What if I need to call BuildShip from my own code instead?
Add the REST API Call trigger to a workflow and call its URL from your own code, for example from a Cloud Function. For plain Firestore document changes, the BuildShip Database Trigger is simpler.
How much does it cost to try?
BuildShip plans start with a 7-day trial, and a card is required to start it. See the pricing page for plans and credits.
Start building
The quickest way to learn this is to build it. Start your 7-day trial (a card is required), create a workflow, add the BuildShip Database Trigger and change a document. If you also use Supabase, read our guide to triggering a workflow from a Supabase database webhook.





