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 connects to the N8N AI Agent service, enabling advanced AI capabilities such as chat interactions, tool execution, and memory management. It supports multiple AI models from providers like OpenAI, Anthropic, and Google, allowing users to select the model best suited for their needs.

Common scenarios include:

  • Engaging in conversational AI with system and user messages, optionally including media inputs.
  • Executing specific AI-powered tools with custom arguments and context.
  • Managing AI memory sessions by storing or retrieving data associated with session IDs.

Practical examples:

  • Automating customer support chats with contextual memory and multimedia input.
  • Running AI tools to analyze or transform data within workflows.
  • Maintaining conversation history and state across multiple workflow executions.

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

Note: The node also uses other parameters internally depending on the operation (e.g., message content, media inclusion, tool names, memory actions), but only "AI Model" was provided explicitly.

Output

The node outputs JSON objects with structure varying by operation:

  • Chat Operation:

    • message: The AI-generated response text.
    • model: The AI model used.
    • operation: The string "chat".
    • usage: Optional token usage statistics.
    • tool_calls: Optional details about any AI tool calls made during processing.
    • memory: Optional memory-related data returned by the AI agent.
    • finish_reason: Reason why the AI finished generating the response (e.g., "completed").
  • Tools Operation:

    • tool_name: The name of the executed tool.
    • result: The result or output from the tool.
    • execution_time: Optional time taken to execute the tool.
    • operation: The string "tools".
    • model: The AI model used.
  • Memory Operation:

    • action: The memory action performed (e.g., store, retrieve).
    • session_id: Identifier for the memory session.
    • data: The stored or retrieved memory data.
    • operation: The string "memory".

If the node encounters errors and is set to continue on failure, it outputs an error object containing the error message along with the operation and model used.

The node does not output binary data.

Dependencies

  • Requires connection to an N8N AI Agent service endpoint, typically hosted locally or remotely.
  • Needs an API key credential for authenticating requests to the AI Agent service.
  • Uses internal helper functions for HTTP requests and media file processing.
  • Supports media input processing for chat messages if enabled.

Troubleshooting

  • Missing API Key: The node throws an error if the API key is not provided. Ensure the API key credential is configured correctly.
  • Invalid API Key: If authentication fails, an error indicating an invalid API key is thrown. Verify the key's validity and permissions.
  • Endpoint Not Found: If the AI Agent endpoint is not reachable or disabled, a specific error is raised. Confirm that the AI Agent service is enabled and accessible at the configured URL.
  • Media Processing Issues: When including media, ensure the media source and files/URLs are valid and accessible.
  • Operation Parameter Errors: Using unsupported operations or missing required parameters may cause failures.
  • Continue On Fail: If enabled, errors per item are captured in output instead of stopping execution.

Links and References

Discussion