๐ŸŽ“Iris Courses
โ† AI Automation Mastery
Day 18 of 21

Agent Workflows

What Makes an Automation an Agent?

There's a spectrum from automation to agent. A basic automation follows a fixed path โ€” trigger, transform, act. An agent observes a situation, reasons about what to do, takes an action, observes the result, and decides what to do next. Agents handle novel situations that no fixed workflow could anticipate. The key properties of an agent workflow: a reasoning step (the AI thinks about what to do), access to tools (the agent can take actions like browsing the web, querying a database, sending messages, calling APIs), and a feedback loop (the agent can observe the results of its actions and adjust). In n8n, agent workflows use the AI Agent node (powered by LangChain under the hood). You configure: the model (Claude, GPT-4), the system prompt (defining the agent's role and available tools), and the tools (each tool is a sub-workflow or HTTP endpoint the agent can call). A simple agent example: a support agent that can look up orders in your database, check shipping status via an API, apply discount codes to accounts, and compose personalized responses. When a new support email arrives, the agent reads it, figures out what the customer needs, looks up their account, checks order status if needed, applies a discount if warranted, and sends a response โ€” all without human involvement. Agent boundaries matter: define what the agent can and cannot do. An agent with access to 'delete user accounts' is dangerous. An agent with access to 'read user data' and 'compose draft emails for human review' is safer. Start with read-only tools and add write access incrementally as you gain confidence.

Building a Research Agent

A research agent is one of the most practical and reusable agent patterns. Given a topic or company name, it researches online, synthesizes findings, and produces a structured report. Here's the architecture in n8n using the AI Agent node: System prompt: 'You are a research assistant. When given a company name, you will: 1) Search for recent news about the company, 2) Find their website and extract key information, 3) Look up their funding history if they're a startup, 4) Compile a structured report. Use the tools available to you.' Tools provided to the agent: - search_web: an HTTP Request node calling a search API (Serper, Bing, or SerpAPI) - fetch_url: an HTTP Request node that fetches a URL and returns the text content - save_report: a workflow that saves the compiled report to your database When you trigger this agent with 'Research Acme Corp', it will autonomously: search for 'Acme Corp recent news', read 2-3 news articles, fetch the Acme Corp homepage, search for 'Acme Corp funding Crunchbase', fetch the Crunchbase page, synthesize all findings, and save the report โ€” all through its own reasoning about which tools to call and in what order. The research agent pattern is reusable for: lead research before sales calls, competitor analysis, due diligence on potential hires or partners, and market research.

โšก Today's Action

Build a research agent in n8n that, given a company name, searches the web, extracts key information from their homepage, and generates a one-paragraph summary. Test it with 5 different companies.

๐Ÿ’ก Pro Tip

Add a 'max iterations' limit to every agent workflow โ€” agents can get into loops if a tool consistently fails or returns unexpected results. N8n's AI Agent node has a built-in max iterations setting; set it to 10-15 for most tasks.