Skip to content

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.

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

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

  1. Every 15 minutes, ClickRuntime checks Gmail for new emails with attachments from your listed senders.

  2. It saves each attachment to your S3 bucket in a folder for the date and sender.

  3. AI writes a one-line summary of each email's key details.

  4. You get an email listing the files saved, with their summaries.

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

RunsEvery 15 minutes
Back up attachments from chosen senders to S3today, 9:00Succeeded
Email · Backup summary2 attachments backed up: bank@northwind-bank.com · statement-oct.pdf: October statement, closing balance $18,240

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

  • 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

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.
back_up_gmail_attachments_to_s3.pyexample
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?
The addresses or domains you list, such as your bank, accountant and main suppliers.
Does the summary read the attachment itself?
It summarises from the email text and file names. Full document reading can be added for PDFs with text.
What if AI isn't available?
Files are still backed up and you get a list of saved files without summaries.
What permissions does it need?
Gmail read; s3:PutObject. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new 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 “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.