n8n AI Agent Tutorial for Beginners 2026 - Step by Step
FULL TRANSCRIPT
- In this video, I'll show you step by step
how to build your first AI agent using n8n.
Instead of hiring an expensive development team,
this tool allows you to start building automation workflows
and AI agents that can complete tasks
for you 24/7, 365, no prior experience needed,
and you can even start out using it for free.
We'll cover setting up a simple AI agent in n8n,
giving the agent tools to expand its capabilities,
setting it to run autonomously, adding a knowledge base
so it can learn and grow over time,
sending custom email briefings automatically
and how to use templates
to quickly start your next workflows.
By the end of this video, you'll know exactly
how to create your own custom AI agents using n8n,
but before we can get started,
you'll need an n8n account.
To sign up, click the link in the description
to get the best available price
and a 14-day free trial for n8n Cloud.
If you plan to use n8n long term,
I recommend setting it up on your own server.
It'll cost much less over time.
You'll find a link to a step-by-step setup video in the card
at the top right and in the description.
We'll also discuss this in more detail later in the video.
For this demo, I'll just sign up
for the free n8n Cloud trial.
To begin the signup process,
click the signup button on the n8n Homepage.
Enter your personal information to create an account,
then complete the brief onboarding survey.
You'll have the option to watch an introductory video,
which can provide additional context if desired.
Once finished, click Start Automating to proceed.
This action will direct you to the n8n dashboard
where you can begin building your first workflow.
When you land on the n8n Overview Page,
click Start from Scratch.
After that, we'll click the big Plus
to add our first step, a trigger.
We'll set our trigger to be a chat message
then we'll return to the canvas.
Next, we'll click the small Plus button on the right side
of the trigger node to add actions to our workflow.
From there, we'll select AI then AI Agent.
Here you can see all
of the basic building blocks of an AI agent.
There's the main AI agent node
and a connector for providing input.
There's also sub node connectors for a brain
or reasoning engine, memory and tools.
Finally, there's a spot to add steps
after the AI agent
so that we can automatically utilise the results
of the AI agent's work.
Let's start by setting up the brain
so we can chat with the agent.
You're able to use most major LLMs such as Anthropic,
Azure, AWS, DeepSeek, Gemini, Groq,
llama, OpenAI, and more.
For this video, we'll stick with OpenAI,
but you can use whichever LLM you prefer.
Click the Plus, then we'll need to add credentials
to connect this with our OpenAI account.
You might already have a subscription for ChatGPT.
However, using OpenAI in an automated workflow
utilises APIs and therefore uses
a paper token billing structure
instead of a flat monthly fee.
For API access, we'll need
to load our OpenAI account with a small amount of money
and grab an API key to get started.
Go to platform.openai.com, then log in or create an account.
If you've never used this part
of the OpenAI site before, the onboarding flow
will guide you through setting up everything you need.
You'll make a project, grab an API key
and load your account with a minimum of $5 to get started.
Your API key is essentially a password.
It's meant to be kept secret.
If anyone else learns your API key,
they can access your OpenAI account
and potentially use it for nefarious purposes
or use your credentials
to get OpenAI access while you foot the bill.
OpenAI will only share this API key with you once,
so copy it
and store it somewhere safe like a password manager app.
Once you've gotten it written down, return to n8n
and paste in your OpenAI API key, then save.
Now, OpenAI's ChatGPT is connected as the brain
of our agent.
Let's try it out by saying hello.
Click the Open Chat button
and type a simple hello message to confirm
that things are connected.
If everything is working correctly,
you should get a response to your greeting
and a success message from n8n.
Next, let's add some memory
so our agent can remember recent interactions.
Click the Plus button under memory
and then add simple memory.
Now the AI agent has the ability
to look at the last few interactions to get the context
for its next response.
Next, let's give the agent some tools.
We're going to create a daily briefing agent,
and I want the agent to find fun facts for me
as part of the briefing.
So let's connect it to Wikipedia.
Click the Plus button to add a tool
then search for and add Wikipedia.
There's nothing special required
to set up the Wikipedia tool,
so you can simply click back to Canvas.
Next, let's give the agent the ability to search Google
so it can find up-to-date news stories
to include in the briefing.
Click the Plus button and search for and add SERP API.
Click Create New Credential.
Next, you'll need to grab an API key from SERP API.
Go to SerpApi.com and register for an account.
Upon signup, you'll get 100 free API calls that you can use
before you have to pay for anything.
Once you're registered, copy your private API key
from your main account Overview page,
again, keeping it secret and secure.
Enter that API key into n8n, then click Save.
Now we have all the main building blocks
of an AI agent connected, let's try it out.
Let's message the agent,
ask it to give us a news story from today
and have it tell us one fun fact about a random animal
pulled from Wikipedia.
You can watch the AI agent take the prompt,
think about it with OpenAI, search the web for a news story
and use Wikipedia to find a fun fact,
and then finally return a response to the chat.
We've officially set up a basic AI agent,
but right now we're limited to chatting with it inside
of n8n, and the agent is limited
to a small number of tools.
So how can we level this up
to make it run on its own without being prompted?
To transform the agent from a chat bot with tools
to an autonomous worker that can send us a daily briefing,
we need to give it more tools, a scheduled trigger
and an increased memory so it can grow and learn over time.
We also need to send the results of its work somewhere
we can view it without logging into n8n.
Let's start by giving it the ability to check the weather.
We'll click the plus button to add another tool.
Search for and select OpenWeatherMap.
Again, this requires an API key.
Go to openweathermap.org and create an account.
Then once you're signed up,
grab an API key from the API key section of your profile,
then return to n8n
and paste in your new API key to connect your account.
Next, we need to add a location for the weather report.
Back on openweathermap.org,
we'll search for a city, open it from the search results,
then copy the city name exactly as it's written
and paste it into the City field back in n8n.
To test that it's working,
we can click execute step in the top right
of the node settings.
If it's set up properly, you'll see
detailed weather information come back
in the right side output panel.
Next, let's add another trigger
to run this agent at the same time every day.
We'll hover over the chat message trigger node
then click the Trashcan icon to delete it.
We'll click the Plus in the top right
to add a new trigger node
then select on a schedule.
This will open the settings for schedule trigger,
so we can set it to run every day at 8:00 a.m.
Then we can click Execute step
to get some test data.
Back on the canvas, we can see that the trigger
has been added, but it's not connected to anything,
so we'll click
and drag from its Plus button to the left side
of the AI agent node to add the secondary trigger.
Now we have a trigger that will start
the AI agent every day at 8:00 a.m.,
but how does it know what to do?
Next, we'll give it some instructions.
If you open up the AI agent node,
you can use the first dropdown menu
to change the prompt source from the connected chat trigger
to instead define a custom prompt in the node settings.
Next, let's create a prompt template.
We'll write a prompt that will get sent
to the LLM every time this workflow runs.
We'll tell it every morning,
gather the weather for San Francisco,
pull in two to three positive trending news stories
and find a fun fact from Wikipedia.
Don't repeat anything from previous days.
Format it like a mini email newsletter in markdown.
This is the foundation of our prompt template.
Now, we can also use variables, also called input fields,
to dynamically insert information into the prompt.
So let's add the text,
today's date, to the end of the prompt.
Then let's drag in the timestamp from the schedule trigger
on the left side panel.
Next, let's click the Execute Step button to run this node
and get some test data.
Oops!
That spits out an error that says,
"Error in sub-node 'Simple Memory', No session ID found."
When starting an agent without a chat trigger,
we need to manually provide the memory with a session ID.
In more complex setups,
you might need to find a way
to manage the session IDs dynamically,
but for a simple agent like this, we can provide a static ID
or simply an ID that doesn't change.
We can just make this idea up.
So for now in our simple memory node,
we'll change the session ID to define below
and enter something like my test ID for the key.
Let's go back to the canvas and test our agent again.
Now, after a bit of thinking, you can see
that the agent outputs a response in markdown format.
Now we have the agent receiving instructions
at a scheduled time, and from there,
deciding what to do with the prompt.
We've given it a goal,
but we haven't told it how to accomplish the task.
It's using the available tools
to find information from the internet,
then deciding what's the best information to present back
to us for our daily briefing.
Now, let's take the results of its work
and send it to our inbox.
We'll click the Plus button
after the AI agent node, select Action in an app,
then search and select Gmail.
You can see that there are a tonne of actions
that you can do within Gmail.
We'll use the Send a message Action.
Now, we need to connect a Gmail account.
If you're using n8n Cloud, the easiest way
is to click Sign in with Google.
But if you're self-hosting, that option won't be available.
In that case, you'll need
to connect your Google account
using a method called OAUTH2.
Setting up OAUTH2 takes a few extra steps
and is outside the scope of this tutorial.
However, I've added a link in the description that walks you
through the process,
including a helpful video from the official documentation.
After you've connected your Google account,
enter your own email address in the To field.
This is where the daily briefing will be sent.
We can set the subject dynamically
based on the date of the briefing.
We'll say daily briefing,
then drag in the readable date variable
from the schedule trigger outputs in the left panel.
Next, drag the output variable from the AI agent step
into the message field.
Let's test this step by itself to see how the email looks
with all the present data.
We'll click Execute Step at the top right.
Then we can open up our inbox to check out how it looks.
Well, there it is.
It's a message, but it's not very pretty.
Let's update our approach
so that we don't just receive a block of text
for our briefing,
and instead receive
a beautifully formatted newsletter-style email.
Next, we'll add a data transformation step
to convert the AI output from markdown format to HTML
since Gmail can handle HTML messages.
On the canvas,
we'll click the Trashcan icon on the output arrow line
to disconnect Gmail from the flow temporarily.
Now, we'll add a new post-processing action.
Under data transformation, we'll select markdown.
We'll set our mode to markdown to HTML.
Then we'll drag in the AI output variable
to the markdown field.
Let's click Execute step to test.
The output is looking promising.
Now, let's beautify the HTML.
After the HTML step, let's add a standalone OpenAI node.
We'll select the message a model action,
and pick a model from the list.
Next, we'll change the message roll below
from user to system.
A system prompt is what gets sent
before any regular user messages are sent,
and it helps prime the LLM regarding its intended purpose
and expected response.
The default system prompt is you are a helpful assistant,
but you can change it to specify how the LLM should respond
to any additional inputs that come through.
Next, for our prompt, we'll say beautify
the HTML below using inline CSS styling for an email.
Format it like a modern newsletter, output only the results
without any header elements.
Next, we'll click add message, keep the role as user,
then drag in the variable containing the results
of the markdown transformation to HTML into the field
for the user message.
Then we'll test this step.
Looks good.
Finally, let's connect Gmail again
to see how the message looks.
We'll need to update the variable for the Gmail message.
So let's delete the old message, drag in the variable
for the content generated
by the OpenAI email beautifying step,
then execute this step to test it.
Let's check it out in the inbox, and there we go.
It's looking great now.
Now we've run many of the steps for the agent individually,
but let's test the whole workflow to see
what will happen at 8:00 a.m.
Back on the canvas,
let's click Execute workflow and see what happens.
The full AI agent workflow will run.
You'll see the various steps processing,
and finally, you'll see a success message
when everything finishes.
It works.
Now finally, let's connect a spreadsheet
to this workflow so that the agent knows what topics
to avoid when trying to find news and fun facts.
The goal is to log the news
and fun facts from each day's briefing
so that the agent can look at the log
and know exactly what to avoid writing about.
First, we'll create a Google Sheet
with three column headers, date, news and fun facts.
Then we'll come back to n8n.
Next, we'll need to add a Google Sheets node within n8n.
You might think we should just connect Google Sheets
as another tool to our agent, but here's the tricky part.
You see, just like humans,
AI agents work best when you give them one clear job to do.
If you pile more work on them
and ask them to do another job at the same time
as the first one, they might not create good results
with one or both of those jobs.
So in order not to overwhelm our agent,
we need to delegate.
Asking it to create an entirely separate output,
our log will likely distract it from its primary job,
or it might ignore this second job entirely.
So let's spin up another AI node to handle logging.
At the end of our workflow, let's add a new action.
We'll click the Plus, then select the AI category.
You could use any of the major LLMs n8n has integrated
to perform this task, but we'll stick with OpenAI again.
Then we'll click the Message a model action.
We'll choose a model from the list then enter a prompt.
We'll set the system prompt to something like this.
Your job is to log the news
and fun fact from the daily briefing
in the relevant columns
within the Google Sheets document you have access to.
An AI will be reading the results of your work, so be sure
to format it in a concise, detailed manner that will be easy
to parse and summarise with a small number of tokens.
Next, we'll add a user message.
We'll type daily briefing to give the LLM some context
then drag in a variable with either the markdown
or the HTML version
of the daily briefing from a previous steps output.
Now, we'll give this LLM Google Sheets to use as a tool,
then make sure that your Google credentials are selected.
We'll change the operation from get row to append row
so we can add new information.
Then we'll add the Google Sheets log we created earlier
from the dropdown and pick the sheet with our headers.
Then we'll grab the timestamp variable
from the schedule trigger and drag it into the field
for the date value.
For the other two columns, we'll click the AI button
to let the AI decide what information to add to the news
and fun fact fields.
Now that we have everything connected to create a log,
let's execute the AI step to test it out.
If it works properly, we'll see a new row appear
in our Google spreadsheet with the columns filled
with the correct information.
Now that we're adding information to a log, we need
to add a step earlier in our workflow to review that log
before searching for news
and generating a report.
We'll do this the same way we set up our last AI node.
We'll click the Plus button between the schedule trigger
and the AI agent nodes to add a new action.
Next, we'll select AI, then OpenAI.
For our action, we'll select message a model.
The action settings will load
and we can select a model from the dropdown.
Next, we'll write a prompt, something like this.
Your job is to review the linked Google Sheet to see
what the previous daily briefs contained.
The goal is not to repeat any fun facts
or news stories.
Generate a description
for the next AI in the chain to understand which topics
to avoid with the briefing.
Whether we use a system
or user prompt matters less for this node,
since we're just giving it a single prompt
and not providing any additional inputs.
That said, I've selected system message
for this demo.
Back on the canvas, click the Plus button
to add a tool to our AI node,
then search for and select Google Sheets.
Leave the operation set to get rows,
then select the document
and the sheet where the previously logged briefings live.
Back on the canvas, you can click the Play button
above the new AI node to test this step
and generate sample output data.
Finally, we need to update the instructions
for our main AI agent node so it understands
what to do with this new information we're giving it.
Open the AI agent node,
then add something like this to the end of the prompt.
Avoid the following topics.
Then drag in the content variable generated as an output
of the newly added message in AI model step.
Next, run the AI agent node to test
that it's working correctly with the new inputs
and instructions that it's receiving.
After a bit of processing,
you should get a success message confirming
that everything is set up correctly,
and you'll be able to see what the AI agent wrote
by looking at the output section in the bottom panel
on the canvas, or in the right panel
of the AI agent node settings window.
Now, theoretically, our agent is fully set up,
but before going live, we still need to test it.
On the canvas,
click the Execute Workflow button to run the full workflow.
As usual, this will take a while to process.
You'll get to see each node
of the workflow running in real time,
and you can watch as the agent node thinks,
then uses tools then thinks again
before creating an output for the next step to use.
If you get a success message when it's done running,
that means it's ready to go.
Click Save in the top right to preserve your hard work.
Then to set your agent to run automatically every day,
click the toggle button at the top labelled Inactive
to activate it.
After that, you'll get a success message indicating
that your workflow is now live.
Now we have a fully functioning AI agent workflow
that sends us a daily brief
and takes notes about what it wrote in previous briefs
so it doesn't send duplicate information from day to day.
Now the AI agent will run every day at 8:00 a.m.
and decide what we should see in our inbox to start the day.
Before you launch your agent into the wild,
here are a few tips to keep it running smoothly.
First, set guardrails.
Just because your agent can make decisions doesn't mean
it should have total freedom.
Be clear and specific in your system prompts.
Spell out what it should and shouldn't do,
and keep its focus narrow.
You can even add validation steps
after the agent runs to serve as a simple quality check.
Second, limit its tools.
Only, give the agent access to the tools it really needs.
More tools can make things more complex,
and that usually means more chances for it to go off track.
Third, use prompt templates.
Templates help keep your outputs consistent
and make it easier to troubleshoot when something breaks.
You can inject variables like dates, prior results
or other workflow data
to keep things flexible without losing structure.
And finally, expect some trial and error.
Bugs and misfires are part of the process.
If something isn't working, start by checking the inputs
and reviewing the node settings.
You can also ask the built-in n8n AI assistant for help.
Many errors include a quick action button
for AI generated suggestions,
and if that doesn't solve it, most nodes have direct links
to the relevant documentation.
You don't have to build everything from scratch.
One of the easiest ways to get started
is by using a template.
N8n has a growing library
of workflow templates, perfect
for common setups like content summarizers,
email responders or AI assistants.
To use one, head to the Templates tab in n8n
and search for something similar to what you want to build.
You can preview the workflow, then click use for free
and copy the template.
Back in your n8n workspace,
open a blank workflow and paste it in,
Command + V on Mac or Ctrl + V on Windows.
This will import the full setup,
including all nodes and connections.
From there, just plug in your API keys, tweak the prompts
or change the trigger.
It's a great way to learn by example,
or get something working without starting from zero.
You can even export and share
your own workflows as templates.
So if you build something useful, you can pay it forward.
You've seen how templates save time.
Now let's talk about saving money.
If you love n8n, but want full control
and a lower monthly bill,
then self-hosting is the way to go.
When you sign up on n8n site, you're paying
for something called n8n Cloud,
which bundles two things.
One, the n8n software, what we've been using,
and two, hosting,
the hardware running it.
So what is self-hosting?
Self-hosting means running n8n on your own system.
Technically, you could use your personal computer,
but your workflows stop the moment you shut it down.
It also eats resources and poses security risks
since most machines aren't built for 24/7 uptime.
A better option is a virtual private server or VPS.
With a VPS, you get a dedicated remote computer system
that runs nonstop, stays secure,
and keeps your personal files separate,
all while using n8n for free.
Self-hosting has big perks.
It's cheaper, about $5 a month for a VPS,
and n8n is free.
No limits on workflows or executions,
full control over hardware and updates.
Instal any custom nodes you want.
Your data stays private
and you'll pick up some useful DevOps skills along the way.
But it's not all smooth sailing.
Setup and maintenance are on you.
That means updates, security and scaling.
There's no official support,
and if your server crashes,
so do your workflows, until you fix it.
Think of it like coffee.
Self-hosting is like brewing at home.
It's cheaper and customizable, but you have to do the work
and maintain the coffee maker.
N8n Cloud is like buying coffee from a cafe.
It's pricier, but someone else handles everything
so you can focus on more important things,
like building automations.
If you're interested in self-hosting,
I have a whole separate video
on how to set that up in under five minutes
for less than $5 per month.
Go ahead and click the video thumbnail on your screen
or the link in the description below to get started.
AVAILABLE LANGUAGES
UNLOCK MORE
Sign up free to access premium features
INTERACTIVE VIEWER
Watch the video with synced subtitles, adjustable overlay, and full playback control.
AI SUMMARY
Get an instant AI-generated summary of the video content, key points, and takeaways.
TRANSLATE
Translate the transcript to 100+ languages with one click. Download in any format.
MIND MAP
Visualize the transcript as an interactive mind map. Understand structure at a glance.
CHAT WITH TRANSCRIPT
Ask questions about the video content. Get answers powered by AI directly from the transcript.
GET MORE FROM YOUR TRANSCRIPTS
Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.