On a schedule
Index reports in Pinecone and write an analysis to Google Docs
Your report documents are indexed in Pinecone, and each quarter an AI analysis drawing on them is written into a new Google Doc.
- Runs
- On a schedule
- Apps
- Google Docs, Pinecone
- AI
- Yes, uses the built-in AI allowance
- Access
- Pinecone key; Docs edit on shared folder
Send this to your assistant
Create a ClickRuntime automation: index the earnings-report docs in my folder into Pinecone, then each quarter write an AI analysis of the company into a new Google Doc.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
An analyst follows a handful of companies and keeps their quarterly reports in a Drive folder. Writing each quarter's summary means rereading hundreds of pages to find the figures and statements that changed.
Indexing the reports means the relevant passages can be pulled up for each question, and a first-draft analysis lands in Docs each quarter. The analyst's time goes into judgement rather than searching.
What you get out of it
Analysis grounded in your documents
The write-up draws on passages from your own reports. Claims can be checked against the source.
A first draft every quarter
The analysis is waiting in Docs when the period closes. Your work starts from a structured draft.
Reports stay searchable
Once indexed, the same collection can answer other questions later. The archive becomes a reference, not a pile of PDFs.
Only new files are processed
Documents already indexed are skipped. Adding a new report each quarter costs only that report's processing.
How it works
What happens, step by step
On each scheduled run, ClickRuntime looks for report documents in your folder that it has not indexed yet.
New documents are split into passages and stored in your Pinecone index.
It then searches the index for the passages most relevant to your analysis questions.
AI writes the analysis from those passages and the result is saved as a new Google Doc.
Before it runs live
- Connect Google Docs
- 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
- Change what the AI looks for, or how it writes the result
- Add another app, for example also send it to Slack
- Combine it with other Google Docs and Pinecone steps into one automation
Under the hood
The code that runs this automation
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, state, http, ai
INDEX_HOST = "https://your-index.svc.your-region.pinecone.io"
QUESTION = "Revenue, margins, guidance and key risks this quarter"
@on_trigger
def run(event):
pc = {"Api-Key": credentials.secret("PINECONE_API_KEY"), "X-Pinecone-API-Version": "2025-04"}
creds = Credentials(credentials.connection("google", "work"))
docs = build("docs", "v1", credentials=creds, cache_discovery=False).documents()
files = build("drive", "v3", credentials=creds, cache_discovery=False).files().list(q="'your-folder-id' in parents").execute()["files"]
indexed = state.get("indexed") or []
for doc_id in [f["id"] for f in files if f["id"] not in indexed]:
body = docs.get(documentId=doc_id).execute()["body"]["content"]
text = "".join(e["textRun"]["content"] for p in body for e in p.get("paragraph", {}).get("elements", []) if "textRun" in e)
records = [{"_id": f"{doc_id}-{i}", "text": text[i:i + 1500]} for i in range(0, len(text), 1500)]
http.post(f"{INDEX_HOST}/records/namespaces/reports/upsert", headers={**pc, "Content-Type": "application/x-ndjson"},
data="\n".join(__import__("json").dumps(r) for r in records))
indexed.append(doc_id)
state.set("indexed", indexed)
hits = http.post(f"{INDEX_HOST}/records/namespaces/reports/search", headers=pc,
json={"query": {"inputs": {"text": QUESTION}, "top_k": 12}}).json()["result"]["hits"]
context = "\n---\n".join(h["fields"]["text"] for h in hits)
analysis = ai.generate(f"Using only these excerpts, write a company analysis covering {QUESTION}:\n{context}", max_output_tokens=1800).text
doc = docs.create(body={"title": "Quarterly analysis"}).execute()
docs.batchUpdate(documentId=doc["documentId"], body={"requests": [{"insertText": {"location": {"index": 1}, "text": analysis}}]}).execute()
return {"indexed": len(indexed), "doc": doc["documentId"]}FAQ
Common questions
What kinds of documents can be indexed?
Which questions does the analysis answer?
Do I need my own Pinecone account?
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
Draft email replies from your FAQ Google Doc
New customer emails get a draft reply in Gmail based on the answers in your FAQ Google Doc, ready for you to check and send.
See how it worksGive your Telegram bot a long-term memory
Tell your Telegram bot things as they come up and ask about them later; it remembers what you said and keeps a running notes Doc.
See how it worksDraft Google Docs from your stored research
Add a topic to your list and get a first draft in Google Docs built from the notes in your knowledge base.
See how it worksKeep exploring
Set up “Index reports in Pinecone and write an analysis to Google Docs” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.