Skip to content

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.

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

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

  1. Every 5 to 10 minutes ClickRuntime checks your Gmail inbox for emails that arrived since its last check.

  2. For each new email it looks at the sender, subject and opening lines.

  3. AI picks the best label from your list, such as Inquiry, Invoice, Newsletter, Notification or Action needed.

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

RunsEvery 5-10 minutes
Label new emails automaticallytoday, 9:00Succeeded
Gmail · labelsInvoice: “Invoice INV-2291 from Northwind Supplies” Inquiry: “Question about your team plan” from ops@acme.example

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 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.
ai_auto_labelling_of_new_mail.pyexample
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?
Yes. Give your AI assistant the list, for example Inquiry, Invoice, Newsletter and Personal, and the AI picks from that list only. You can add or remove categories later and approve the change. Short, clear names work best for the AI.
Does it change or move my emails?
It only adds a label. Messages stay in the inbox unless you also ask for archiving, so the sorting is non-destructive and you can remove any label if the AI picked the wrong one. You stay in full control of what is moved.
Does it label old emails or only new ones?
Only new messages that arrive after it starts. Older mail is untouched, since the run continues from the last message it saw. If you want a one-time pass over existing mail, that can be requested separately.
What permissions does it need?
read+write (gmail.modify). 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 “Label new emails automatically” from your assistant

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