On a schedule
Index new documents into Pinecone nightly and email what changed
Every night new and changed documents from your folder are indexed into Pinecone, and you get an email listing what was added.
- Runs
- On a schedule
- Apps
- Gmail, Pinecone
- AI
- Not needed
- Access
- Pinecone write; gmail.send
Send this to your assistant
Create a ClickRuntime automation: every night at 1am, index new or changed Google Docs from my Knowledge folder into Pinecone and email me the list of files added or updated.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A knowledge base that powers answers or replies is only trusted if people know what is in it. When documents are added quietly, nobody can tell whether last week's new policy made it in.
Teams running document search or AI answers on their own material use it to keep the index current overnight and to have a written record of each update.
What you get out of it
Updated while you sleep
New and edited documents are in the index by morning.
A clear record
The nightly email lists exactly which files were added or updated.
Only changes processed
Unchanged files are skipped, which keeps the run quick.
Quiet nights stay quiet
No email is sent when nothing changed.
How it works
What happens, step by step
Every night, ClickRuntime lists the Google Docs in your folder and checks which ones are new or changed since the last run.
Each changed document is split into chunks and written to your Pinecone index, replacing its earlier entries.
If anything changed, you get an email from your Gmail listing the files.
Before it runs live
- Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
- Connect Pinecone
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
- Run it at a different time, more or less often, or only on weekdays
- 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 Gmail and Pinecone steps into one automation
Under the hood
The code that runs this automation
import base64, json
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, state
ME, Q = "me@example.com", "'your-folder-id' in parents and trashed=false and mimeType='application/vnd.google-apps.document'"
HOST, NS = "https://kb-abc123.svc.aped-1234.pinecone.io", "company" # your index host and namespace
def upsert(records):
http.post(f"{HOST}/records/namespaces/{NS}/upsert", data="\n".join(json.dumps(r) for r in records[:96]), headers={
"Api-Key": credentials.secret("PINECONE_API_KEY"), "X-Pinecone-API-Version": "2025-04", "Content-Type": "application/x-ndjson"}).raise_for_status()
def send(to, subject, body):
raw = f"To: {to}\r\nSubject: {subject}\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n{body}"
build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users() \
.messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(raw.encode()).decode()}).execute()
@on_trigger
def run(event):
drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).files()
files, known = drive.list(q=Q, fields="files(id,name,modifiedTime)", pageSize=1000).execute()["files"], state.get("known") or {}
changed = [f for f in files if known.get(f["id"]) != f["modifiedTime"]]
for f in changed:
text = drive.export(fileId=f["id"], mimeType="text/plain").execute().decode("utf-8", "ignore")
upsert([{"_id": f"{f['id']}#{n}", "chunk_text": text[i:i + 1500], "file_id": f["id"], "file_name": f["name"]}
for n, i in enumerate(range(0, len(text), 1500))])
if changed:
send(ME, f"Knowledge base: {len(changed)} files indexed", "\n".join(
f"{'Updated' if f['id'] in known else 'Added'}: {f['name']}" for f in changed))
state.set("known", {f["id"]: f["modifiedTime"] for f in files})
return {"indexed": len(changed)}FAQ
Common questions
Which files are indexed?
Are old versions removed?
Who gets the email?
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
Get only the security news that affects your tech stack
Every morning you get one email with the security news items that match the tools and systems you actually use.
See how it worksDraft email replies from your knowledge base
Customer emails get an accurate draft reply in Gmail, written from the docs you keep in Pinecone.
See how it worksLet visitors ask about your CV, with a daily summary by email
Visitors to your site can ask questions about your experience and get answers from your CV, and you get an email summarising each day's conversations.
See how it worksKeep exploring
Set up “Index new documents into Pinecone nightly and email what changed” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.