You, n8n and Your First AI Agent, Built in 30 Minutes

ME

My Equation ยท The My Equation Team

31 Jul 2025 ยท 9 min read ยท Updated 9 Sept 2026

Building AI agents with n8n

Every hour, someone somewhere is building a new AI agent โ€” scheduling meetings, replying to emails, running entire workflows. Basically doing all the stuff you thought was tedious.

Welcome to the era of AI agents.

OpenAI dropped their "Agent" framework and people were hyped, until they realised it isn't free. But it's 2025. We don't wait for free versions anymore โ€” we build our own.

This is a clean, beginner-friendly walkthrough of building your very own AI agent. People will tell you "no coding knowledge needed," but honestly it's always better to have a little bit of coding context. The tool we're using is called n8n.

What Even Is an AI Agent?

It's one step ahead of what ChatGPT can do on its own. Think of it like this: an AI agent is a smart worker with context, memory, and access to tools.

Say you ask ChatGPT: "Remind me to drink water every 2 hours." It'll reply with something like "Sure โ€” here's your schedule reminder for every 2 hours." But what it can't physically do is give you an actual alarm, trigger, or notification.

That's where an AI agent comes in. It understands the request, sets a timer, triggers a notification system, and reminds you to drink water every 2 hours, automatically.

To understand how agents actually get things done, we need a brief understanding of AI tools, workflows, and automation.

Step 1: AI Tools

An AI tool is an app that does a task using AI.

  • ChatGPT: takes a prompt, gives a reply.

  • Midjourney: takes text, gives an image.

  • ElevenLabs: takes text, gives a voice.

On their own, AI tools don't achieve outcomes. You still have to connect and use them in a specific order.

Step 2: Workflow

Say you're creating an Instagram Reel and want to use AI tools for it. Your steps might look like:

  • Write the script in Google Docs

  • Convert that script into voice using ElevenLabs

  • Make a video using HeyGen

This series of steps, followed in a specific order, is a workflow. Think of it as a recipe: each tool is an ingredient, and the steps are how you combine them.

Step 3: Automation

Now imagine doing this same process every single day. Wouldn't it be better if the system just ran itself?

That's what automation does. Every day you write a script, and the system automatically takes that script, sends it to ElevenLabs, then to HeyGen, and returns the final video โ€” all without human intervention.

What Is n8n, and Why Is It Perfect for AI Agents?

n8n (say it like "n-eight-n") is a no-code automation tool. It's where you connect your apps, add AI, run tasks on autopilot, and build full AI agents without writing a single line of code.

The best part: it's open source, and you can host it on your own machine.

Think Zapier, but open source and far more flexible than most drag-and-drop tools. With n8n you can:

  • Run workflows on a schedule.

  • Connect to ChatGPT, Gmail, Notion, Telegram, Google Sheets โ€” anything with an API.

  • Add memory, logic, conditions, loops.

  • Build smart, context-aware agents that behave like mini-employees.

The shape of it is always: trigger โ†’ do something โ†’ do the next thing โ†’ automate it โ†’ done.

How to Use n8n for Free

n8n provides a 14-day cloud trial and 1,000 free workflow runs. But if you want to use it forever for free, you can self-host it on your own machine.

For that, we're using Docker. You don't need to know what Docker is in depth โ€” you just need to know why we're using it. Docker lets us run apps like n8n on our own computer, like launching a mini server inside a box, without messing up our system. Think of it as installing an app with one click, except the app lives inside its own safe container.

This tutorial uses Windows 11. If you're on Mac or Linux, the interface and setup steps may look a little different, but the core process stays the same.

Step 1: Download Docker

Go to Docker Desktop and download the version that suits your OS. Install it. You may need to restart your machine. If you're on Windows, you might be prompted to enable WSL (Windows Subsystem for Linux) โ€” allow it.

Step 2: Launch Docker

Once installed, double-click Docker Desktop to start it. Accept the agreement and skip account setup.

Step 3: Open Command Prompt

Hit the Start menu, type cmd, and open Command Prompt. Now type:

docker volume create n8n_data

If it works, you'll see n8n_data echoed back. Now run:

docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n

Wait a few moments โ€” your n8n is running locally.

Access Your Local n8n

Open your browser and go to http://localhost:5678. You'll see the n8n dashboard. Create an account, and you're in.

The interface is clean and beginner-friendly. Top right lets you create new workflows; the bottom left corner gives you access to thousands of free templates; the middle section lists all the workflows you build.

Click "AI Agents" in the templates and you'll see WhatsApp bots, ChatGPT responders, email writers, Notion journal entries. These are pre-built workflows you can import, tweak, and run in minutes.

The Goal

We're going to create a smart WhatsApp chatbot using n8n, the WhatsApp Business Cloud API, and Google Gemini, to respond conversationally to messages sent on WhatsApp.

What this agent will do:

  • Wait for incoming messages via WhatsApp

  • Send those messages to a smart AI (Gemini)

  • Have the AI generate a relevant response

  • Reply back to the sender via WhatsApp

  • Include a memory buffer to maintain context across messages

Don't get scared by how many steps are ahead. Take breaks if you need โ€” but don't forget to save your workflow.

Step-by-Step Build

Step 1: Set Up the WhatsApp Business Cloud Trigger

  • In your local n8n instance, click + to create a new workflow.

  • Select Trigger Manually.

  • Add a WhatsApp Business Cloud Trigger node.

  • From the dropdown, select On Messages โ€” this triggers your workflow every time a WhatsApp message is received.

  • If credentials aren't set, click Create New Credential. You'll need a Client ID and Client Secret.

Step 2: Create a Facebook App to Get Credentials

  • Go to business.facebook.com and sign in. Make sure you have a business account on Meta; if not, create one.

  • Navigate to Business Settings โ†’ Apps โ†’ Create App.

  • Name it (for example, "n8n chatbot") and click Next.

  • Choose Other, then Next.

  • Select Business, click Next, fill in the details, and create the app.

  • Under App Settings โ†’ Basic, copy the App ID (use as Client ID) and App Secret (use as Client Secret).

  • Paste both into the n8n credential window and save. The connection should say "Tested Successfully."

If you don't have a business account, just make a new Facebook or Instagram account and log into your Meta account. Note that a brand-new account may take an hour or so before Meta lets you in, so it's easier to use an existing or older account.

Step 3: Add Gemini as the Chat Model

  • Click + in your workflow, then choose Advanced AI โ†’ AI Agent.

  • Inside the AI Agent node, click Chat Model and choose Google Gemini.

  • If prompted for credentials, visit Google AI Studio, click Get API Key, copy the key, paste it into n8n and save.

  • Select a Gemini Flash model for faster, near real-time responses.

You can choose any model here. OpenAI's API works too and includes some free credits. We're not using Anthropic because Claude doesn't offer a public API key for free use, and n8n requires an API key to connect to a model.

Step 4: Add a Memory Buffer

  • Click + and add a WhatsApp Buffer Memory node.

  • Choose Define Below.

  • Set the key as an expression: {{ $('WhatsApp Msg').item.json.contacts[0].wa_id }}

  • Make sure the trigger name in the key matches the name of the trigger node you used earlier.

Step 5: Add the WhatsApp Message Sender Node

  • Click + and search for WhatsApp Business Cloud, then choose Send Message.

  • To set up credentials, go back to your Facebook App dashboard and click WhatsApp โ†’ API Setup.

  • Step 1 there gives you a Test Number. Add FROM (test number) and TO (your number).

  • Click Generate Access Token and copy the token.

  • Go to Tools โ†’ Access Token Debugger, add your access token, and click Extend Access Token to extend its life.

  • Copy your WhatsApp Business Account ID.

  • In n8n, paste the access token and business account ID.

  • In the Send Message node, set the recipient number (include the country code) and drag the AI Agent output into the message body.

Step 6: Connect the Nodes

Your node flow should now look like: WhatsApp Trigger โ†’ AI Agent โ†’ Memory โ†’ WhatsApp Send Message.

Testing and Debugging Your Agent

Set the test number. Use the same number for both the recipient phone number and the access token generated for this test number. Add your phone number with the correct country code โ€” format matters, so ensure it matches what's specified in the WhatsApp Business Cloud settings.

Send a sample test message. In the text body of the WhatsApp message node, temporarily type success. Head back to the canvas in n8n and click Test Workflow. Open WhatsApp and send "Hi, how are you?"

Fix the missing prompt error. If you get "Problem in node AI Agent: No prompts have been specified," click on the AI Agent node, set Prompt Source to "Define below," then drag and drop the incoming WhatsApp message body into the Text field.

Retest with dynamic output. Click Test Step, go back to the canvas, and test the workflow again. Send a message from WhatsApp โ€” your chatbot should now reply with something like "I'm fine, how can I be of assistance today?"

Replace the static message. In the WhatsApp node, delete the hardcoded "success" and drag the output from the AI Agent node into the message body field.

Activate the workflow. Click Activate Workflow so your chatbot runs in the background and responds automatically to every message, instead of you testing manually each time.

Test a back-and-forth conversation. Try a follow-up like "Can you suggest some good recipes to cook with chickpeas?" The chatbot should respond dynamically, and you'll see the execution flow inside n8n with trigger and response logs.

Filter for text messages only. WhatsApp sometimes sends messages in non-text formats like images or locations. To avoid processing those, click +, search for the If node, and set the condition to Text โ†’ String โ†’ Exists. Drag the incoming message body into that field.

Save your workflow. The most important step of all.

Conclusion

If you've got questions or errors, you'll almost certainly have some. Drop them in the comments โ€” or dig through Reddit; odds are someone has hit the same error before.

But here's the thing: you now understand the building blocks โ€” triggers, AI, APIs, automation. From here, the possibilities are genuinely endless.

So go build more. Try things. Let them fail. Let them go weird. And if you create something cool, tag us.

This article was originally published on Medium by the My Equation team.

  • n8n
  • AI Agents
  • Automation
  • WhatsApp
  • Docker
  • Gemini

Keep reading