Tutorial – How to Build an AI Agent with n8n

In this tutorial, we’ll walk through step by step how to create an AI agent in n8n, from installation to setting up a conversational or autonomous agent. You’ll learn how to connect n8n with OpenAI, design your first workflows, and test agents that can interact or automate tasks. A hands-on guide to get started fast and master the essential basics.

Sommaire

Introduction – What Is an AI Agent in n8n?

Quick Definition – What Is an AI Agent?

Before AI agents came along, we were already automating plenty of tasks with tools like Zapier, Make, or n8n. But let’s be real: it was all very rigid. We built precise action chains with clearly defined inputs and outputs—for example, “when I receive an email, create a task in Trello.” Nice automation, but totally unable to handle anything outside the predefined box.

This is where AI agents change the game. An AI agent is like a supercharged automated assistant that can make decisions, adapt to context, and handle more complex tasks—without needing you to spell out every single step. Basically, we’re moving from repetitive automation… to smart automation.

Concrete example: you want to summarize the latest articles from your RSS feed and send out a digest by email? With an AI agent, there’s no need to manually define what to extract or how to format the message: it understands and adapts.

For an AI agent to work properly, you need to connect it to four key components:

• A trigger → for example, a new event, an incoming message, or even a scheduled time.

• An LLM (Large Language Model) → this is the agent’s brain. Here, we’ll work with OpenAI, which is incredibly powerful for generating text, understanding requests, and more.

• Memory → yep, a good agent needs to remember what it has already done or said; otherwise, it starts from scratch every time (which is frustrating).

• Tools → these are its arms and legs. They allow it to send emails, post messages, search for info on Google, and more.

Why Use n8n to Build an AI Agent?

If you’re into AI agents, you’ve probably asked yourself: why choose n8n over Make or Zapier? It’s a key question, and there are some solid reasons to go with n8n.

n8n was a pioneer.
While Make, for example, only added AI agents in April 2025, n8n had already been offering this feature for several months. The result? The AI agent ecosystem on n8n is mature, well-tested, and a step ahead of the competition.

You can connect it to almost anything.
n8n stands out for its flexibility. Want to hook up your AI agent to a CRM, Slack, Notion, Google Sheets, or any API? No problem. You get access to a massive library of native integrations, saving you from messy hacks or unstable workarounds.

Unbeatable value for money with self-hosting.
This is probably one of the most compelling arguments: n8n can be self-hosted. In practice, you install your own instance on a server or VPS, avoiding the recurring costs of n8n Cloud, Make, or Zapier. And to make it easier, this article walks you through a step-by-step self-hosted deployment. You’ll see—it’s more straightforward than you might think.

In short, n8n combines flexibility, power, and cost savings while giving you full control over your infrastructure. It’s the perfect playground to experiment and deploy ambitious AI agents.

Tutorial Goal – Learn How to Build an AI Agent in n8n Step by Step

The goal of this tutorial is simple: to guide you step by step in building your own AI agent in n8n—even if you’re starting from scratch. By the end, you’ll not only understand how an AI agent works but also be ready to customize it for your own needs and use cases.

Here’s what we’ll cover together:

• The essential prerequisites before getting started: how to create an n8n Cloud account, how to self-host n8n (and why it’s worth it), how to get your OpenAI API keys, and the basics you need to understand n8n properly.

• Setting up and connecting n8n to AI: we’ll explain how to link OpenAI to n8n, how to build your first workflow, and how to run your initial tests to make sure everything works smoothly.

• Building a simple conversational AI agent: we’ll show how to set up a chat model, add memory, and integrate a first tool to give your agent superpowers.

• Creating a simple autonomous AI agent: we’ll demonstrate how to build an agent that can work independently, for example, automatically summarizing an RSS feed in French.

Bonus: you’ll be able to download the automations we’ve built for you and import them straight into your n8n—no need to start from scratch or rewrite everything. You can customize them for your own projects in just a few clicks.

By the end of this tutorial on building an AI agent in n8n, you’ll have everything you need to start experimenting, create your own workflows, and automate high-value tasks.

Hack’celeration: What the Experts Never Show You? We Give It to You.

Qonto logo, online banking solution for professionals.
Gymlib logo, fitness and wellness platform for companies.
Yousign logo, electronic signature service.
Spendesk logo, spend management platform.
Liligo logo, travel comparison tool.
Online restaurant reservation platform.

Prerequisites: What You Need Before Creating an AI Agent in n8n

Get an n8n Account: (Self-Hosted or Cloud)

How to Sign Up for n8n Cloud

Honestly, there’s nothing easier than getting started with n8n Cloud. Just head over to the official website n8n.io, click the “Get Started” button, and follow the signup process. Fill in a few details, and that’s it—you get instant access to a 14-day free trial to test the platform with no hassle.

Good to know: n8n Cloud is a paid service. After the trial, pricing starts at around €20 per month, which includes 2,500 workflow executions and unlimited nodes per workflow. That’s more than enough to experiment and begin setting up your first AI agents.

If you want to go further, no worries: just below we’ll also show you how to self-host n8n to cut costs even more.

How to Self-Host n8n (e.g., Hostinger)

If you want to cut costs and keep full control over your workflows, self-hosting is an excellent option. And the good news: it’s much easier than you might think.

Just use the following Hostinger link. Once on the site, pick the plan that suits your needs. No need to go big right away—a basic plan is more than enough to experiment and run your first AI agents.

After selecting your plan, you’ll be able to choose apps to install automatically on your server. Among them, you’ll find n8n. Simply check the box, and Hostinger takes care of the rest.

Once your signup is complete, you’ll get access to a dashboard where a single click opens your n8n app—already set up and self-hosted. No need to mess with command lines or manual setups: you can dive straight into what matters—building your first workflows.

Get an API Key: (OpenAI, Hugging Face, LLM)

How to Get an OpenAI API Key

Before connecting n8n to artificial intelligence, you need to get an OpenAI API key.

Important: this isn’t the same account you use for ChatGPT in its regular mode—it’s a specific account on OpenAI’s API platform. That’s a crucial distinction because without this dedicated account, you won’t be able to generate an API key or use the models via n8n.

Here are the steps to follow:

1. Create an account on OpenAI API if you haven’t already.

2. Once logged in, click your name (top left), then select Manage Project.

3. Go to the API Keys tab.

4. Click Create a new secret key.

5. Name your key something easy to recognize (for example, “AI Agent n8n”).

6. Select the relevant project.

7. Leave the default permissions on “All,” unless you want to restrict access to certain features.

8. Click Create key.

Very important: copy and securely save this key as soon as it’s generated. You won’t be able to retrieve it later, so make sure to store it in a secure password manager or a document you have handy. We’ll need it later when connecting n8n to OpenAI to build your AI agent.

Know the Basics of n8n Workflows

Before diving into building an AI agent, it’s important to clarify one thing: an AI agent shouldn’t be the very first workflow you create in n8n if you’re a complete beginner. Why? Because an AI agent relies on several advanced components and concepts that require a bit of automation experience.

If you’ve never used n8n before, we highly recommend starting with a few simple automations. This will help you get familiar with the interface, workflow logic, and the essential basics before tackling a more ambitious project like an AI agent.

To help you out, we’ve put together a catalogue of ready-to-use automations that you can download, import into your n8n, and explore. This will give you a solid overview of how things work—without overwhelming complexity right away.

At a minimum, here’s what you should be comfortable with before jumping in:

  • Creating a simple workflow in n8n.
  • Understanding what a trigger is (the starting point of a workflow).
  • Knowing where to find and how to add nodes to your workflow.
  • Having a good grasp of automation logic (for example, passing data between nodes, handling conditions, etc.).

In short, you don’t need to be an expert, but having some hands-on experience will help you get the most out of this tutorial. Once you’ve got that covered, we can dive into the real stuff: building your first AI agent!

Tutorial 1: Build a Simple Conversational AI Agent in n8n (Beginner)

In this tutorial, you’ll learn how to create a simple chatbot connected to French Wikipedia using n8n. The main goal isn’t to build a high-performance agent but to understand the basics: how an AI agent works with its trigger, tools, memory, and LLM (the agent’s “brain”). This first project will help you build skills around key concepts, and you’ll be able to expand it later—for example, by connecting it to Telegram to turn it into a real personal assistant.

Get the AI Agent JSON File for Free

Video Tutorial to Build an AI Agent in n8n (Beginner)

Step-by-Step Guide to Build an AI Agent in n8n (Beginner)

Add OpenAI Credentials in n8n

Now that you’ve got your OpenAI API key, it’s time to connect it to n8n so you can use it in your workflows. Again, nothing complicated here.

Here are the steps to follow:

  1. Log in to your n8n dashboard.

  2. On the main screen, right next to the Create Workflow button, you’ll see a small arrow. Click it, then select Create Credential.

  3. From the list that appears, choose OpenAI as the application.

  4. A form will open: simply paste the API key you created in the previous step.

  5. Save, and you’re done.

With these credentials set up, you’ll be able to call OpenAI from your workflows, test requests, and—most importantly—start creating powerful and customized AI agents.

Add a Simple Trigger – When Chat Message Received

Now let’s get into the real action! We’re going to create our first workflow and add a trigger, which is the event that will activate the AI agent.

Here’s how to do it:

  1. From your n8n dashboard, click on Create a Workflow to start a new blank workflow.

  2. In the search bar on the right side of the screen, simply type “Chat”.

  3. From the results, select the trigger When Chat Message Received.

  4. Click on it, and voilà, the node is added to your workflow.

With this trigger, your workflow will be ready to react as soon as a message is received, which is perfect for building a conversational agent. We can now move on to the next step and connect the OpenAI model.

Add an AI Agent to the Workflow

Now that you’ve set up your When Chat Message Received trigger, let’s add the AI agent that will process the incoming messages.

Here are the steps:

  1. Click the small “+” next to the When Chat Message Received node you added earlier.

  2. From the list that appears, select AI, then AI Agent.

  3. Once the node is added, important: leave the default settings as they are.

    • For the Source for Prompt field, make sure Connected Chat Trigger Node is selected.

    • Don’t change anything else for now.

With this setup, your AI agent is already ready to receive messages captured by the trigger and respond to them. Next, we’ll enhance this setup to make it smarter and enable it to remember conversations.

Add the Chat Model

Now we’re going to connect the language model that allows your AI agent to understand and generate responses.

Here’s how to do it:

  1. Under the AI Agent node, you’ll see a section called ChatModel (it’s the first one on the left).

  2. Click the small “+” linked to this section.

  3. In the search bar on the right, type OpenAI ChatModel and select it from the list.

  4. In the node settings, make sure to choose the Credential to connect with that you created earlier with your OpenAI API key.

  5. For the model, you can keep the default option or select another one from the list. No need to get into details for now—models evolve quickly, and the main thing here is to validate that everything is working properly.

Once this step is complete, your AI agent will have its “brain” connected and will be ready to process prompts received via the trigger.

Add Memory

For your AI agent to be truly useful, it needs to be able to remember the context of a conversation. This is where memory comes into play.

Here’s how to add it:

  1. Under the AI Agent node, you’ll see a Memory button.

  2. Click on it.

  3. In the search bar on the right, select Simple Memory for Beginners. This is the simplest memory option and perfect for beginners.

At this point, you’ll see a field called Context Window Length.

This number represents the number of past interactions the AI agent will remember.

In a conversation, this allows the agent to retain previous exchanges in order to provide more relevant and coherent responses. The higher the number, the more context the agent will have, but be cautious—this can also use more resources.

Once this memory is added, your agent will already have a solid conversational base. Next, we can move on to adding the first tool to further enhance its capabilities.

Add Your First Tool

To make your AI agent truly useful, you need to give it access to external tools, called tools. In this example, we’ll connect just one tool: Wikipedia. This will allow it to pull information directly from Wikipedia and provide more comprehensive and relevant answers.

Here’s how to do it:

  1. Under the AI Agent node, click the Tool button.

  2. Click the small “+” below.

  3. In the search bar at the top right, type Wikipedia.

  4. Select the Wikipedia module from the list.

Once added, your agent will be able to query Wikipedia’s data to enrich its responses. This is a great starting point to allow it to pull information and enhance its answers with external content.

Test the First Conversational AI Agent in n8n

Congratulations, your conversational AI agent is ready!

You’ve just created your first AI agent in n8n.

To test it:

  • Click on OpenChat at the bottom of the screen.

  • Type your messages in the box at the bottom left.

  • Ask your questions, and it will respond live.

Example question connected to Wikipedia:

“What year was Julius Caesar born?” → The agent will look up the answer on Wikipedia and provide it.

But know that it’s very easy to take it further:

  • Instead of a chat message trigger in n8n, you can connect a Telegram channel, for example.

  • This will allow you to chat with your AI agent directly on Telegram (or any other tool connected to n8n).

  • You can link any tool you want to this AI module, give it the intelligence you need, and start conversations wherever you want, however you want.

Tutorial 2: Build an Autonomous AI Agent in n8n to Summarize RSS Feeds and Send Them to Notion

In this tutorial, you’ll learn how to create an autonomous AI agent in n8n that can automatically summarize an RSS feed in French. The main goal isn’t to build a complex agent, but to understand how to retrieve, process, and synthesize external data using AI. This project will help you deepen the basics covered in the first tutorial and apply AI to real-world use cases, which you can later expand with other sources or channels like Telegram.

Get the AI Agent JSON File for Free

Video Tutorial to Build an Autonomous AI Agent in n8n

Step-by-Step Guide to Build an Autonomous AI Agent in n8n

Create a Notion API Key and Prepare the Database

Start by generating a Notion API key. Click on your workspace in the top left, go to Settings → Connections → Manage Integrations. Create a new integration, select your workspace, set the type to internal, save, and get your API key.

In n8n, add these credentials: click on Create Credentials, select Notion, and paste your API key.

Finally, create a Notion database with the columns ID and FrenchResume — this is a mandatory prerequisite.

Add the RSS Feed Trigger

In n8n, click the + in the top right and search for RSS Feed Trigger. Select the first result.

In the Feed URL field, paste this example feed: https://seths.blog/feed/atom

Configure the AI Agent

Click the + again, search for AI, and select AI-Agent.

In Source for Prompt User Message, choose Define Below and add this prompt:

“Incoming article: – ID: {{ $json[“id”] }} – Content: {{ $json[“content”] }}

Your task: Decide if the article has already been processed, summarize if necessary, and store it in the Notion database.”

In System Message, paste this prompt:

“You are an expert autonomous assistant managing marketing blog articles. Your goal: – Process new RSS articles and manage their storage in Notion. Workflow: 1. When you receive a new article: – CALL THE GetAllPage TOOL **ONCE** to retrieve the database. – WAIT for the GetAllPage response. 2. Check if the current article ID exists. 3. If it exists → skip further actions. 4. If not: – Generate a short French summary. – CALL THE CreateNotionPage TOOL. Rules: – NEVER CALL GetAllPage MORE THAN ONCE PER ARTICLE. – WAIT FOR tool results before continuing. – Do NOT send raw JSON or tool outputs in your message. – Do NOT explain your reasoning.”

Add the OpenAI ChatModel

Add an OpenAI ChatModel module and leave the default model selected. It will serve as the AI engine to generate summaries in French.

Configure the Notion Tools

Add two Notion Tool modules: GetManyDataPage and Create a Notion Page.

For GetManyDataPage, set the Tool Description (set manually) as:

“Tool Name: GetAllPage

Description: This tool retrieves all articles from the Notion database. It returns two key fields for each article: – ID → the unique article identifier. – FrenchResume → the French summary of the article. You must use this data to determine if the current article has already been processed.”

For Create a Notion Page, set the Tool Description (set manually) as:

“Tool Name: CreateNotionPage

Description: This tool creates a new page in the Notion database. It takes two inputs, which must match the node’s parameters exactly: – title → the article’s unique identifier (used as the page title) – FrenchResume → the French summary generated by the AI It does not perform any validation or summarization.”

Test the Autonomous AI Agent

Run a test of the module. The agent will check if the article from the RSS feed already exists in Notion. If it doesn’t, it will automatically create a new entry with a French summary of the article.

Why Do We Call It an “Autonomous AI Agent”

An AI agent is not only designed to chat or answer questions, as shown in Tutorial 1. Here, we’re talking about an “autonomous” agent because it can take actions on its own, without human intervention.

Specifically, it is connected to tools like Notion and RSS feeds so that it can analyze information, make decisions (for example, check if an article already exists), and perform tasks automatically (such as summarizing the article and adding it to the database).

With every new RSS feed detected, the agent operates entirely autonomously: it checks, decides, and acts without needing any intervention. That’s the true power of an autonomous AI agent.

To Go Further: Build Advanced AI Agents on n8n with Multi-Tool Integrations

What You Can Do with Advanced AI Agents on n8n

Advanced AI Agents on n8n open up an almost limitless range of possibilities. Thanks to n8n and its compatibility with hundreds of APIs, you can automate practically anything that can be connected: multi-feed processing, report generation, CRM synchronization, data analysis, automatic responses, content generation, monitoring, and much more.

Where it gets revolutionary is that we’re no longer talking about simple or repetitive tasks, but also high-value tasks that previously required real human thought. Today, an AI agent can analyze, decide, and act autonomously, with a level of sophistication that radically transforms the way you work.

If you want to go further and deploy custom AI agents, our agency is here to help. Feel free to contact us to install turnkey AI agents tailored to your needs, maximizing your time savings and operational impact.

Contact

We will get back to you in a few minutes ✔

Why Connect Multiple Tools to Your AI Agent?

Connecting multiple tools to your AI agent on n8n amplifies its power. No more juggling between different software or switching from one task to another. The agent becomes capable of fetching information, cross-referencing it, analyzing, deciding, and then acting completely autonomously. The result? You go from a simple “assistant” to a true intelligent system that works for you, without constant supervision. It’s this ability to make decisions and trigger actions that makes AI truly revolutionary in your daily life.

Prepare n8n for Advanced AI Agents

Before diving into more complex workflows, take the time to properly set up your n8n environment. Structure your workflows clearly, write precise prompts to guide the AI, anticipate data volumes, and secure your API connections. Also, remember to test step by step to avoid hard-to-identify errors. The stronger your foundation, the more you’ll be able to evolve your AI agents into advanced, reliable, and truly autonomous use cases.

Where to Find Resources to Go Further?

To continue progressing and explore more advanced automations, I invite you to check out our downloadable automations catalogue — you’ll find ready-to-use n8n and Make workflows that will save you valuable time. And to stay updated on the latest news, advanced tips, and exclusive tutorials, sign up now for our newsletter. You’ll receive practical content directly in your inbox to help you evolve your AI projects on a daily basis.