Design and build AI agents with tools, memory, and multi-step reasoning capabilities. Covers ChatGPT, Claude, Gemini integration patterns based on n8n's 5,000+ AI workflow templates.
agent_types:reactive_agent:description:"Single-turn response, no memory"use_case:simple_qa,classificationcomplexity:lowconversational_agent:description:"Multi-turn with conversation memory"use_case:chatbots,supportcomplexity:mediumtool_using_agent:description:
"Can call external tools/APIs"
use_case:
data_lookup,
actions
complexity:
medium
reasoning_agent:
description:
"Multi-step planning and execution"
use_case:
complex_tasks,
research
complexity:
high
multi_agent:
description:
"Multiple specialized agents collaborating"
use_case:
complex_workflows
complexity:
very_high
Tool Calling Pattern
Tool Definition
tool_definition:name:"get_weather"description:"Get current weather for a location"parameters:type:objectproperties:location:type:stringdescription:"City name or coordinates"units:type:stringenum: ["celsius", "fahrenheit"]
default:"celsius"required: ["location"]
implementation:type:api_callendpoint:"https://api.weather.com/v1/current"method:GETparams:q:"{location}"units:"{units}"
n8n_agent_workflow:nodes:-trigger:type:webhookpath:"/ai-agent"-ai_agent:type:"@n8n/n8n-nodes-langchain.agent"model:openai_gpt4system_prompt:|
You are a helpful assistant that can:
1. Search the web for information
2. Query our customer database
3. Send emails on behalf of the user
tools:-web_search-database_query-send_email-respond:type:respond_to_webhookdata:"{{ $json.output }}"
Memory Patterns
Memory Types
memory_types:buffer_memory:description:"Store last N messages"implementation:|
messages = []
def add_message(role, content):
messages.append({"role": role, "content": content})
if len(messages) > MAX_MESSAGES:
messages.pop(0)
use_case:simple_chatbotssummary_memory:description:"Summarize conversation periodically"implementation:|
When messages > threshold:
summary = llm.summarize(messages[:-5])
messages = [summary_message] + messages[-5:]
use_case:long_conversationsvector_memory:description:"Store in vector DB for semantic retrieval"implementation:|
# Store
embedding = embed(message)
vector_db.insert(embedding, message)
# Retrieverelevant=vector_db.search(query_embedding,k=5)use_case:knowledge_retrievalentity_memory:description:"Track entities mentioned in conversation"implementation:|
entities = {}
def update_entities(message):
extracted = llm.extract_entities(message)
entities.update(extracted)
use_case:personalized_assistants
Thought: I need to find information about X
Action: web_search("X")
Observation: [search results]
Thought: Based on the results, I should also check Y
Action: database_query("SELECT * FROM Y")
Observation: [database results]
Thought: Now I have enough information to answer
Action: respond("Final answer based on X and Y")
support_agent:name:"Customer Support AI"model:gpt-4system_prompt:|
You are a customer support agent for {company}.
Guidelines:-Behelpful,professional,andempathetic-Usetheknowledgebasetoanswerquestions-Escalatetohumanifyoucannothelp-NevermakeupinformationAvailable actions:-Searchknowledgebase-Lookupcustomeraccount-Createsupportticket-Escalatetohumanagenttools:-knowledge_search:description:"Search help articles"-customer_lookup:description:"Get customer account info"-create_ticket:description:"Create support ticket"-escalate:description:"Transfer to human agent"escalation_triggers:-sentiment:very_negative-keywords: ["speak to human", "manager", "complaint"]
-failed_resolution:after_3_attempts
Research Agent
research_agent:name:"Research Assistant"model:claude-opussystem_prompt:|
You are a research assistant that helps users find
and synthesize information on any topic.
Process:1.Understandtheresearchquestion2.Plansearchstrategy3.Executesearchesacrossmultiplesources4.Synthesizefindings5.Presentwithcitationstools:-web_search-academic_search-news_search-wikipedia_lookupoutput_format:-executive_summary-key_findings-detailed_analysis-sources_cited
Output Example
Request: "Design an AI agent for appointment scheduling"
User: "I'd like to book an appointment"
Agent: [Thought: Need to know service type and preferred time]
Agent: "I'd be happy to help! What service are you looking for,
and do you have a preferred date/time?"
User: "Haircut, next Tuesday afternoon"
Agent: [Action: calendar_check(date="next Tuesday", time="afternoon")]
Agent: "I have availability at 2pm, 3pm, and 4:30pm next Tuesday.
Which works best for you?"
User: "3pm please"
Agent: [Action: book_appointment(datetime="Tuesday 3pm", service="haircut")]
Agent: [Action: send_notification(type="confirmation", ...)]
Agent: "You're all set for a haircut at 3pm next Tuesday.
I've sent a confirmation to your email. See you then!"