Overview
This node, named "N8N AI Agent," connects to an external AI Agent service to provide advanced AI capabilities including chat interactions, tool execution, and memory management. It supports multiple AI models from providers like OpenAI, Anthropic, and Google.
The "Use Tools" operation allows users to invoke specific tools by name with custom arguments and optional context, leveraging the selected AI model. This is useful for scenarios where you want to integrate AI-driven tool execution within your workflows, such as fetching weather data, performing calculations, or querying external APIs via AI-managed tools.
Practical example:
You can configure this node to call a weather tool by specifying "get_weather" as the tool name and passing location parameters in JSON format. The AI Agent will execute the tool and return the result, enabling dynamic, AI-assisted automation in your workflow.
Properties
| Name | Meaning |
|---|---|
| AI Model | Select the AI model to use. Options include: GPT-4 Turbo, GPT-4, GPT-3.5 Turbo, Claude 3 Opus, Claude 3 Sonnet, Claude 3 Haiku, Gemini Pro. |
| Tool Name | Name of the tool to execute (e.g., get_weather). |
| Tool Arguments | JSON object containing arguments to pass to the tool (e.g., {"location": "São Paulo", "units": "celsius"}). |
| Context | Optional string providing additional context for tool execution (e.g., "User is asking about weather in their city..."). |
Output
The output JSON structure for the "Use Tools" operation includes:
tool_name: The name of the executed tool.result: The result returned by the tool execution, typically the main output or response.execution_time: (Optional) Time taken to execute the tool.operation: The operation performed, here always"tools".model: The AI model used for the request.
If the node supports binary data output, it is not indicated in this operation; the output focuses on JSON results from tool execution.
Dependencies
- Requires connection to an external N8N AI Agent API service.
- Requires an API key credential for authenticating requests to the AI Agent service.
- The AI Agent service URL defaults to
http://localhost:5678but can be configured via credentials. - The node uses HTTP POST requests to communicate with the AI Agent API endpoints.
Troubleshooting
- Missing API Key: If the API key is not provided or invalid, the node throws an error indicating that the API key is required or invalid.
- Endpoint Not Found: If the AI Agent endpoint is not enabled or reachable, an error stating "N8N AI Agent endpoint not found" will appear.
- API Errors: Other errors from the AI Agent API are surfaced with descriptive messages prefixed by "N8N AI Agent API error".
- Invalid JSON in Tool Arguments: Ensure that the JSON provided in "Tool Arguments" is well-formed to avoid parsing issues.
- Tool Execution Failures: If the specified tool name does not exist or fails internally, the result may be empty or contain error details depending on the AI Agent's response.
Links and References
- N8N Documentation – For general n8n usage and credential setup.
- External AI model providers' documentation (OpenAI, Anthropic, Google Gemini) for understanding model capabilities.
- Relevant API documentation for the AI Agent service if available (not included in source).