n8n

How to Automate Gmail Inbox Cleanup?

Start each day with a focused inbox. The workflow runs on a set schedule and keeps only starred Gmail messages in your inbox while archiving the rest. It fits teams and managers who want less clutter and a clear view of what matters.

At midnight on work days, a schedule trigger starts the run. It looks at recent inbox threads from the last day in Gmail, loads each full thread, and checks if any message is starred. Threads with a star stay visible. All other threads go through a loop that removes the INBOX label on each message or at the thread level, which moves them to All Mail. By filtering with the Gmail STARRED label, your inbox shows only items you marked as important, so you can act faster in the morning.

You only need a Gmail account and permission for n8n to read mail and change labels. Adjust the cron time and the date filter to match your routine, such as daily for personal email. Many users save 20 to 30 minutes each work day and can handle higher email volume without extra effort, since starring becomes the simple way to protect key messages.

What are the key features?

  • Runs on a weekday midnight schedule to clean your inbox before the work day starts.
  • Pulls recent inbox threads and loads full thread details from Gmail.
  • Checks for the Gmail STARRED label and leaves those threads in the inbox.
  • Splits threads into individual messages for precise control using item lists.
  • Removes the INBOX label from non starred items to archive them to All Mail.
  • Supports archiving at message or thread level for different cleanup styles.
  • Uses Gmail OAuth2 credentials for secure access and label changes.

What are the benefits?

  • Reduce manual triage from 30 minutes to 2 minutes each morning
  • Streamline inbox views by keeping only starred items front and center
  • Eliminate misfile errors by using one simple star rule
  • Handle higher email volume without extra effort during busy weeks
  • Connect directly to Gmail for fast setup and low maintenance

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Gmail. See the Tools Required section above for links to create accounts with these services.
  3. Open any Gmail node, then in the Credential to connect with dropdown click Create new credential and follow the on screen steps to sign in with Google. Allow permission to read mail and modify labels. Name the credential clearly, for example Work Gmail.
  4. Return to the Gmail nodes and select your new Gmail credential in the Credential to connect with field.
  5. Open the Schedule Trigger node and confirm the cron expression is 0 0 * * 1-5 for weekdays at midnight. Change it to run every day if you prefer daily cleanup.
  6. Open the node that gets inbox threads and confirm the search uses label inbox and a recent time window. Adjust the time window if you want a different lookback period.
  7. Review the filter step. The logic checks for the STARRED label. Star a few test emails and leave some unstarred so you can see the difference clearly.
  8. Click Execute workflow once to test. After the run, refresh Gmail. Starred emails should remain in the inbox. Other emails should move to All Mail.
  9. If nothing changes, check the Gmail credential scopes, make sure the Gmail API is enabled for your account, and confirm that the remove labels operation uses the INBOX label.
  10. If you see both message and thread archiving in one run, pick one path for your use case. Use only the thread removal for whole thread cleanup or only the message removal for fine control.
  11. Turn on the workflow. Monitor the first week of runs in the n8n executions list and adjust the schedule or time window as needed.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Gmail

Sign up

No cost: Personal Gmail (Gmail API has no usage-based pricing; quotas apply)

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.