Every 15 minutes
Post a summary of each invoice uploaded to S3 to Slack
Each new invoice in your S3 bucket is read, and Slack gets the vendor, amount and due date within 15 minutes.
- Runs
- Every 15 minutes
- Apps
- AWS, Slack
- AI
- Optional
- Access
- s3:ListBucket/GetObject, textract:AnalyzeExpense; chat:write
Send this to your assistant
Create a ClickRuntime automation: every 15 minutes, check my invoices bucket for new files, read the vendor, total and due date with Textract, and post a summary to #finance.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A business collects invoices in an S3 bucket from a scanner, an upload form or another system. Files arrive, but nobody knows what's in them until someone opens each PDF, and due dates get missed.
Reading each new invoice as it lands and posting the key facts to Slack tells finance what's arrived and when it's due, without opening a single file.
What you get out of it
Know what's arrived
Finance sees every new invoice with its vendor and amount the same day it's uploaded.
Fewer missed due dates
The due date is in the message, so payments can be scheduled straight away.
No opening PDFs
Key details are read from the file, including scanned invoices.
A running record
The channel becomes a simple log of invoices received.
How it works
What happens, step by step
Every 15 minutes, ClickRuntime looks for files added to your invoices bucket since the last check.
Amazon Textract reads each invoice and finds the vendor, total and due date.
If AI is available, it adds a short line describing what the invoice is for.
It posts a summary of each invoice to #finance in Slack.
It remembers the newest file it handled, so nothing is posted twice.
Before it runs live
- Connect AWS
- Connect Slack, then invite the app to the channel (type /invite @ClickRuntime there)
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 Google Sheets
- Combine it with other AWS and Slack steps into one automation
Under the hood
The code that runs this automation
import boto3
from clickruntime import on_trigger, credentials, http, state, notify, ai, report_fetched
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):
s3, since = aws("s3"), state.get("since") or ""
objs = [o for o in s3.list_objects_v2(Bucket=BUCKET, Prefix="invoices/").get("Contents", []) if o["LastModified"].isoformat() > since]
report_fetched(len(objs))
if not objs:
return {"summary": "Nothing new"}
tx = aws("textract")
for o in objs:
doc = tx.analyze_expense(Document={"S3Object": {"Bucket": BUCKET, "Name": o["Key"]}})["ExpenseDocuments"][0]
f = {x["Type"]["Text"]: x.get("ValueDetection", {}).get("Text", "") for x in doc["SummaryFields"]}
items = ", ".join(i["ValueDetection"]["Text"] for g in doc.get("LineItemGroups", []) for li in g["LineItems"] for i in li["LineItemExpenseFields"] if i["Type"]["Text"] == "ITEM")
text = f"🧾 {f.get('VENDOR_NAME', '?')}: {f.get('TOTAL', '?')}, due {f.get('DUE_DATE', 'not stated')} ({o['Key']})"
try:
text += "\n" + ai.generate(f"In under 15 words, what is this invoice for? {items[:1000]}", max_output_tokens=40).text
except ai.AIError:
pass
notify.slack(text, channel="#finance")
state.set("since", max(o["LastModified"].isoformat() for o in objs))
return {"posted": len(objs)}FAQ
Common questions
Does it work with scanned invoices?
What AWS permissions does it need?
What does AI add?
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
Back up your Airtable base to S3 every night
Every night each table in your Airtable base is saved as a CSV in a dated S3 folder, backups older than 30 days are removed, and Slack confirms it worked.
See how it worksMove old Salesforce files to S3 and report in Slack
Every week, Salesforce files older than a year are moved to your S3 bucket to free up storage, and Slack reports how many files and megabytes were archived.
See how it worksSave a copy of any web page to S3 and share the link in Slack
Send a URL to your automation's link and a copy of the page is saved to S3, with a download link posted to your research channel.
See how it worksKeep exploring
Set up “Post a summary of each invoice uploaded to S3 to Slack” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.