Skip to content

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.

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 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

  1. Every night, ClickRuntime lists the Google Docs in your folder and checks which ones are new or changed since the last run.

  2. Each changed document is split into chunks and written to your Pinecone index, replacing its earlier entries.

  3. 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

RunsOn a schedule
Index new documents into Pinecone nightly and email what changedtoday, 9:00Succeeded
Email · Knowledge baseKnowledge base: 3 files indexed Added: Returns policy 2026 Updated: Shipping FAQ Updated: Wholesale price list

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

  • 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

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_pinecone_knowledge_base_in_sync_and_email_a_report.pyexample
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?
Google Docs in the folder you choose. Convert PDFs and Word files to Google Docs to include them.
Are old versions removed?
Yes. When a file changes, its earlier entries are replaced with the new text.
Who gets the email?
You, from your own Gmail. Add teammates if they also rely on the index.
What permissions does it need?
Pinecone write; gmail.send. 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 runs (on a schedule). Checks that find nothing to do 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 “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.