Every 15 minutes
Create document drafts from new contract PDFs in Drive
Each contract PDF added to your Drive folder produces a draft from your Doc template with the parties, dates and amounts filled in.
- Runs
- Every 15 minutes
- Apps
- Google Docs, Google Drive
- AI
- Yes, uses the built-in AI allowance
- Access
- Drive read+write; Docs write
Send this to your assistant
Create a ClickRuntime automation: when a new contract PDF is added to my Drive folder, extract the parties, dates and amounts and create a draft from my Doc template.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A small legal practice receives signed contracts as PDFs and writes a one-page summary of each for the client file. Every summary means reading the PDF, finding the parties, term, notice period and fees, and typing them into the same template.
Having the template filled in as soon as the PDF lands means the lawyer reviews and corrects a draft instead of retyping the same facts from scratch.
What you get out of it
Less retyping
Names, dates and amounts are copied into the template for you, which removes the slowest and most error-prone part of the job.
The same format for every contract
Every draft uses your template, so summaries in client files look and read the same.
Drafts ready when you are
The document is waiting in Drive by the time someone opens the folder, without anyone starting it.
A person still signs off
The result is a draft to review, so the details are checked before anything goes to a client.
How it works
What happens, step by step
Every few minutes ClickRuntime checks your contracts folder in Google Drive for new PDFs.
It skips any PDF it has already handled.
AI reads the contract and pulls out the parties, key dates and amounts.
It makes a copy of your Doc template, fills in those details and saves the draft in your folder.
Before it runs live
- Connect Google Docs
- Connect Google Drive
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
- 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 Google Drive steps into one automation
Under the hood
The code that runs this automation
from googleapiclient.discovery import build
from google.oauth2.credentials import Credentials
from clickruntime import on_trigger, credentials, state, ai, report_fetched, http
FOLDER, TEMPLATE, FIELDS = "contracts-folder-id", "template-doc-id", ["parties", "start_date", "end_date", "amount"]
@on_trigger
def run(event):
creds = Credentials(credentials.connection("google", "work"))
drive = build("drive", "v3", credentials=creds, cache_discovery=False).files()
seen = state.get("seen") or []
pdfs = [f for f in drive.list(q=f"'{FOLDER}' in parents and mimeType='application/pdf' and trashed=false",
fields="files(id,name)").execute()["files"] if f["id"] not in seen]
report_fetched(len(pdfs))
if not pdfs:
return {"summary": "No new PDFs"}
docs = build("docs", "v1", credentials=creds, cache_discovery=False).documents()
for f in pdfs:
text = drive.copy(fileId=f["id"], body={"mimeType": "application/vnd.google-apps.document"}).execute()
body = http.get(f"https://www.googleapis.com/drive/v3/files/{text['id']}/export", params={"mimeType": "text/plain"},
headers={"Authorization": f"Bearer {creds.token}"}).text[:12000]
drive.delete(fileId=text["id"]).execute()
data = ai.generate(f"Extract {FIELDS} from this contract:\n{body}", max_output_tokens=200,
json_schema={"type": "object", "properties": {k: {"type": "string"} for k in FIELDS}}).json
draft = drive.copy(fileId=TEMPLATE, body={"name": f"Summary - {f['name']}", "parents": [FOLDER]}).execute()
docs.batchUpdate(documentId=draft["id"], body={"requests": [{"replaceAllText": {"containsText": {"text": "{{" + k + "}}"},
"replaceText": v or ""}} for k, v in data.items()]}).execute()
seen.append(f["id"])
state.set("seen", seen[-500:])
return {"drafts": len(pdfs)}FAQ
Common questions
Which fields can it fill in?
What about scanned PDFs?
Where are the drafts saved?
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
Score CVs in a Drive folder and keep a ranked report Doc
Every CV you drop into your Applicants folder is scored against the job description and added to a ranked summary in a Google Doc.
See how it worksTurn PDFs in Drive into two versions of a multiple-choice test
Drop a PDF into your Drive folder and get two different multiple-choice tests on it as Google Docs.
See how it worksGet a Slack summary of each new doc in a Drive folder
Every document that lands in your Drive Inbox folder is summarised and the summary is sent to you in Slack.
See how it worksKeep exploring
Set up “Create document drafts from new contract PDFs in Drive” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.