How to Build an AI Agent with n8n for Free
A guide to Install n8n on your own computer, Connect a free AI model, Give the agent a job, memory, and tools, Put the agent on autopilot, Test, activate, and keep it free
An AI agent is not a chatbot: it decides which tools to call, reads the results, and keeps working until the job is done. You can build one this afternoon without writing code and without paying for a platform, because n8n's self-hosted community edition is free and both Google and Groq give away model access on their free tiers. This guide walks through the whole build in five parts: installing n8n, connecting a free model, giving the agent a prompt, memory and tools, putting it on a schedule, and keeping it running safely. If you can install an app and paste a key, you can finish this. Browse more builds in the AI Automation and Agents category.
How do you build an AI Agent with n8n for Free?
Howcompass | How to Build an AI Agent with n8n for FreeInstall n8n on your own computer
HowcompassCheck your computer before you install
Confirm your machine has at least 8 GB of RAM and 2 GB of free disk before downloading anything, because Docker plus the n8n image needs that headroom to run comfortably. Close heavy apps while you build; a browser with forty tabs and a video call will make the canvas feel slow even when n8n itself is fine. If your machine is already struggling, speed up a slow laptop first and free up disk space so the install does not fail halfway.
HowcompassInstall Docker Desktop
Download Docker Desktop from the official site and install it with the default options; on Windows it will ask to enable WSL 2, which you should accept. Docker is the free container runtime that lets n8n run on your machine without a manual Node.js setup. When it finishes, open a terminal and run docker --version to confirm it answers. The Docker Desktop documentation covers each platform's installer, and the rest of the Computers and Electronics library covers the machine itself.
HowcompassRun n8n with one Docker command
Create a persistent volume with docker volume create n8n_data, then start n8n with docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n. The volume is the important part: it keeps your workflows and credentials when the container stops, so treat it like any other data worth protecting and back up your computer to an external drive regularly. The first run downloads the image, which takes a few minutes. The official n8n Docker installation guide lists the same command with all current options.
HowcompassCreate the owner account at localhost:5678
Open http://localhost:5678 in your browser and create the owner account when n8n asks for an email and password on first launch. This account exists only on your machine; nothing is sent to n8n the company. Use a real password, not a throwaway one, because this login guards every credential you will store later. A password manager with a recovery plan is the right place for it, the same habit you use for email and banking.
HowcompassLearn the three parts of the canvas
Spend two minutes on the empty workflow before building: nodes are the boxes that do things, connections are the lines that pass data between them, and the Executions tab records every run. Click the plus button to add a node, and drag from a node's right-hand dot to connect it to the next one. Data always flows left to right, which is why the trigger sits at the far left. This canvas is the same in every guide in the AI Automation and Agents category, so the minutes pay off repeatedly.
HowcompassSet the timezone before any schedule
Stop the container and restart it with -e GENERIC_TIMEZONE=Europe/Berlin -e TZ=Europe/Berlin added to the docker run command, using your own zone. Without this, n8n schedules run on UTC and your 8 am digest arrives at the wrong hour, which is the single most common beginner bug with scheduled workflows. The environment variable reference lists every setting you can pass this way. It is a small habit from the wider Artificial Intelligence library: configure the boring defaults before the clever parts.
Connect a free AI model
HowcompassGet a free Gemini API key
Sign in at Google AI Studio with any Google account and create an API key; the Gemini API free tier needs no credit card and is enough for a personal agent. Copy the key somewhere safe the moment it appears. Only ever create keys on Google's own domain, because fake key-generator sites are a classic phishing trick, the kind covered in recognizing and avoiding phishing emails and fake websites. Google's API key documentation shows the exact screens.
HowcompassLine up a backup free provider
Create a free account at Groq and note OpenRouter's free models as a second fallback, because free tiers have daily caps and a single provider can throttle you mid-task. Groq's free tier serves open models very fast, and OpenRouter lists models with a :free suffix that cost nothing within their limits. Having two keys means your agent keeps working when one provider pauses you, the same redundancy logic as auditing your monthly SaaS subscriptions so no single service owns you. See Groq and OpenRouter for current terms.
HowcompassStore the key as an n8n credential
In n8n, open Credentials, choose Add credential, search for Google Gemini(PaLM) Api, and paste the key there rather than into any node field. Credentials are stored separately from workflows, so when you later export or share a workflow the key does not travel with it. Name it clearly, for example Gemini free tier, so you can tell providers apart at a glance. The Google credentials documentation shows where each Google key type belongs. Treat every API key like a password in your password manager and recovery plan, because anyone holding it spends your quota.
HowcompassAdd the AI Agent node
Click the plus button, search for AI Agent, and add it; it lives in the Advanced AI section and is the brain of this build. Unlike a plain node, the agent has empty slots underneath it for a chat model, memory, and tools, and it decides at runtime which of those to use. You do not wire the logic yourself; the model reads your prompt and picks. The AI Agent node documentation explains each slot, and more agent builds live in the AI Automation and Agents category.
HowcompassAttach a chat model sub-node
Click the Chat Model slot under the agent and choose Google Gemini Chat Model, then select the credential you saved and a Flash-family model such as gemini-flash-latest. Flash models are the right default for a free build: they are fast, capable enough for tool use, and generous on the free tier, while Pro models burn quota quickly. You can swap models later without touching the rest of the workflow. The AI Models and Technology category covers how the model families differ and when to upgrade.
HowcompassTest the model with a one-line prompt
Open the agent node, type Say hello in exactly five words into the chat panel, and run it; a coherent reply means the key, credential, and model are wired correctly. If you get a 401 error the key is wrong or revoked, and a 429 means you hit the free-tier rate limit and should wait a minute. Fix connection problems now, before memory and tools complicate the picture. The AI Tools and Platforms category has more setup guides if your provider's screens have changed.
Give the agent a job, memory, and tools
HowcompassWrite a system prompt that defines the job
Open the agent's Options, add a System Message, and write the job in plain English: the role, the task, the output format, and the limits. For example: You are a research assistant. Summarise the articles you are given into five bullet points, each under twenty words, and end with one suggested action. Vague prompts produce vague agents, so be as specific as you would when writing clear emails to a new colleague: role, task, format, deadline. This one field does more for quality than any model upgrade.
HowcompassAdd Simple Memory so it remembers
Click the Memory slot under the agent and add Simple Memory, then set the context window to around ten messages. Without memory every message is a first message; with it the agent can handle follow-ups like make the third point shorter. Ten to twenty messages is plenty for a personal assistant and keeps token usage inside the free tier. The Simple Memory documentation explains session keys if you later serve several users. It is the same principle as a Zettelkasten slip box: useful notes need a place to live.
HowcompassGive it an HTTP Request Tool
Click the Tool slot, add the HTTP Request Tool, and write a tool description that tells the model when to use it, for example Fetch the full text of a URL the user provides. The description matters more than the settings: the model chooses tools by reading descriptions, so a vague one never gets called. Leave the URL as a placeholder the model fills in, and keep the method on GET for reading. The HTTP Request node documentation covers authentication and pagination when you need them. This is the agent's first real hand reach into the world, a theme across the Computers and Electronics library.
HowcompassAdd Wikipedia and Calculator tools
Add the Wikipedia tool for factual lookups and the Calculator tool for arithmetic, because language models guess numbers and dates unless a tool computes them. With these attached, a question like what is the population density of Portugal becomes a lookup plus a division instead of a confident hallucination. The MediaWiki API documentation describes the data the Wikipedia tool reads. Test with a question that needs both tools and watch the agent chain them. Checking facts against sources is the same discipline as taking clear lecture notes with the Cornell method: capture, verify, summarise.
HowcompassCap iterations and treat web content as untrusted
Set the agent's maximum iterations to five or ten so a confused model cannot loop forever and burn your free quota in minutes. More importantly, remember that any page the agent reads can contain hidden instructions aimed at it, a prompt-injection attack, so keep tools read-only while you learn. Never attach a tool that sends email or deletes files to an agent that also reads arbitrary web pages. The social-engineering mindset in recognizing phishing emails and fake websites applies directly: the agent is a new employee who believes everything it reads.
HowcompassChat-test the finished agent
Add a Chat Trigger node, connect it to the agent's input, and click Open Chat to talk to your build in a proper chat window. Ask a multi-step question that forces tool use, for example look up the area and population of Slovenia and calculate its density, then ask a follow-up to prove memory works. Watch the canvas light up each node as it runs; that visual trace is your best debugging tool. If the answers ramble, tighten the system prompt the way you would write an email that actually gets a reply: one clear ask, one clear format.
Put the agent on autopilot
HowcompassSwap chat for a Schedule Trigger
Delete the Chat Trigger and add a Schedule Trigger set to every day at 08:00, so the agent works while you sleep. A schedule turns a toy you talk to into a service that delivers; the agent no longer waits for you to remember it exists. Use the cron option for weekday-only runs, and remember the timezone you set in part one decides when 08:00 actually happens. The Schedule Trigger documentation lists every interval option. More ways to automate daily office work live in the AI Productivity and Office category.
HowcompassFetch fresh input with RSS Feed Read
Add an RSS Feed Read node between the schedule and the agent, and give it one or two feed URLs you actually read, such as a favourite blog or a news section. The node returns an array of fresh items, which becomes the raw material the agent summarises each morning. Start with a single feed so the output stays short and the token cost stays tiny. The RSS Feed Read documentation shows the field names you will reference next. Curating a few good sources beats drinking from a firehose, the same lesson as a Zettelkasten slip box.
HowcompassOr trigger it from anywhere with a Webhook
Add a Webhook node as an alternative trigger when you want the agent to run on demand, for example from a phone shortcut or another app. n8n gives you a test URL while you build and a production URL once the workflow is active; they are different, and mixing them up is the classic webhook beginner bug. Keep the webhook private and treat its URL like a key. The Webhook node documentation covers methods and responses. If you later expose it to your home network, the segmentation advice in planning whole-home Wi-Fi applies.
HowcompassFeed the data into the prompt with expressions
In the agent's prompt field, switch to expression mode and reference the incoming items, for example Summarise these articles: {{ $json.title }} with links {{ $json.link }}. Dragging a field from the input panel on the left writes the expression for you, so you never have to memorise the syntax. The pattern is always the same: your instruction stays fixed, the data changes every run. This is where automation stops being a demo and becomes useful, and the AI Writing and Content category covers what to do with the summaries once they arrive.
HowcompassDeliver the answer to Gmail or Telegram
Add a Gmail node after the agent to email the summary to yourself, or a Telegram node to push it to your phone; Telegram is simpler because a bot token from BotFather is all it needs. Map the agent's output field into the message body, run once, and check your inbox before trusting the schedule. An agent whose output nobody reads is just an expensive screensaver. The Gmail and Telegram node docs show the auth steps, and writing an email that gets a reply is worth a read if you later point the agent at other people.
HowcompassCatch failures before they vanish
Open each node's Settings tab and enable Retry On Fail with three attempts five seconds apart, so a transient network blip does not kill the morning run. For failures that retries cannot fix, add a Stop and Error node on a failure branch, and later an Error Trigger workflow that messages you when anything breaks. Silent failure is the real danger of automation: you only notice the missing digest a week later. The Stop and Error documentation shows the pattern, and the AI Safety and Privacy category covers the wider discipline of watching what your automations do.
Test, activate, and keep it free
HowcompassRead the execution log like a debugger
Open the Executions tab, click the latest run, and inspect each node's input and output JSON by clicking it on the canvas. Green means success, red means error, and the red node's panel shows the exact message the provider returned. Nine times out of ten a failure is an expired key, a renamed field, or a rate limit, and the log tells you which in seconds. Long debugging sessions are exactly when relieving screen eye strain pays off, so take the breaks. Reading logs calmly is a skill that transfers to every automation you ever build.
HowcompassPin test data and iterate the prompt
Pin the RSS node's output so every test run uses the same articles instead of fetching new ones, then edit the system prompt and rerun until the summary format is exactly right. Pinning makes your tests comparable: same input, different prompt, clear cause and effect. Unpin before activating, or the agent will summarise yesterday's news forever. This loop of capture, test, and refine is the same method as taking clear lecture notes with the Cornell method, and it is the fastest way to make the output genuinely yours.
HowcompassActivate and verify one unattended run
Flip the Active toggle in the top-right corner, then wait for the next scheduled time and confirm a successful execution appears without you touching anything. Activation also switches webhooks from test URLs to production URLs, which is why a workflow that worked in the editor can behave differently once live. Check the first unattended run end to end, including the email or Telegram delivery, before you consider the build finished. The AI Productivity and Office category has more workflows worth activating once this one has run cleanly for a week.
HowcompassStay inside the free-tier limits
Check your provider's current requests-per-minute and requests-per-day caps on the Gemini pricing page, and keep your schedule well under them. A daily digest of five articles uses a handful of calls; an agent in a loop can use hundreds, so the iteration cap from part three is your safety valve. If you regularly hit 429 errors, add a Wait node between calls or move some runs to the Groq key you saved. Free tiers are a budget like any other, the same mindset as auditing your monthly SaaS subscriptions.
HowcompassExport and back up the workflow
Open the workflow's three-dot menu and download it as JSON, then store that file with your other backups; importing it into any n8n instance restores the whole build in seconds. Back up the n8n_data volume too, because it holds your credentials and execution history. Do this before every major edit, not after, and fold it into the routine in setting up encrypted automated cloud and local backups. The export and import documentation shows the menu paths, which change occasionally between versions.
HowcompassKeep the instance private and updated
Never port-forward 5678 to the internet; an exposed n8n is an open door to every credential inside it. If you later move it to a server, put it behind a reverse proxy with HTTPS and authentication, as the n8n security overview describes, and keep your home network segmented the way a separate guest Wi-Fi network does for visitors. Pull the updated Docker image monthly so security fixes arrive. Your agent now works for you around the clock; the last job is making sure nobody else can hire it.
Frequently Asked Questions
Question: Is n8n really free?
Yes for this build. The self-hosted community edition is free under n8n's fair-code license and includes the AI Agent node, memory, and tools. You pay only if you exceed a model provider's free tier or choose n8n's paid cloud hosting instead of running it yourself.
Question: Which AI model can I use for free?
Google's Gemini API has a free tier aimed at exactly this kind of personal project, and Groq and OpenRouter also offer free access to open models within daily limits. This guide uses Gemini Flash as the default because it is fast and generous, with Groq as the backup.
Question: Do I need to know how to code?
No. The whole build is drag-and-drop, the system prompt is plain English, and n8n writes the data expressions for you when you drag fields from the input panel. Code nodes exist for later, but nothing in this guide requires them.
Question: Will the agent run when my computer is off?
No. A self-hosted n8n only runs while its machine is on, so a scheduled agent needs an always-on computer: an old laptop, a small home server, or a cheap VPS all work. If you want zero maintenance, n8n's paid cloud is the alternative.
Question: What is the difference between an AI agent and a chatbot?
A chatbot answers messages. An agent is given a goal and tools, then decides for itself which tools to call, reads the results, and loops until the job is done. In n8n the AI Agent node is that decision loop, and the tools you attach are its hands.
Question: Is my data sent to Google when the agent runs?
The prompts and any data you pass to the model are sent to the provider you choose, and free tiers often allow the provider to use that traffic to improve its models. Keep sensitive personal, financial, or client data out of free-tier prompts, or use a paid tier with a no-training policy.
Tips
- Name every node as you add it, like Fetch RSS or Summarise articles; future you will read the canvas at a glance instead of opening ten panels.
- Start with one tool and add more only when a chat test shows a real gap; every extra tool is another description the model can misread.
- Keep a scratch workflow for experiments and duplicate a working flow before any big edit, so a broken test never costs you the build.
- Free-tier quotas reset daily, so schedule heavier jobs shortly after the reset rather than at the end of the day when the budget is spent.
- Download the workflow JSON before every refactor; a five-second export is the cheapest undo button in automation.
Warnings
- API keys are money: anyone holding your key spends your quota and can impersonate your agent, so never paste keys into screenshots, public forums, or shared workflow exports.
- Web pages the agent reads can carry hidden instructions aimed at the model, a prompt-injection attack; keep tools read-only until you fully trust the flow.
- Free tiers are not for sensitive data: providers may log or train on free-tier traffic and can change limits without notice, so keep personal and client data out of the prompts.
- An n8n port exposed to the internet hands strangers your stored credentials; keep it on localhost or behind authenticated HTTPS, never raw port-forwarding.
Things You'll Need
- A computer with 8 GB of RAM and 2 GB of free disk space
- Docker Desktop on Windows or macOS, or Docker Engine on Linux
- n8n community edition, self-hosted and free
- A Google account and a free Gemini API key from AI Studio
- Optional: a free Groq or OpenRouter account as a backup provider
- A Gmail or Telegram account for delivering the agent's output
- A password manager for the owner account and the API keys
- Sixty to ninety minutes for the first complete build
References (7)
- Install n8n with Dockern8n Docs
- AI Agent node documentationn8n Docs
- Advanced AI in n8nn8n Docs
- Gemini API pricing and free tierGoogle AI for Developers
- Docker Desktop overviewDocker Docs
- MediaWiki API main pageMediaWiki
- n8n community forumn8n Community
Sources are listed so you can read the underlying guidance yourself. Our editorial policy explains how guides are reviewed.
Did this article help you?
0 readers found this helpful — add your vote.




No comments yet — be the first to share your results.