Skip to content

Daily

Clean up your inbox every night

Old promotions, social mail and spam go to trash and read mail is archived, so your inbox only holds what's current.

Runs
Daily
Apps
Gmail
AI
Not needed
Access
read+write (gmail.modify)

Send this to your assistant

Create a ClickRuntime automation: every night, move emails in Spam, Promotions and Social older than 7 days to trash, archive inbox emails older than a day unless they're starred, and email me how many were moved.

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

An inbox that is never cleaned becomes a liability. Tens of thousands of old promotions, social notifications and read mail make search slower and storage fuller, and the emails that matter are harder to spot. People plan to spend a Sunday clearing it, never do, and the number just keeps climbing. Gmail's storage limit then becomes a surprise bill or a blocked inbox.

Each day, searches by category and age find mail that does not need to stay: Spam, Promotions, Social and old messages that you have already read. A batch operation removes them from the inbox or moves them to trash, and you receive an email with the count, so you know what was done.

Anyone with an old, crowded Gmail account, and especially people close to their storage quota, will notice the difference.

What you get out of it

  • Storage pressure goes away

    Clearing bulk mail regularly keeps you under the Gmail quota, which avoids paying for extra space or suddenly being unable to receive messages. Those savings are most welcome for people on a free account.

  • Search gets faster and cleaner

    With old promotions gone, results show real conversations, so finding an invoice or a thread from last year no longer means filtering through noise. You find what you need in a few seconds instead of a few minutes.

  • Cleanup happens in small daily steps

    A few messages removed each day never turns into a giant job, and you never reach the point where cleaning feels impossible. Tiny daily steps are easy for the system to repeat without any fuss at all.

  • The count keeps you informed

    A daily email with the number of messages cleared tells you that the process is running and would reveal a sudden jump caused by a change in your mail flow.

  • Important mail stays untouched

    Searches use categories and age, and read status, so conversations with people and recent unread mail are left alone. Rules based on age and category keep the process predictable and safe.

How it works

What happens, step by step

  1. Every night ClickRuntime searches your Gmail for the kinds of mail you no longer need, such as old promotions and social updates.

  2. Matching emails are moved to the trash or archived out of your inbox, following the rules you set.

  3. Your important mail is left where it is.

  4. You get a short email saying how many messages were trashed and how many were archived.

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

RunsDaily
Clean up your inbox every nighttoday, 9:00Succeeded
Email · Inbox clean-upMoved 214 emails to trash and archived 37.

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

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • 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.
scheduled_inbox_clean_up.pyexample
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, notify

def ids(gmail, q):
    out, token = [], None
    while True:
        page = gmail.users().messages().list(userId="me", q=q, maxResults=500, pageToken=token).execute()
        out += [m["id"] for m in page.get("messages", [])]
        token = page.get("nextPageToken")
        if not token:
            return out

@on_trigger
def run(event):
    gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    trash = ids(gmail, "{in:spam category:promotions category:social} older_than:7d")
    archive = ids(gmail, "in:inbox older_than:1d -is:starred")
    for i in range(0, len(trash), 1000):
        gmail.users().messages().batchModify(userId="me", body={"ids": trash[i:i + 1000], "addLabelIds": ["TRASH"]}).execute()
    for i in range(0, len(archive), 1000):
        gmail.users().messages().batchModify(userId="me", body={"ids": archive[i:i + 1000], "removeLabelIds": ["INBOX"]}).execute()
    notify.email_me("Inbox clean-up", f"Moved {len(trash)} emails to trash and archived {len(archive)}.")
    return {"trashed": len(trash), "archived": len(archive)}

FAQ

Common questions

Does it permanently delete my emails?
Mail moved to trash stays there for 30 days under Gmail's normal rules before being removed, so there is time to recover a mistake. Archiving only removes mail from the inbox and keeps it searchable.
Which mail is touched?
Spam, Promotions and Social categories, and read mail older than a set number of days. Unread mail and anything from conversations with people are excluded by default, and you can choose different age limits for each group.
Can I protect specific senders?
Yes. Add exclusions for addresses or labels you never want touched, such as your bank or an important client, and the searches will skip them. You approve the updated rules before they run. Your own exceptions are respected.
What permissions does it need?
read+write (gmail.modify). Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (daily). Checks that find nothing to do 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 “Clean up your inbox every night” from your assistant

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