n8n AI Agent Tutorial for Beginners 2026 - Step by Step
📺 ดูคลิป · 👁️ 117,532 views · 📅 2025 · ⏱️ 23:34 · 🤖 AI Agents / Vibe Coding / Automation
📌 สรุป
คลิปนี้สอนการสร้าง AI Agent ด้วย n8n แบบ step-by-step สำหรับมือใหม่ปี 2026 โดยเริ่มจากการต่อ LLM (OpenAI) + memory + tools จนสร้างระบบส่ง daily briefing email อัตโนมัติทุกวัน 8 โมงเช้า รวมถึงการเก็ป log ใน Google Sheets เพื่อไม่ให้ agent ส่งข้อมูลซ้ำ และจบด้วยแนะนำการ self-host n8n บน VPS ราคา $5/เดือน
🔑 ประเด็น / ขั้นตอนหลัก
- สมัคร n8n Cloud (มี 14-day free trial) → เข้า dashboard → Start from scratch → เพิ่ม trigger 'Chat Message' → เพิ่ม node AI Agent
- ต่อ LLM brain: เลือก OpenAI (รองรับ Anthropic/Azure/AWS/DeepSeek/Gemini/Groq/Ollama/OpenAI) → ต้องใช้ API key จาก platform.openai.com → เติมเงินขั้นต่ำ $5 เพราะใช้ pay-per-token ไม่ใช่ subscription
- เพิ่ม Memory (Simple Memory) → ให้ agent จำ context การสนทนาก่อนหน้า
- เพิ่ม Tools: Wikipedia (ไม่ต้องตั้งค่าพิเศษ) + SerpAPI (Google Search, ลงทะเบียนได้ 100 free calls) + OpenWeatherMap (API key ฟรี)
- เปลี่ยน trigger จาก Chat → Schedule Trigger (รันทุกวัน 8:00 AM) → เขียน prompt template ใน AI Agent node แทน เช่น 'gather weather, 2-3 positive news, fun fact from Wikipedia, format as newsletter in markdown' + inject วันที่จาก trigger
- แก้ error session ID: ตั้ง session ID แบบ static ใน Simple Memory node เมื่อไม่ใช้ Chat trigger
- แปลง output จาก Markdown → HTML ด้วย node 'Markdown' (data transformation) → ส่งต่อ OpenAI node ให้ beautify HTML ด้วย inline CSS สไตล์ newsletter → ส่ง Gmail
- เพิ่ม Google Sheets logging: สร้าง sheet 3 columns (date/news/fun facts) → เพิ่ม OpenAI node แยกต่างหาก (อย่าให้ agent เดิมทำสองงานพร้อมกัน) → ใช้ Google Sheets เป็น tool ของ node นั้น append row
- เพิ่ม pre-read node ก่อน AI Agent: OpenAI อีกตัวอ่าน Google Sheets log แล้วสร้าง summary หัวข้อที่เคยส่งแล้ว → inject เข้า prompt หลักว่า 'avoid following topics'
- Activate workflow โดยกด toggle Inactive→Active → agent จะรันอัตโนมัติทุกวัน
🛠️ เครื่องมือ / บริการ / ลิงก์ที่พูดถึง
- n8n Cloud — free trial 14 วัน, สมัครผ่านลิงก์ description ได้ราคาดีสุด (n8n.io)
- OpenAI API — platform.openai.com, เติมเงินขั้นต่ำ $5, ใช้ API key (pay-per-token ไม่ใช่ subscription)
- SerpAPI — serapi.com, 100 free API calls หลังสมัคร (Google Search tool)
- OpenWeatherMap — openweathermap.org, มี free tier + API key
- Wikipedia — built-in tool ใน n8n ไม่ต้องสมัครอะไร
- Gmail — เชื่อมผ่าน Sign in with Google (n8n Cloud) หรือ OAuth2 (self-host)
- Google Sheets — เชื่อมผ่าน Google credentials ใน n8n
- VPS self-hosting — ประมาณ $5/เดือน (แนะนำตาม video แยกในช่อง) ใช้ n8n Community Edition ฟรี ไม่จำกัด workflow/execution
💡 เอาไปใช้ / ข้อสังเกต
- n8n เหมาะมากสำหรับสร้าง automation ขาย service ให้ลูกค้า SME เพราะ no-code/low-code + API ครบ ต้นทุน $5/เดือน VPS แต่คิดค่าบริการลูกค้าได้เต็ม
- กลยุทธ์ affiliate: คลิปฝัง link สมัคร n8n Cloud (ได้ commission) + link setup VPS video (cross-sell คลิปอื่นในช่อง) — monetize ทั้ง tool subscription และ hosting tutorial
- หลักการออกแบบ agent ที่ดี: 1 agent = 1 งาน (อย่าให้ทำหลายงานพร้อมกัน) + จำกัด tools เฉพาะที่จำเป็น + เขียน system prompt ชัดเจน + เพิ่ม validation step
- ใช้ Templates ใน n8n เป็น shortcut เรียนรู้และลดเวลา build — เหมาะสำหรับนำเสนอ demo ให้ลูกค้าเร็ว
- ระวัง API key รั่ว: OpenAI/SerpAPI/OpenWeatherMap key ต้องเก็บใน password manager ไม่แชร์ใคร
📄 Transcript เต็ม (English, 4,319 คำ)
In this video, I'll show you step by step how to build your first AI agent using NADN. 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 NADN, 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 NADN. But before we can get started, you'll need an NADN account. To sign up, click the link in the description to get the best available price and a 14-day free trial for NADN Cloud. If you plan to use NADN 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 NAD cloud trial. To begin the sign up process, click the sign up button on the NADN 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 NADN dashboard where you can begin building your first workflow. When you land on the NADN 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 subnode 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 utilize the results of the AI agents 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, Grock, Olama, 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 Chat GPT. However, using OpenAI in an automated workflow utilizes APIs and therefore uses a payer 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 NADN and paste in your OpenAI API key. Then, save. Now, OpenAI's chat GPT 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 NAD. 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 SER API. Click create new credential. Next, you'll need to grab an API key from SER API. Go to serapi.com and register for an account. Upon sign up, 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 NADN. 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 new 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 NADN, 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 chatbot 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 NADN. 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 open weather map. Again, this requires an API key. Go to openw weathermap.org and create an account. Then once you're signed up, grab an API key from the API keys section of your profile. Then return to naden 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 NAD. 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 trash can 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 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 drop-down 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 ID up. So for now in our simple memory node, we'll change the session ID to defined 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 ton 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 OOTH 2. Setting up OOTH 2 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 two 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 trash can 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 ro 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 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 NAN. Next, we'll need to add a Google Sheets node within NADN. 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 NAD 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 summarize 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 step's 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 drop-down 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 open AI. For our action, we'll select message a model. The action settings will load and we can select a model from the drop down. 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 and 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 labeled 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 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 guard rails. 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 NADN 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. N 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. CommandV on Mac or controlV 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's 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 N8 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 247 uptime. A better option is a virtual private server or VPS. With a VPS, you get a dedicated remote computer system that runs non-stop, stays secure, and keeps your personal files separate, all while using N8N for free. Self-hosting has big perks. It's cheaper, about five bucks a month for a VPS, and N8N is free. No limits on workflows or executions. Full control over hardware and updates. Install 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. N8NCloud 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.