Skip to content

Every 15 minutes

Save supplier attachments to S3 and log their details in a sheet

Attachments from your suppliers' emails are saved to S3, and the invoice number, date and total from each one are added to your sheet with a link to the file.

Runs
Every 15 minutes
Apps
AWS, Google Sheets
AI
Yes, uses the built-in AI allowance
Access
s3:PutObject; Sheets write

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, take attachments from new emails from my suppliers, upload them to S3, extract invoice number, date and total with AI, and add a row to my Documents sheet.

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

Supplier documents arrive by email and live there: invoices, delivery notes, certificates. When the accountant or an auditor asks for last March's invoices, someone spends an hour searching inboxes and forwarding attachments.

Saving each attachment to S3 as it arrives, with its key details in a sheet, gives you a single searchable register of supplier documents with a link to every file.

What you get out of it

  • Every document in one place

    Attachments are stored together in your bucket, not scattered across personal inboxes.

  • Find anything in seconds

    The sheet lets you filter by supplier, date or amount and open the file from the row.

  • Ready for your accountant

    Handing over a quarter's invoices means sharing a filtered sheet, not forwarding emails.

  • Safe from inbox clean-ups

    Files survive even if the original email is deleted.

How it works

What happens, step by step

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

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

  3. AI reads the email and picks out the invoice number, date and total.

  4. It adds a row to your Documents sheet with those details and the file's S3 path.

  5. Emails already handled are remembered, so files aren't saved twice.

Before it runs live

  • Connect AWS
  • Connect your Google Sheets account and pick the spreadsheets it may use

What you get

RunsEvery 15 minutes
Save supplier attachments to S3 and log their details in a sheettoday, 9:00Succeeded
Google Sheets · Documentsnorthwind.com · invoice-2291.pdf · INV-2291 · 2026-10-12 · 1280.00 · s3://northwind-files/northwind.com/…

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 Google Sheets 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.
store_email_attachments_in_s3_and_extracted_data_in_sheets.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, ai, report_fetched

SHEET_ID = "your-spreadsheet-id"
QUERY = "has:attachment from:(@northwind.com OR @acme-supply.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, rows = 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(">")
        f = ai.generate(f"Return invoice number, date (YYYY-MM-DD) and total from:\n{full['snippet']}", max_output_tokens=80, json_schema={"type": "object",
                        "properties": {"number": {"type": "string"}, "date": {"type": "string"}, "total": {"type": "number"}}}).json
        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"]
            key = f"{date.today():%Y/%m}/{sender}/{m['id']}-{p['filename']}"
            s3.put_object(Bucket=BUCKET, Key=key, Body=base64.urlsafe_b64decode(data))
            rows.append([sender, p["filename"], f.get("number"), f.get("date"), f.get("total"), f"s3://{BUCKET}/{key}"])
        done.add(m["id"])
    build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).spreadsheets().values().append(spreadsheetId=SHEET_ID, range="Documents!A:F", valueInputOption="RAW", body={"values": rows}).execute()
    state.set("done", list(done)[-1000:])
    return {"emails": len(msgs), "files": len(rows)}

FAQ

Common questions

Which emails are included?
Emails with attachments from the supplier addresses or domains you list.
What if a document isn't an invoice?
It's still saved to S3 and logged; the invoice fields are simply left blank.
How are files organised in S3?
By date and sender, for example 2026/10/northwind.com/invoice-2291.pdf.
What permissions does it need?
s3:PutObject; Sheets write. 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 “Save supplier attachments to S3 and log their details in a sheet” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.