[KongchangAI]
· 3 min read· 1,600 words

Build Your First AI Agent with n8n from Scratch: A Free Email Assistant Tutorial

Build Your First AI Agent with n8n from Scratch: A Free Email Assistant Tutorial

Build a free AI email-sorting agent with n8n in one weekend for under $10/month.

This article walks through building a personal AI inbox-sorting agent using the open-source tool n8n — no coding required, completable in a weekend. The n8n Community Edition is free to self-host; actual costs come from a small server ($5–$10/month) and AI model tokens (nearly zero). The five-step process covers installing n8n, assembling a schedule-triggered Gmail + AI agent workflow, choosing a local or cheap API model as the "brain," setting read-only and human-in-the-loop safety guardrails, and using a schedule trigger for 24/7 operation. The agent reads emails, writes summaries, flags priorities, and drafts replies — but never sends anything automatically. The article also honestly addresses four key limitations: AI misreads, API changes, credential security, and a non-trivial learning curve.

Every morning, imagine a version of you that never sleeps has already read your emails, organized your tasks, and only alerts you when something truly important comes up. This isn't science fiction — it's something you can build for free over a single weekend. YouTube creator Lina Torres, who specializes in building AI workflows, walks through a hands-on tutorial demonstrating how to use the open-source tool n8n to build your first "inbox sorting" AI agent — no code required, and no inflated marketing promises.

The Truth About "Free": The Software Is Free, But Not Everything Is

Whenever someone says "free," there's usually an asterisk. The tool used in this tutorial, n8n, has a Community Edition that is genuinely free to self-host forever, with no limits on the number of workflows you can run — that part is real.

AI brains consume tokens

The asterisk is this: the software is free, but the computer running it isn't. You can run it on your own laptop at zero cost while learning, or rent a small virtual server for $5–$10 a month. The AI model powering the agent's "brain" does consume tokens, but the author promises to show you how to keep that cost close to zero.

The honest summary: "free-ish" — free software, cheap server, nearly free AI brain. For most people who just want to try it out, the math works.

What You're Building: An Inbox Sorting Agent

The goal of this first project is clearly defined. Every morning, it reads your new emails, writes a one-sentence summary for each, flags anything that must be handled today, and drafts replies for simple messages.

The key rule: it never sends anything on its own. One agent, one job — specifically handling the kind of tedious work that eats up an hour of your day. A small, clearly scoped project like this is exactly the right entry point for beginners.

Five Steps from Setup to 24/7 Operation

Step 1: Get n8n Running

If you have Docker, a single command does it: run the n8n image, map port 5678, then open it in your browser. No Docker? No problem — there's a desktop version for testing, and most server hosts offer one-click templates that deploy in about eight minutes.

One-click templates deploy in about eight minutes

The author offers two pieces of hard-won advice: allocate at least 2GB of memory, and pin a stable version rather than chasing weekly beta updates.

Step 2: Build the Workflow

Every n8n workflow follows the same skeleton: a trigger, a series of steps, and an endpoint. For this project, the trigger is a Schedule Node set to fire every morning at 7 a.m., followed by a Gmail node that fetches unread emails, and finally the star of the show — the AI Agent node.

Connect those three boxes with lines and you have an automated flow. The key to upgrading a regular workflow into an "agent" is equipping the AI node with tools: email search, calendar, note-taking apps. The agent decides on its own which tool to call for each email — this decision-making capacity is the fundamental difference between a workflow and an agent.

The core distinction between a Workflow and an Agent is worth spelling out here. A traditional workflow is a pre-written linear script: step A completes, then step B executes — fixed logic, no autonomous decision-making. An AI agent introduces a "plan-then-act" loop (the ReAct pattern: Reasoning + Acting): the model first "thinks" about which tool is needed for the current goal, calls it, observes the result, then decides the next step. When processing email, an agent might reason: "This email mentions a meeting — I should check the calendar for conflicts" — something a regular workflow would never do, mechanically applying the same operations to every message. This difference allows agents to handle real-world tasks with variable structure, but it also introduces unpredictability. The agent may occasionally make decisions you didn't anticipate, which is exactly why the guardrails in Step 4 exist.

Step 3: Choose the Brain

There are two honest options for models. First, run a local model via Ollama on your own machine — zero cost per message, and plenty capable for inbox sorting tasks. Second, connect to a cheap API model by pasting an API key into n8n's credential manager — just a few cents per thousand emails.

The author's own real-world setup is a hybrid: boring sorting tasks go to the local model, and a better API model is only called when a draft reply needs to "sound like a human." Whichever you choose, set a spending cap on day one — that's the difference between "a little experiment" and "a shocking bill."

Ollama is a tool that lets everyday users run open-source large language models (like Llama 3, Mistral, Gemma, etc.) on their local computer — no internet connection required, no API key, all inference runs on your own hardware. The advantages are strong privacy (your email content never gets uploaded to any external server) and zero marginal cost. The trade-off is hardware requirements: running a 7B-parameter model typically needs at least 8GB of memory, and speed is limited by your local GPU or CPU. For structured tasks like inbox sorting, where language fluency isn't critical, a small local model usually performs well enough — which is exactly why the author delegates "boring sorting" to local models. Tokens are the basic unit by which AI models charge for and process text: roughly 750 English words ≈ 1,000 tokens. Chinese text typically consumes more tokens per character due to encoding differences.

Step 4: Put Guardrails on the Agent

This is the most important part of the tutorial — and the part new users should take most seriously. Three "guardrail rules":

  • Read-only first: The agent can only read the inbox. It cannot send, delete, or archive anything.
  • Human in the loop: Every draft goes into a review queue (a chat message or a note, for example) and nothing goes out until you click approve.
  • Write rules in plain language: "Do not send anything without asking" and "Do not touch any email flagged as financial." Write your rules like you're briefing an intern, and review the execution logs like you're auditing a credit card statement.

Trust the agent, but verify the agent.

Human in the loop is a safety principle in AI system design that mandates a mandatory human review step at critical decision points in an automated process, ensuring that high-risk operations (sending emails, modifying data, executing payments) cannot be carried out without explicit human approval. The concept originated in high-reliability fields like aviation and medicine, and has been widely adopted in AI agent development in recent years. In n8n's implementation, draft replies don't directly trigger the "send" API — instead, they're written to a to-do item or message, and a subsequent node completes the send only after user confirmation. This structurally eliminates the risk of "the AI misjudges and automatically executes an irreversible action." Until you've built enough confidence in a newly deployed agent, every operation involving external output should default to having this human confirmation gate in place.

Step 5: Make It Run 24/7

This is handled by the Schedule trigger. Set it to run every 15 minutes, or every morning at 7 a.m., and n8n will execute it on the server while you sleep. When you wake up, you'll find a pre-sorted inbox, a few draft replies waiting for review, and three truly important emails surfaced at the top. Not magic — just a very reliable intern who comes with their own computer.

Reality Check: Where It Will Go Wrong

The author is candid: tutorials that skip this section are the real clickbait. Four honest limitations:

Now let's ruin the dream: what will go wrong

First, AI sometimes misreads emails, confidently summarizing the wrong thing — which is why the review queue is not optional. Second, APIs change: Google updates an endpoint, and your Gmail node might silently break on some Tuesday night. Third, credential security: API keys stored in n8n require a locked-down server, strong passwords, and staying up to date. Fourth, there's a learning curve — this is not a chat box, and you should budget a full weekend of tinkering before things click.

The real cost is a weekend of setup and ongoing maintenance attention.

The Real Numbers: What Does It Cost Per Month?

Honest figures: software, free forever; using your laptop during the learning phase, free; running it persistently on a small virtual server, $5–$10/month; AI brain on cheap API models, a few cents per day, or zero with local models.

For comparison, n8n's official cloud plan is $20/month, and hiring a virtual assistant costs considerably more. For a personal inbox sorting agent, the total budget stays well under $10/month.

Why n8n and Not the Other 50 Agent Tools

The author gives three reasons and one honest trade-off. First, the Community Edition is free with no execution limits — rare among comparable tools. Second, it's visual: you can see the entire workflow, which means you can debug it. Third, over 1,500 integrations and a large template library mean you rarely need to start from scratch.

The one trade-off: it requires some technical familiarity. If you want zero configuration, chat-based agent tools are simpler — but you'll pay for that convenience every single month.

For anyone willing to invest a weekend learning it, the control n8n gives you and its near-zero running costs are what make the deal genuinely attractive.

#n8n AI agent#inbox sorting automation#no-code AI workflow#self-hosted automation#email AI assistant
Share:

Related articles