Every 5-10 minutes
Label new emails automatically
New mail is sorted into labels like Inquiry, Invoice and Newsletter within minutes of arriving.
- Runs
- Every 5-10 minutes
- Apps
- Gmail
- AI
- Yes, uses the built-in AI allowance
- Access
- read+write (gmail.modify)
Send this to your assistant
Create a ClickRuntime automation: every 10 minutes, sort my new emails into inquiry, invoice, newsletter, notification or action needed, and apply the matching Gmail label. Create the label if it doesn't exist.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A Gmail inbox that mixes customer enquiries, supplier invoices, newsletters and personal messages forces you to sort by eye. Filters help, but they match fixed words, so an enquiry that does not include the usual phrase lands unsorted, and a newsletter from a new sender slips through. Creating and maintaining dozens of filter rules is a chore that most people stop doing after a month.
Every 5 to 10 minutes, new messages since the last one seen are listed and the subject, sender and a snippet are read. ClickRuntime's built-in AI chooses a category such as Inquiry, Invoice or Newsletter, and the matching label is added in Gmail, created first if it does not exist yet.
Freelancers, small business owners and anyone who manages a busy personal and work mailbox will use it.
What you get out of it
Labels follow meaning, not keywords
The AI understands what a message is about, so an enquiry worded in an unusual way still gets the Inquiry label, which fixed filters would have missed. Fewer misses means fewer awkward apologies later.
Invoices are easy to find at tax time
With every invoice labeled as it arrives, collecting a year of them for an accountant means opening a single label instead of searching the whole mailbox. That saves a lot of frantic searching in the weeks before a filing deadline.
Newsletters stay out of the way
Labeled newsletters can be skipped during the day and read in one go, so the inbox view shows the messages that need action. Reading them in one sitting is also more enjoyable.
No filter rules to maintain
There is nothing to write or update when a new sender appears, because the categories are chosen from the content and not from a list of addresses. Your attention stays on work rather than on maintaining rules.
New labels appear on their own
If a category does not exist yet it is created, which keeps the setup working as your mix of mail changes without a manual visit to Gmail settings. Flexible categories suit work that changes from month to month.
How it works
What happens, step by step
Every 5 to 10 minutes ClickRuntime checks your Gmail inbox for emails that arrived since its last check.
For each new email it looks at the sender, subject and opening lines.
AI picks the best label from your list, such as Inquiry, Invoice, Newsletter, Notification or Action needed.
The label is added to the email in Gmail, and created first if it doesn't exist yet.
Before it runs live
- 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 Gmail steps into one automation
Under the hood
The code that runs this automation
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, report_fetched, credentials, state, ai
LABELS = ["Inquiry", "Invoice", "Newsletter", "Notification", "Action needed"]
@on_trigger
def run(event):
gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
after = state.get("after") or "1d"
q = f"in:inbox after:{after}" if after.isdigit() else "in:inbox newer_than:1d"
msgs = gmail.users().messages().list(userId="me", q=q, maxResults=50).execute().get("messages", [])
done = set(state.get("done") or [])
new = [m for m in msgs if m["id"] not in done]
report_fetched(len(new))
if not new:
return {"summary": "Nothing new"}
existing = {l["name"]: l["id"] for l in gmail.users().labels().list(userId="me").execute()["labels"]}
for m in new:
meta = gmail.users().messages().get(userId="me", id=m["id"], format="metadata",
metadataHeaders=["From", "Subject"]).execute()
heads = {h["name"]: h["value"] for h in meta["payload"]["headers"]}
label = ai.generate(f"Pick one of {LABELS} for this email. Reply with the label only.\n"
f"From: {heads.get('From')}\nSubject: {heads.get('Subject')}\n{meta['snippet']}",
max_output_tokens=10).text.strip()
label = label if label in LABELS else "Action needed"
if label not in existing:
existing[label] = gmail.users().labels().create(userId="me", body={"name": label}).execute()["id"]
gmail.users().messages().modify(userId="me", id=m["id"], body={"addLabelIds": [existing[label]]}).execute()
done.add(m["id"])
state.set("done", sorted(done)[-1000:])
return {"labelled": len(new)}FAQ
Common questions
Can I choose my own categories?
Does it change or move my emails?
Does it label old emails or only new ones?
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
Get 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 worksGet pinged when an important email arrives
Emails from the people or companies you care about are flagged within minutes, with sender, subject and a link.
See how it worksGet an inbox summary twice a day
Twice a day you get one email listing what came in and what you need to act on.
See how it worksKeep exploring
Set up “Label new emails automatically” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.