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.
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
Every 15 minutes ClickRuntime checks your Knowledge folder in Google Drive for files added or changed since the last check.
It reads the text of each changed file and splits it into short passages.
Each passage is turned into a search vector with the embedding service you chose.
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
Build your own
Need it to work differently?
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
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?
What does my Supabase table need?
Which embedding model is used?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Categorise bank statement transactions into Supabase
Drop a bank statement CSV into Drive and each transaction is sorted into your own categories and saved to your Supabase database.
See how it worksBack up your Supabase storage files to Google Drive every night
Every night new and changed files in your Supabase storage bucket are copied to a Drive folder, and you get an email summary.
See how it worksDraft answers to support questions from your own documents
Each question from your support form comes back to you as a drafted answer with links to the documents it used.
See how it worksKeep exploring
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.