Skip to content

Every 5 minutes

Hear about every new Firestore document

A few minutes after a document lands in the collection you pick, you get its key fields in Slack or email.

Runs
Every 5 minutes
Apps
Firebase
AI
Not needed
Access
datastore read (Cloud Datastore Viewer)

Send this to your assistant

Create a ClickRuntime automation: every 5 minutes, check my Firestore 'orders' collection for documents newer than the last one by createdAt and post each new order's customer, total and status to #orders in Slack.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

In many apps, a new document in a Firestore collection means that something a human needs to see has happened: a support request, a refund request, a new lead from a contact form, a flagged post. The app saves it and moves on, and nobody is told. Staff discover the record when they next open an admin page, which may be hours later, while the customer who wrote in is still waiting.

Every five minutes, ClickRuntime runs a structured query on the collection, ordered by createdAt and starting after the last value it stored, and sends you the new documents. It then saves the latest timestamp as a cursor, so each document is reported once.

It is a good fit for apps without a built-in notification system, where the database is the only record of events.

What you get out of it

  • React to customer requests quickly

    A support request or refund request that triggers a message within five minutes gets answered faster. Quick replies reduce churn and chargebacks from customers who feel ignored. Customers who feel heard stay longer.

  • Add alerts without changing app code

    Developers do not have to write and deploy a notification feature. The alert reads the collection from outside, so releases stay small and the app's own code stays focused. Fewer deploys also means fewer chances to break something.

  • Catch problems from flagged content

    If your app lets users report posts, a new report document alerts a moderator right away. Harmful content stays visible for minutes, not for the rest of the day. Moderators can then act in time.

  • Avoid missed and duplicate messages

    The cursor means you are told once per document. If a run is delayed or the service restarts, the next run picks up from the saved point and nothing is skipped.

  • Make background activity visible

    Teams often forget what the app records behind the scenes. Seeing new documents arrive helps non-technical staff understand what customers are doing and when. Understanding the product's real activity helps everyone.

How it works

What happens, step by step

  1. Every five minutes ClickRuntime checks the Firestore collection you picked for documents created since its last check.

  2. It posts the key fields of each new document to Slack or email.

  3. It remembers where it stopped, so nothing is sent twice.

Before it runs live

  • Connect Firebase

What you get

RunsEvery 5 minutes
Hear about every new Firestore documenttoday, 9:00Succeeded
Slack · #ordersNew order: Northwind Traders, 249.00, paid

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Firebase steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
get_notified_about_new_firestore_documents.pyexample
from clickruntime import on_trigger, credentials, http, notify, state, report_fetched

PROJECT = "acme-prod"
FS = f"https://firestore.googleapis.com/v1/projects/{PROJECT}/databases/(default)/documents"

def fs_headers():
    return {"Authorization": f"Bearer {credentials.connection('google', 'work')}"}

def val(field):
    return next(iter(field.values())) if field else None

@on_trigger
def run(event):
    since = state.get("since") or "1970-01-01T00:00:00Z"
    query = {"structuredQuery": {"from": [{"collectionId": "orders"}],
             "where": {"fieldFilter": {"field": {"fieldPath": "createdAt"}, "op": "GREATER_THAN", "value": {"timestampValue": since}}},
             "orderBy": [{"field": {"fieldPath": "createdAt"}}], "limit": 100}}
    docs = [r["document"] for r in http.post(f"{FS}:runQuery", json=query, headers=fs_headers()).json() if "document" in r]
    report_fetched(len(docs))
    if not docs:
        return {"new": 0}
    for d in docs:
        f = d["fields"]
        notify.slack(f"New order: {val(f.get('customer'))}, {val(f.get('total'))}, {val(f.get('status'))}", channel="#orders")
    state.set("since", docs[-1]["fields"]["createdAt"]["timestampValue"])
    return {"new": len(docs)}

FAQ

Common questions

Do documents need a creation timestamp?
Yes. The query orders by a field such as createdAt, so each document must have one that Firestore can sort on. Documents created without it will not be found by this check, so add the field in your app. Add an index if Firestore asks for one.
What does the notification include?
The document ID and the fields you choose, such as customer email, subject or amount. Large text fields can be trimmed. You pick which fields to show so the message stays readable and avoids sensitive details.
Can I watch a subcollection?
Yes. Point the query at the full path of the subcollection, or use a collection group query to watch every collection with the same name across your database. Each needs its own index for ordering, which Firestore will describe. Collection groups need their own index.
What permissions does it need?
datastore read (Cloud Datastore Viewer). Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Hear about every new Firestore document” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.