Every 15 minutes
Summarise PDF attachments arriving in Gmail or Outlook
When a PDF arrives in either your Gmail or your Outlook, you get an email with a short summary of what it says.
- Runs
- Every 15 minutes
- Apps
- Gmail, Outlook
- AI
- Yes, uses the built-in AI allowance
- Access
- gmail.readonly; Mail.Read
Send this to your assistant
Create a ClickRuntime automation: every 15 minutes, check my Gmail and my Outlook for new emails with PDF attachments. Summarise each PDF with AI in five bullet points and email me the summaries with the sender and subject.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A lawyer receives contracts, reports and letters as PDFs in two mailboxes, one for the firm and one for their own practice. Opening every attachment to see whether it needs attention today takes a large part of the day.
A short summary of each PDF, wherever it arrived, shows at a glance which ones need reading now and which can wait.
What you get out of it
Know what is in a PDF before opening it
Five bullet points show what each document is and what it asks for.
Both mailboxes covered
Attachments from Gmail and Outlook are summarised in the same way.
Prioritise your reading
Urgent documents stand out from routine ones.
Summaries in one place
All summaries come to one email address, so nothing is missed in the other inbox.
How it works
What happens, step by step
Every 15 minutes, ClickRuntime checks your Gmail and your Outlook for new emails with PDF attachments.
It reads the text from each PDF.
AI writes a five-point summary of each document.
You get one email with the summaries, each with its sender and subject.
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 Outlook
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 Gmail and Outlook steps into one automation
Under the hood
The code that runs this automation
import base64
import io
from pypdf import PdfReader
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, report_fetched, http, credentials, ai, state, notify
api = lambda name, version: build(name, version, credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
def graph(method, path, **kw):
r = http.request(method, "https://graph.microsoft.com/v1.0" + path, headers={"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}, **kw)
return r.raise_for_status() or (r.json() if r.content else None)
pdf_text = lambda b64: " ".join(p.extract_text() or "" for p in PdfReader(io.BytesIO(base64.b64decode(b64))).pages)[:12000]
@on_trigger
def run(event):
gmail, seen, since = api("gmail", "v1").users().messages(), set(state.get("seen") or []), state.get("since") or "2026-01-01T00:00:00Z"
pdfs = []
for ref in gmail.list(userId="me", q="has:attachment filename:pdf newer_than:1d").execute().get("messages", []):
if ref["id"] in seen:
continue
m = gmail.get(userId="me", id=ref["id"]).execute()
subject = next(h["value"] for h in m["payload"]["headers"] if h["name"] == "Subject")
for p in m["payload"].get("parts", []):
if p.get("filename", "").lower().endswith(".pdf"):
data = gmail.attachments().get(userId="me", messageId=ref["id"], id=p["body"]["attachmentId"]).execute()["data"]
pdfs.append((f"Gmail: {subject}", base64.b64encode(base64.urlsafe_b64decode(data)).decode()))
seen.add(ref["id"])
out = graph("GET", "/me/messages", params={"$filter": f"hasAttachments eq true and receivedDateTime gt {since}", "$select": "id,subject,receivedDateTime"})["value"]
for m in out:
pdfs += [(f"Outlook: {m['subject']}", a["contentBytes"]) for a in graph("GET", f"/me/messages/{m['id']}/attachments")["value"] if a.get("contentType") == "application/pdf"]
report_fetched(len(pdfs))
if not pdfs:
return {"summary": "No new PDFs"}
parts = [f"{label}\n" + ai.generate(pdf_text(b64), system="Summarise this document in 5 bullet points, noting any deadline.", max_output_tokens=300).text for label, b64 in pdfs]
notify.email_me(f"{len(pdfs)} PDFs summarised", "\n\n".join(parts))
state.set("seen", sorted(seen)[-3000:])
state.set("since", max([since] + [m["receivedDateTime"] for m in out]))
return {"pdfs": len(pdfs)}FAQ
Common questions
How long can the PDFs be?
Does it work on scanned documents?
Are the documents stored anywhere?
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
Triage your Gmail and Outlook inboxes with one digest
Both inboxes are sorted into the same categories, and you get one digest of the emails that need you.
See how it worksSend thank-you emails from the right mailbox for each brand
New buyers get a thank-you from your Gmail or your Outlook, depending on which brand they bought from.
See how it worksCheck whether your emails land in the inbox at Gmail and Outlook
Every week a test email is sent each way between your Gmail and Outlook, and you learn whether it reached the inbox or spam and whether SPF, DKIM and DMARC passed.
See how it worksKeep exploring
Set up “Summarise PDF attachments arriving in Gmail or Outlook” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.