AutomationAdvanced

How to Build an AI Agent with Tools in n8n

Set up the AI Agent node with a chat model, memory, and custom tools so it can decide when to call APIs instead of just chatting.

11 minAdvanced

A plain LLM node only talks. The AI Agent node reasons about a request and decides which tools to call to fulfil it, looping until it has an answer. This guide builds an agent that can check the weather and look up a value in a sheet, which shows the general pattern for giving an agent real abilities.

What you need

  • A running n8n instance with an OpenAI credential
  • A free weather API key (for example OpenWeather) for the example tool
  • Comfort with expressions and sub-node connections

Step 1: Add the AI Agent and a chat model

Start with a Chat Trigger, then add an AI Agent node. Connect a Chat Model sub-node (OpenAI Chat Model with gpt-4o) into the agent's Model input. This is the brain that plans and decides which tools to use.

n8n - AI Agent wiring
[Chat Trigger]
|
[ AI Agent ]
/ | \
[Chat Model] [Memory] [Tools: Weather, Sheet Lookup]
Model, memory, and tools all plug into the central agent node.

Step 2: Attach short-term memory

Connect a Simple Memory sub-node to the agent's Memory input. This lets the agent remember earlier turns in the same conversation so follow-up questions like that one work without repeating context.

Step 3: Add a tool the agent can call

Add an HTTP Request Tool sub-node into the agent's Tools input. Give it a clear name and description, because the agent reads the description to decide when to use it. Use a placeholder like {city} that the agent fills in at call time.

HTTP Request Tool - config
Name: get_weather
Description: Get current weather for a city. Input: a city name.
Method: GET
URL: https://api.openweathermap.org/data/2.5/weather
Query: q={city}&units=metric&appid=YOUR_KEY
Descriptions are the API contract
The agent never sees your node settings, only the tool name and description. Write them as if explaining to a new teammate exactly what the tool does and what input it expects.

Step 4: Add a second tool and test reasoning

Add a Google Sheets Tool so the agent can look up a row by key. Now ask a question that needs both tools and watch the execution log show the agent choosing each one in turn.

n8n - Agent reasoning
You
What should I wear in Lisbon today?
Agent
Calling get_weather with city=Lisbon... It is 24C and sunny. Light clothing and sunglasses are fine.
The agent decides to call the weather tool, then answers.

Result

You have an agent that picks the right tool for each request and remembers the conversation. Add more tools the same way (each is just a sub-node with a good description) and the agent's capabilities grow without you writing branching logic.

Watch related tutorials

Tags
#n8n#ai-agent#tools#langchain