Every 15 minutes
Back up attachments from chosen senders to S3
Attachments from the senders you list are saved to your S3 bucket by date and sender, and you get an email summary of what each one contains.
- Runs
- Every 15 minutes
- Apps
- AWS, Gmail
- AI
- Yes, uses the built-in AI allowance
- Access
- Gmail read; s3:PutObject
Send this to your assistant
Create a ClickRuntime automation: every 15 minutes, take attachments from new Gmail messages from my listed senders, upload them to S3 under date/sender, and email me a short AI summary of each file's key details.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Contracts, statements and invoices arrive as attachments and stay in Gmail. Mailbox size limits, accidental deletions or a departing employee's account can take them with them.
Copying important attachments into S3 as they arrive gives you a durable archive organised by date and sender, and a short summary email tells you what came in without opening each file.
What you get out of it
A durable copy of key documents
Attachments survive inbox clean-ups, deleted emails and account changes.
Organised automatically
Files are filed by date and sender, so they're easy to browse.
Know what arrived
The summary email lists each file with its key details.
Only what matters
Only senders on your list are backed up, not every newsletter.
How it works
What happens, step by step
Every 15 minutes, ClickRuntime checks Gmail for new emails with attachments from your listed senders.
It saves each attachment to your S3 bucket in a folder for the date and sender.
AI writes a one-line summary of each email's key details.
You get an email listing the files saved, with their summaries.
Handled emails are remembered, so nothing is saved twice.
Before it runs live
- Connect AWS
- Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
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 AWS and Gmail steps into one automation
Under the hood
The code that runs this automation
import base64, boto3
from datetime import date
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, state, notify, ai, report_fetched
QUERY = "has:attachment from:(bank@northwind-bank.com OR @acme-accounting.com) newer_than:2d"
REGION, BUCKET = "us-east-1", "northwind-files"
def aws(service):
return boto3.client(service, region_name=REGION, aws_access_key_id=credentials.secret("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=credentials.secret("AWS_SECRET_ACCESS_KEY"))
@on_trigger
def run(event):
gmail, done = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False), set(state.get("done") or [])
msgs = [m for m in gmail.users().messages().list(userId="me", q=QUERY).execute().get("messages", []) if m["id"] not in done]
report_fetched(len(msgs))
if not msgs:
return {"summary": "Nothing new"}
s3, lines = aws("s3"), []
for m in msgs:
full = gmail.users().messages().get(userId="me", id=m["id"]).execute()
sender = next(h["value"] for h in full["payload"]["headers"] if h["name"] == "From").split("<")[-1].strip(">")
for p in [p for p in full["payload"].get("parts", []) if p.get("filename")]:
data = gmail.users().messages().attachments().get(userId="me", messageId=m["id"], id=p["body"]["attachmentId"]).execute()["data"]
s3.put_object(Bucket=BUCKET, Key=f"attachments/{date.today()}/{sender}/{p['filename']}", Body=base64.urlsafe_b64decode(data))
try:
summary = ai.generate(f"One line: key details (type, amount, dates) of {p['filename']} from: {full['snippet']}", max_output_tokens=50).text
except ai.AIError:
summary = full["snippet"][:100]
lines.append(f"{sender} · {p['filename']}: {summary}")
done.add(m["id"])
notify.email_me(f"{len(lines)} attachments backed up to S3", "\n".join(lines))
state.set("done", list(done)[-1000:])
return {"files": len(lines)}FAQ
Common questions
Which senders are included?
Does the summary read the attachment itself?
What if AI isn't available?
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
Save a PDF receipt to S3 for each payment and email the link
When a payment succeeds, a PDF receipt is created, stored in your S3 bucket, and the customer gets an email from your Gmail with a private download link.
See how it worksLabel new emails automatically
New mail is sorted into labels like Inquiry, Invoice and Newsletter within minutes of arriving.
See how it worksGet draft replies to emails that need an answer
Emails that need a reply get a draft in the same thread, ready for you to edit and send.
See how it worksKeep exploring
Set up “Back up attachments from chosen senders to S3” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.