N8N AI Agent icon

N8N AI Agent

Connect to N8N AI Agent service for advanced AI capabilities with tool calling and memory

Overview

This node integrates with the N8N AI Agent service to provide advanced AI capabilities including chat interactions, tool execution, and memory management. Specifically for the Memory operation, it allows users to store, retrieve, or clear data in an AI agent's memory associated with a unique session ID. This is useful for scenarios where you want the AI to remember user preferences, context, or any other relevant information across multiple workflow executions or interactions.

Practical examples include:

  • Storing user settings or preferences during a conversation to personalize responses.
  • Retrieving previously stored data to maintain context in multi-step workflows.
  • Clearing memory to reset the AI agent’s state for a new session or user.

Properties

Name Meaning
AI Model Select the AI model to use. Options: GPT-4 Turbo, GPT-4, GPT-3.5 Turbo, Claude 3 Opus, Claude 3 Sonnet, Claude 3 Haiku, Gemini Pro.
Memory Action Action to perform on AI Agent memory. Options: Store (save data), Retrieve (get data), Clear (remove data).
Session ID Unique identifier string for isolating memory per session or user (e.g., "user-123").
Memory Data JSON object containing data to store in memory. Only shown when Memory Action is "Store". Example: {"user_preferences": {"language": "pt-BR", "timezone": "America/Sao_Paulo"}}.

Output

The output JSON structure varies depending on the memory action performed:

  • For Store and Retrieve actions, the output contains:

    • action: The memory action performed (store, retrieve, or clear).
    • session_id: The session identifier used.
    • data: The memory content returned by the AI agent after the action. For retrieval, this is the stored data; for storing, it confirms what was saved.
    • operation: Always "memory" indicating the operation type.
  • For Clear action, the data field typically reflects the cleared state (likely empty or null).

Example output JSON snippet:

{
  "action": "retrieve",
  "session_id": "user-123",
  "data": {
    "user_preferences": {
      "language": "pt-BR",
      "timezone": "America/Sao_Paulo"
    }
  },
  "operation": "memory"
}

No binary data output is involved in this operation.

Dependencies

  • Requires connection to an instance of the N8N AI Agent service, accessible via a base URL.
  • Requires an API key credential for authenticating requests to the N8N AI Agent API.
  • The node expects the AI Agent service to be enabled and reachable at the configured endpoint.
  • No additional external services are directly required beyond the AI Agent API.

Troubleshooting

  • Missing or invalid API key: The node will throw an error if the API key is missing or invalid. Ensure that a valid API key credential is configured.
  • AI Agent endpoint not found: If the AI Agent service is not enabled or the URL is incorrect, a 404 error will occur. Verify that the AI Agent is running and the base URL is correct.
  • Session ID issues: Using an empty or non-unique session ID may cause memory collisions or unexpected behavior. Always provide a meaningful unique session identifier.
  • Malformed JSON in Memory Data: When storing data, ensure the JSON input is well-formed to avoid errors.
  • Network or connectivity problems: General request failures may happen due to network issues; verify connectivity to the AI Agent service.

Links and References


This summary covers the static analysis of the node's execute method focusing on the Default resource and Memory operation as requested.

Discussion