Skip to content

Every 15 minutes

Keep a Drive folder searchable in your Supabase vector table

New and updated documents in your Drive Knowledge folder are split into chunks, embedded and kept in step in your Supabase documents table, so your app always searches current content.

Runs
Every 15 minutes
Apps
Google Drive, Supabase
AI
Not needed
Access
Drive read; Supabase service key (write)

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, take new or updated files in my Drive 'Knowledge' folder, split them into chunks, embed them and upsert them into my Supabase documents table, replacing old rows for each file.

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

A startup has built a help assistant on Supabase that answers questions from its product docs. The docs live in a Drive folder that the support team edits weekly, but the vector table was loaded once by a developer, so the assistant keeps quoting last quarter's pricing.

Re-indexing documents whenever they change keeps your search and AI features answering from current content, without a developer re-running an import script.

What you get out of it

  • Answers stay up to date

    When someone edits a doc in Drive, the indexed version is replaced within minutes, so outdated text stops appearing in results.

  • Writers keep using Drive

    Your support or content team edits documents as usual. Nobody needs access to the database.

  • No stale duplicates

    Old chunks for a file are removed before the new ones are added, so search never returns two versions of the same page.

  • You hear about failures

    If a file cannot be read or the database rejects a write, you get an email naming the file.

How it works

What happens, step by step

  1. Every 15 minutes ClickRuntime checks your Knowledge folder in Google Drive for files added or changed since the last check.

  2. It reads the text of each changed file and splits it into short passages.

  3. Each passage is turned into a search vector with the embedding service you chose.

  4. The file's old passages are removed from your Supabase table and the new ones are added. You get an email if any file fails.

Before it runs live

  • Connect Google Drive
  • Connect Supabase

What you get

RunsEvery 15 minutes
Keep a Drive folder searchable in your Supabase vector tabletoday, 9:00Succeeded
Email · Indexing reportDrive indexing failed for some files: Northwind pricing 2026.pdf could not be read.

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 Google Drive and Supabase 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.
keep_a_drive_folder_indexed_in_supabase_for_ai_search.pyexample
from clickruntime import on_trigger, credentials, http, state, notify, report_fetched
FOLDER, SB = "your-knowledge-folder-id", "https://yourproject.supabase.co/rest/v1/documents"
D = "https://www.googleapis.com/drive/v3/files"
@on_trigger
def run(event):
    h = {"Authorization": f"Bearer {credentials.connection('google', 'work')}"}
    since = state.get("since") or "2026-01-01T00:00:00Z"
    files = http.get(D, headers=h, params={"q": f"'{FOLDER}' in parents and modifiedTime > '{since}' and trashed = false",
                                           "orderBy": "modifiedTime", "fields": "files(id,name,mimeType,modifiedTime)"}).json()["files"]
    report_fetched(len(files))
    if not files:
        return {"changed": 0}
    key = credentials.secret("SUPABASE_SERVICE_KEY")
    sb = {"apikey": key, "Authorization": f"Bearer {key}"}
    emb = {"Authorization": f"Bearer {credentials.secret('OPENAI_API_KEY')}"}
    failed = []
    for f in files:
        try:
            gdoc = f["mimeType"].startswith("application/vnd.google-apps")
            text = (http.get(f"{D}/{f['id']}/export", headers=h, params={"mimeType": "text/plain"}) if gdoc
                    else http.get(f"{D}/{f['id']}", headers=h, params={"alt": "media"})).text
            chunks = [text[i:i + 1500] for i in range(0, len(text), 1300)][:200]
            vecs = http.post("https://api.openai.com/v1/embeddings", headers=emb, json={"model": "text-embedding-3-small", "input": chunks}).json()["data"]
            http.delete(SB, headers=sb, params={"file_id": f"eq.{f['id']}"}).raise_for_status()
            http.post(SB, headers=sb, json=[{"file_id": f["id"], "file_name": f["name"], "content": c, "embedding": v["embedding"]}
                                            for c, v in zip(chunks, vecs)]).raise_for_status()
        except Exception as e: failed.append(f"{f['name']}: {e}")
    if failed: notify.email_me("Drive indexing failed for some files", "\n".join(failed))
    state.set("since", files[-1]["modifiedTime"])
    return {"indexed": len(files) - len(failed), "failed": len(failed)}

FAQ

Common questions

Which file types are indexed?
Google Docs, PDFs, plain text and CSV files in the folder.
What does my Supabase table need?
A documents table with columns for the file ID, file name, chunk text and an embedding vector, plus the pgvector extension enabled.
Which embedding model is used?
The one whose API key you save in your ClickRuntime dashboard. Use the same model your app uses for search queries, so the vectors match.
What permissions does it need?
Drive read; Supabase service key (write). 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 “Keep a Drive folder searchable in your Supabase vector table” from your assistant

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