20 min
Lesson 2 of 4
Building AI Agents & RAG Pipelines
From the course n8n AI Workflow Builder
n8n's AI Agent node is one of the most powerful no-code agent builders available. It lets you create agents that can reason, use tools, and maintain conversation memory.
AI Agent Architecture
An n8n AI Agent consists of:
- LLM: The brain (GPT-4, Claude, Gemini, local models via Ollama)
- Tools: Actions the agent can take (HTTP requests, database queries, calculations)
- Memory: Conversation history (window buffer, summary, or vector memory)
- Output Parser: Structures the agent's response
Building a RAG Pipeline
Retrieval-Augmented Generation (RAG) lets your AI answer questions using your own documents:
Ingestion Workflow:
- File Trigger: Watch a folder for new documents
- Document Loader: Parse PDF, Word, or text files
- Text Splitter: Break documents into chunks (500-1000 tokens)
- Embeddings: Generate vector embeddings (OpenAI, Cohere)
- Vector Store Insert: Store in Pinecone, Qdrant, or Supabase
Query Workflow:
- Chat Trigger: User asks a question
- Vector Store Retrieval: Find relevant document chunks
- AI Agent: Answer using retrieved context + conversation memory
- Response: Return the answer with source citations
Tool Integration
n8n agents can use these built-in tools:
- HTTP Request Tool: Call any API
- Code Tool: Execute JavaScript or Python
- Database Tool: Query SQL databases
- Wikipedia Tool: Search Wikipedia
- Calculator Tool: Perform calculations
- Custom Tools: Build your own with sub-workflows
Key Takeaways
- •AI Agents combine an LLM, tools, and memory for autonomous task execution
- •RAG pipelines ingest documents into vector stores for context-aware AI answers
- •n8n supports multiple vector stores including Pinecone, Qdrant, and Supabase
- •Custom tools can be built as sub-workflows for agent extensibility
0 of 4 lessons marked complete
Progress is kept in this browser only.