Better AI Agent
Overview
The Better AI Agent node is an advanced AI conversational agent designed to interact with users by processing input prompts and generating intelligent responses. It integrates modern AI SDKs and supports tool usage with proper memory management, enabling multi-step reasoning and interaction with external tools during the conversation.
This node is beneficial in scenarios where you want to build complex AI-driven workflows that require:
- Context-aware conversations with memory of previous interactions.
- Use of external tools or APIs dynamically during the conversation.
- Step-by-step reasoning with control over maximum steps.
- Real-time partial result reporting via webhooks.
Practical examples:
- A customer support chatbot that remembers past user queries and uses external knowledge bases or APIs to provide accurate answers.
- An AI assistant that can perform multi-step tasks such as booking appointments, fetching data from other services, or summarizing information.
- Interactive agents that report progress or intermediate results to a monitoring system through webhook callbacks.
Properties
| Name | Meaning |
|---|---|
| Tip: This node uses modern AI SDK with proper tool call memory management | Informational notice about the node's use of modern AI SDK and memory handling. |
Source for Prompt (User Message) (promptType) |
Defines how the prompt text is sourced: - Connected Chat Trigger Node: Uses the chatInput field from a directly connected chat trigger node.- Define below: Manually enter or reference prompt text. |
Prompt (User Message) (text) |
The actual user message or prompt to send to the AI model. Required. Its visibility depends on the selected promptType. |
Options (options) |
Collection of additional settings: - System Message: Defines the AI assistant’s behavior and context. - Max Steps: Maximum number of tool call steps before stopping (1–20). - Intermediate Webhook URL: If set, partial replies and tool calls are POSTed as JSON to this URL during execution. - Verbose Logs: Enables detailed console logging for debugging purposes. |
Output
The node outputs an array of items, each containing a json object with the following fields:
output: The final generated text response from the AI agent.steps: An array detailing each step taken by the agent, including any tool calls made.totalSteps: The total number of steps executed during the generation process.
If the node interacts with tools, the output includes detailed information about tool calls and their results embedded within the steps.
No binary data output is produced by this node.
Dependencies
- Requires connection to a supported AI language model node (e.g., OpenAI, Anthropic, Google Gemini, or others compatible with the integrated AI SDK).
- Optionally connects to AI memory nodes for conversation history persistence.
- Optionally connects to AI tool nodes to enable tool usage during conversation.
- For some providers, API keys or authentication tokens must be configured in n8n credentials or environment variables.
- If using the Intermediate Webhook URL option, an accessible HTTP endpoint is required to receive partial updates.
- Telemetry integration with OpenTelemetry and Langfuse/Langsmith exporters is included if environment variables and API keys are set.
Troubleshooting
- No language model connected: The node throws an error if no AI language model node is connected. Ensure a compatible AI model node is linked.
- No input text provided: If the prompt text is missing or empty, the node will error. Verify the prompt source and input data.
- API key missing or invalid: If the connected AI model requires an API key and it is not configured properly, the node will fail. Check credential setup.
- Failed to load/save conversation memory: Warnings may appear if memory nodes are misconfigured or inaccessible; the node will continue without memory in such cases.
- Intermediate webhook failures: If the webhook URL is invalid or unreachable, warnings are logged but do not stop execution.
- Verbose logs enabled: Use this option to get detailed console output for debugging issues related to model calls, tool executions, or memory operations.
- Unsupported model type: If the connected AI model is not recognized by the node’s internal logic, an error is thrown. Update the node or use a supported model.
Links and References
This summary is based solely on static analysis of the provided source code and property definitions.