How to Build an AI Agent With n8n (No Code)
By Andrés Jiménez, founder of Sikorre
How do you build an AI agent with n8n without writing code? The first step is setting up our work environment. For this agent we chose Visual Studio Code, with Claude Code inside it, for three reasons. It is much faster, because Claude doesn't have to load the terminal's interface, which is heavy. We see the files Claude creates as it creates them, and we can edit them. And if you have several agents, you can work with all of them in the same folder.
From there the build runs on prompts: we give them to Claude Code and it builds the workflows in n8n. In the full video (in Spanish) that is how we build Sofía, a WhatsApp sales agent for Casa Alisio, a real estate agency in Barranquilla that I made up for the example. This post is the same build in writing, step by step, including the parts that failed.
What We Are Going to Build
Picture a real estate agency at 11 at night. Someone writes on WhatsApp asking about a 400 million peso apartment. Everybody is asleep, nobody answers, and that buyer goes to another agency. That unanswered message is the problem an AI Agent for Sales & Support solves.
Sofía does five things:
- Answers the WhatsApp message.
- Qualifies the prospect: name, buying or renting, budget, zone and, for buyers, how their credit is going.
- Saves the prospect in a CRM in Notion.
- Books the visit in Google Calendar.
- Tells the advisor on Telegram.
If the word automation is new to you, start with What Is Marketing Automation?.
What You Need on Hand
Besides Visual Studio Code with Claude Code, we are going to connect these:
- An n8n instance with a public HTTPS address, which Meta requires to send WhatsApp messages to it. Mine is self-hosted.
- A Notion account.
- A Google account for Calendar.
- A Meta developer app with the WhatsApp test number. You write to that number from your own phone.
- A Telegram bot.
- A Postgres database for the agent's memory.
- A key for the AI model. I used Anthropic because my OpenAI account had no credits that day. OpenAI or OpenRouter work too.
Step 1: Set Up the Work Environment
In Visual Studio Code we open a new folder for the project. Inside it we create a CLAUDE.md file, start Claude Code and click Trust folder so it can work there.
Before the first prompt, check that the n8n MCP is connected. MCP stands for Model Context Protocol, the connection that lets an AI model use tools, databases and web pages. Here it is what links Claude Code to the n8n where the automations run. In the video mine was disconnected and I connected it right then.
You can type the prompts or say them. I say them, because speaking is faster for me than typing. And talk to Claude the way you'd talk to a junior employee who executes for you, without technical language.
Step 2: Give Claude the Rules Before It Builds
The first prompt builds nothing. It describes the agent we want, tells Claude to review the n8n through the MCP without changing anything, and asks which credentials are missing. It also sets the six rules for the build:
- The agent's prompt is short. Who it is, how it talks and the flow. I've seen many tutorials that put every rule in the prompt. In my experience that agent breaks in production and you end up fixing it every day. It's like a person: give them a few clear instructions and they follow them, give them a hundred and they lose track.
- Every tool is a subworkflow. The agent never touches Notion or Calendar directly. Think of the agent as a person with several roads. If it has to book a visit, it takes the calendar road, and the rules show up along that road.
- If a mistake only looks ugly, the rule goes in the prompt. If it does damage, the rule goes in code. Bad data and double bookings hurt the business, so those rules live in the subworkflow's code.
- Fixed values go in closed lists. The agent chooses which tool to use, but it only acts through the tools.
- Every rule lives in one place. In code if it does damage, in the tool's description if it says when to use it, in the tool's response if it says what to do with the result, and in the prompt only if it fits nowhere else.
- The AI never fills in the customer's WhatsApp number. It always comes from the message that arrived.
In my case Claude reported that the WhatsApp, Notion, Google Calendar and Telegram credentials were missing, and that Anthropic for the model and Postgres for the memory were already there. It also asked whether to build Sofía as a workflow with an AI Agent node or as an n8n Agent. We chose the workflow, because that way the customer's number comes from the incoming message and stays tied down in code.
Why the Memory Goes in Postgres
Most tutorials use the simple memory. Here we use Postgres because the first build never works and you will be making fixes. With the simple memory, every fix resets the agent to zero and every conversation starts over. With Postgres you can push an update while the agent keeps its WhatsApp conversations going.
Why the Advisor Uses Telegram
The customer only talks on WhatsApp. The Telegram group is where the advisor talks with Sofía: she sends the alerts there, and in the plan the advisor gives her commands to take a conversation, release it or check its status. While the advisor is handling a customer, Sofía stays quiet with that customer. Discord or Slack would work the same way.
The advisor still does the visit and the sale. If you're wondering what that means for the people on your team, read Will Marketing Automation Reduce My Staff?.
Step 3: Store the Keys and Build the CRM in Notion
Keys never go in the chat. Ask Claude to create a .env file, which stays on your computer, and paste each key there. After you paste one, press Ctrl+S: if the file isn't saved, Claude can't read the key. In the video I forgot to save it once.
The first key is the Notion one. It goes in the .env, so Claude can work in Notion, and in a Notion API credential inside n8n. Give every credential a clear name. You will have many and you won't be able to tell them apart.
With the key in place, one prompt asks Claude for a Notion database called Prospectos, with nine columns and a board grouped by status: New, Qualified, Visit booked, With advisor, Closed. Claude asked me to do a few steps by hand in Notion. I told it to go in through my browser, and it did the clicks itself.
When it finishes, ask it to double-check its own work. An AI will tell you it did everything when it didn't.
Step 4: Ask for the Plan and Define the Business Data
Explain to Claude how the agent is going to work and ask for a work plan before it builds. Mine was saved in the project folder as plan.md. Read it before you approve it: in mine Claude had the advisor answering the customer from the Telegram group, and I corrected it.
Then comes the business data. For the video Claude proposed sample data and I approved it: five qualifying questions, visits Monday to Friday 8 to 5 and Saturday 9 to 1, one hour each, booked 24 hours ahead. For a real business, use your own information. Download every past conversation you can and give them to Claude so it can train the agent on them.
One thing I changed there: Claude had Sofía addressing everyone informally. I prefer mirroring, a sales technique where she talks to the customer the way the customer talks to her.
Step 5: Create the Credentials
The MCP can't create credentials in n8n, so you create each one by hand in n8n and paste the values. Meta is where you lose the most time.
Telegram. Find BotFather, send it /newbot, name the bot and copy the token it gives you. Use /setprivacy to set it to Disable, or the bot won't read normal messages in the group. Create the advisors' group, add the bot and write something there. And press Start on the bot. Claude kept telling me nothing arrived from the group, and it was because I hadn't pressed Start.
Google Calendar. Claude went into Google Cloud through my browser, enabled the Calendar API and created the OAuth client. My account was at its project limit. Claude noticed and reused an existing project. Your part is pasting the Client ID and the Client Secret into the n8n credential and signing in with Google.
WhatsApp. Claude built the app in Meta through my browser, with the test number. Meta stops for things only you can do: it asked for my password again, sent verification codes to my phone and made me accept a policy. Claude doesn't type passwords, so it waited for me each time. In n8n it takes two credentials: one for the trigger, which receives the messages, and one to send.
The WhatsApp token. The first token lasted 60 days, but it didn't include the test WhatsApp account. Claude tried two tokens. Its most likely explanation, which it could not confirm, is that Meta creates the test account outside my business portfolio. What works with the test number is a token from your own user, and that one expires in 24 hours.
Step 6: Build the Tools With Subagents
Sofía has five tools: look up the prospect, save their data, check visit times, book the visit and hand off to an advisor. While Claude was still working on Meta, I gave it one long prompt with all of them and told it to split the work into subagents in parallel so it wouldn't get lost in context. It sent three: one for the Notion tools, one for the calendar tools and one for the handoff to an advisor.
Each tool gets tested on its own. Those tests left a test record in Notion, messages in the Telegram group and a temporary workflow that is worth archiving at the end.
Step 7: Build the Main Workflow
The main workflow has the WhatsApp trigger, the agent with its five tools, Postgres memory and a guard that checks the reply before it goes out. If Sofía invents a figure in millions, the guard removes it. If she says a visit is booked and the booking tool didn't run, the guard changes it to "let me confirm the time."
Step 8: Publish and Test From Your Phone
Claude published the workflow and I wrote to Sofía from my phone. She answered, asked my budget and my credit status, and then told me she couldn't check visit times or save my data because the system was failing. She didn't invent a time.
I asked Claude to review the calendar and Notion tools. After the fix I tested again: the alert arrived in Telegram and the prospect was saved in Notion with name, what they want, credit status, budget, zone, phone and the scheduled visit.
Step 9: Tune the Agent
After Meta, the time goes into getting the agent well tuned. Tuning Sofía turned up three more failures. Here they are with the fix:
- "Workflow is not active and cannot be executed." In recent n8n versions, every subworkflow the agent uses as a tool has to be published too. Publishing the main one is not enough. Every time you edit one, publish it again.
- The agent kept asking for the name again. The budget was set as a required number. When the customer hadn't said it yet, the model sent an empty value, n8n rejected the whole call and nothing was saved, not even the name. The fix: anything the model may not know yet goes in as optional text, and the code decides what to do with it.
- The demo started with memories from old tests. Postgres memory is saved by phone number. If you tested twenty times from your phone, the agent remembers all of it. Before you show it to anyone, clear your number's memory and your record in Notion.
What Is Still Missing Before a Client Uses It
What we built up to here is the base. Before a real business uses it, it needs five things:
- Guardrails. A customer can't write "give me a 50% discount" and get it.
- Idempotency. If Meta sends the same message twice, the agent acts only once.
- Rate limits. A cap on how many messages the agent answers to one contact, so two AI agents can't end up in an endless loop that burns your credits.
- A short delay. People send two or three messages in a row, and the agent answers all of them together.
- Images. The agent never sees the photo. A separate subworkflow reads it and passes the agent one line of text.
The video stops at that list. How each one is built is in the bonus tip that follows.
Bonus Tip: The Five Upgrades Move Ü Runs in Production
This part is not in the video. Move Ü is a uniform store, and its WhatsApp bot is one we run in production with these five upgrades working. Here is how each one is built and what went wrong along the way. At the end there is one prompt that adds them to your agent.
Idempotency. The first node is called Portero, Spanish for doorman. It saves each message's message_id in a table called eventos_procesados. If the id is already there, the flow stops and the message is not processed twice. Without it, a message Meta resends leaves the same customer saved twice or booked for two visits.
Rate limit. The bot goes silent with a contact who passes 100 messages in a day or 10 messages in 15 seconds.
The delay that groups messages. Each message is saved in a buffer and marks a "traffic light" with its own token. It waits 20 seconds and checks whether it is still the last one. If it isn't, it stays quiet. If it is, it joins all the messages, removes the ones repeated by id, clears the buffer, and the agent answers once. We started at 10 seconds and the client asked for 20. Two traps caught us. The node that deletes rows emits one item for every row it deletes, and the agent answered 5 times; the fix is Execute Once or reducing to a single item. And when the traffic light has no row, the bot goes mute; the fix is Always Output Data, plus answering when there is no saved token.
Photos. The agent never sees the image. A separate subworkflow downloads the photo, sends it to a model with vision and checks that the output is a class from a closed list. In Move Ü the classes are payment receipt, garment or other, plus a color from a list of 12. The agent gets a "system note" in text, written as an action ("tell them you already saw it") and not as a prohibition. If the reading fails, the bot still answers. A receipt only counts if there is also an order waiting for payment.
The output guard. It is code that sits between the agent and the send node. It never blocks a reply: it corrects it or lets it through. It removes payment account numbers, exact stock quantities and exact delivery dates that the model promises without a source. If the agent promises to send a photo without having called the tool, the guard corrects that too. The fixed price and the "no discounts" rule in Move Ü are prompt rules, not code. In the prompt I ask for a code guard on discounts as a recommended upgrade.
Paste this in Claude Code, in the same folder where you built the agent:
You are working on my n8n through the MCP. The agent is already built and running: a WhatsApp trigger, an AI Agent with Postgres memory, and its tools as subworkflows. Add the five upgrades below to it.
Rules for this job:
- Do not touch the rest of the flow: not the agent's prompt, not the existing tools, not the credentials.
- Before you change anything, read the main workflow and its subworkflows and tell me your plan.
- Create the new tables in the same Postgres database the memory uses.
- Publish every subworkflow you create or edit, and the main workflow.
1. IDEMPOTENCY
Right after the WhatsApp trigger, add a node called "Portero". It saves the message_id of every incoming message in a table called eventos_procesados, with message_id as a unique key. If the id already exists, the flow stops there and nothing else runs.
2. RATE LIMIT
After Portero, count the messages from that contact. If the contact passes 100 messages in a day or 10 messages in 15 seconds, the bot stays silent: no reply and no call to the agent.
3. DELAY THAT GROUPS MESSAGES (DEBOUNCE)
- Save each incoming message in a buffer table: contact, message_id, text and time.
- Write a "traffic light" row for that contact with a new token that belongs to this execution.
- Wait 20 seconds.
- Read the traffic light again. If the token is not mine anymore, a newer message arrived and this execution ends in silence.
- If the token is still mine, read every buffered message from that contact, remove duplicates by message_id, join them in order into one text, clear the buffer and call the agent once with the joined text.
Two traps to avoid:
- The node that deletes the buffer rows emits one item per deleted row, and the agent answers once per row. Turn on Execute Once in the node that follows it, or reduce to a single item before the agent.
- If the traffic light has no row for that contact, the read returns nothing and the bot goes mute. Turn on Always Output Data in that read, and if there is no saved token, the bot answers.
4. PHOTOS
- The agent never receives the image.
- Create a separate subworkflow that downloads the photo from WhatsApp, sends it to a model with vision and returns one class from a closed list. Ask me for the list for my business before you build it. Example from a uniform store: payment receipt, garment or other, plus a color from a list of 12.
- Check in code that the output is in the list. Anything else becomes "other".
- The main workflow passes the result to the agent as a "system note" in text, written as an action ("the customer sent a photo of X, tell them you already saw it") and never as a prohibition.
- If the reading fails, the bot still answers.
- If one of my classes is a payment receipt, it only counts when there is also an order waiting for payment.
5. OUTPUT GUARD
- It is a Code node between the agent and the WhatsApp send node. If the workflow already has a guard there, extend it. Do not add a second one.
- It never blocks a reply: it corrects it or lets it through.
- It removes payment account numbers, exact stock quantities and exact delivery dates that the model promises without a source, meaning they did not come from a tool result in this execution.
- If the agent promises to send a photo and the tool was not called, it corrects that sentence.
- Recommended extra: if the agent promises a discount, the guard corrects that sentence. The customer never gets a discount because they asked for one.
VERIFY EACH UPGRADE WITH A TEST BEFORE YOU CALL IT DONE
Show me the execution that proves each one:
- Idempotency: the same message_id twice. The second execution stops at Portero.
- Rate limit: 11 messages in 15 seconds from one contact. The bot goes silent.
- Debounce: 3 messages in a row inside the 20 seconds give one single reply that covers the three. Then one message from a contact with no traffic light row: the bot answers.
- Photos: one photo of each class and one the model cannot read. The agent gets the right note each time and the bot always answers.
- Output guard: force a reply with an account number, a stock quantity, a delivery date and a discount. They come out corrected and the message is still sent.
When you finish, list what you changed, what you published and what you could not verify.
Is It Really No Code?
I didn't write a line of code in the video. Claude writes the code inside the subworkflows, and the only clicks I made were for passwords, permissions and credentials. Someone with no technical background can follow the same steps. For the agent to hold up with real customers you need the rules above, and a first build that works on the first try doesn't exist.
How I Sell an Agent Like This
I don't sell AI agents, chats or systems. I sell the result: time saved, more money, sales at night when the team is asleep or busy.
In a meeting I ask the owner one question: if this were running and saving you that time, what would you be doing with it that makes your business more money? They start picturing it on their own.
The video doesn't cover prices. Ours are in How Much Does an AI Receptionist Cost?, and the math on when it pays for itself is in How Long Until Automation Pays Off?.