My inbox has never been cleaner thanks to this free open-source tool

I used to dread opening my Gmail inbox—it was hard to tell which emails were useful and which weren’t. Important messages were buried among ads, promotions, and spam, making navigation a chore. After spending a day cleaning it manually, I wondered if there was a way to keep it clean with less effort.

I researched several automation tools and ultimately settled on a free, open-source tool that efficiently accomplishes the task. It’s called n8n (pronounced n-eight-n), a tool for automating workflows without code. I was able to set up an automation (workflow) that manages my inbox for me, ensuring that it remains clean and organized at all times.

n8n in a nutshell

One of the best automation tools that works on any system

A blank workflow in n8n

n8n is a browser-based automation tool that lets you build workflows with a node-based visual builder. It’s self-hosted, meaning you have full control over your data and can run it on your own server. I love how it has a user-friendly interface that lets me effortlessly connect apps (it has over 400 integrations), actions, and AI to create productivity-enhancing workflows.

Automating with Zapier on a computer screen

6 Tasks I Automate Every Month to Avoid Burnout

A few simple steps have stopped my burnout symptoms and allowed me to be more productive.

It’s worth mentioning that you can run n8n in the cloud. However, that requires a subscription plan, whereas the self-hosted version is completely free—that’s what I’ll cover in this article. Also, don’t be put off by the mention of self-hosted, as it’s very easy to set up.

Also, keep in mind that n8n doesn’t use the traditional open-source license like MIT or Apache. It uses a Sustainable Use License (formerly called Fair Code License), you can do nearly anything with the code except sell it. To use it for commercial purposes, you must obtain a commercial license.

Getting the n8n editor to work

All you need is Docker and an n8n image

An n8n container running in Docker

You can run n8n on your computer in several ways, but I found that Docker is the easiest to use. Docker allows me to run applications in portable containers. I can easily set up n8n without dealing with dependencies or compatibility issues. I use Docker Desktop for Windows, but it’s also available on macOS and Linux.

In Docker, I went to the Images tab, searched for the n8n image, and pulled it. Running it created a n8n container. I was able to access the n8n editor by entering in my browser.

If it’s your first time running n8n, you will need to create your login information. Don’t worry; it doesn’t get sent to a remote server somewhere. All data is stored locally on your computer.

I didn’t need to build the workflow from scratch

Getting started immediately

Before I create anything custom with any tool, I like to check for any templates I can use to speed things up. Luckily, I found an n8n template for automatic email labeling on the official site. I was confident that I could easily configure it too, since I have experience with Zapier and Power Automate workflows. However, if I want to create custom workflows, I would need to dive deeper or reverse engineer the templates. But that’s for another day.

Businessman working on laptop with automation symbols hovering above his hands (1)

How I Automate My Daily Tasks in Windows 11

Boring Windows tasks? Not anymore with Power Automate.

The template checks for new emails at set intervals. It then uses AI (the default is an OpenAI model) to analyze each email’s contents, including sender, subject, body, and keywords, and assigns the appropriate label. Gmail uses labels to organize emails. If it doesn’t find a matching label, it creates a new one for that email.

For example, the workflow will apply an existing Asana label to emails from Asana or those containing Asana-related information. If it’s a marketing, promotional, social, or spam email, the workflow will remove the Inbox label so it doesn’t clutter the inbox and apply the appropriate label.

From the template’s page, I copied the code, pasted it into a text file, and saved it with a .JSON extension. Next, I created a workflow and imported it. After studying what each node does, I was ready to put it to use.

The hardest part of setting up the template

Getting the Google credentials

First, I needed to configure the Gmail Trigger node, which starts the automation when a new email is received. I had to add credentials for my Google account, and it wasn’t easy. I signed in to the Google Cloud Console, enabled the Gmail API, configured the OAuth consent screen, and created the credentials.

There were a lot of errors along the way, but I finally got it done. Afterward, I copied the Client ID and Client Secret and pasted them into the trigger. After the credentials checked out, all the other Gmail nodes, such as Gmail — read labels and Gmail — get message, automatically used them.

Set up the AI agent

The default OpenAI model didn’t work for me

The next node I needed to add credentials to was Open AI Chat Model1. It’s the AI mode that analyzes the emails for the Gmail labeling agent.

I went to the OpenAI website and created an API key. Unfortunately, that didn’t work because I was out of AI credits. Apparently, OpenAI has stopped giving free credits to new accounts for now (this might change in the future). It asked me to pay at least $5 to get more—I wasn’t going to do that. I decided to use Gemini instead, which allows me to perform several hundred requests a day for free.

I disconnected Open AI Chat Model1 from the Gmail labeling agent. Next, I added a Google Gemini Chat Model node and connected that to the Gmail labeling agent instead. Afterward, I went to Google AI Studio, created an API key, and used that one instead.

Enjoying my highly organized Gmail account

With everything set up, I clicked Execute Flow to see if everything worked. Sure enough, it ran buttery smooth. I no longer need to clean my email manually since the workflow takes care of it. I also didn’t need to create a custom one since there was a template available for my exact needs. Now I wish I had done this sooner.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top