Let AI specify the tool parameters#
When configuring app node tools connected to the Tools Agent, many parameters can be filled in by the AI model itself. The AI model will use the context from the task and information from other connected tools to fill in the appropriate details.
There are two ways to do this, and you can switch between them.
Let the model fill in the parameter#
Each appropriate parameter field in the tool's editing dialog has an extra button at the end:
On activating this button, the AI Agent will fill in the expression for you, with no need for any further user input. The field itself is filled in with a message indicating that the parameter has been defined automatically by the model.
If you want to define the parameter yourself, click on the 'X' in this box to revert to user-defined values. Note that the 'expression' field will now contain the expression compiled by AI, though you can now edit it further to add extra details as described in the following section.
Warning
Activating this feature will overwrite any manual definition you may have already added.
Use the $fromAI()
function#
The $fromAI()
function uses AI to dynamically fill in parameters for tools connected to the Tools AI agent. You can use the $fromAI()
function in expressions within app nodes (like Gmail, Notion, or Slack) which are connected to the AI Agent as tools.
Only for the Node Tools
The $fromAI()
function is only available for app node tools connected to the Tools Agent. It isn't possible to use the $fromAI()
function with the Call n8n Workflow, Code, HTTP Request, or other cluster sub-nodes.
To use the $fromAI()
function, call it with the required key
parameter:
1 |
|
The key
parameter and other arguments to the $fromAI()
function aren't references to existing values. Instead, think of these arguments as hints that the AI model will use to populate the right data.
For instance, if you choose a key called email
, the AI Model will look for an email address in its context, other tools, and input data. In chat workflows, it may ask the user for an email address if it can't find one elsewhere. You can optionally pass other parameters like description
to give extra context to the AI model.
Parameters#
The $fromAI()
function accepts the following parameters:
Parameter | Type | Required? | Description |
---|---|---|---|
key |
string | A string representing the key or name of the argument. This must be between 1 and 64 characters in length and can only contain lowercase letters, uppercase letters, numbers, underscores, and hyphens. | |
description |
string | A string describing the argument. | |
type |
string | A string specifying the data type. Can be string, number, boolean, or json (defaults to string). | |
defaultValue |
any | The default value to use for the argument. |
Examples#
As an example, you could use the following $fromAI()
expression to dynamically populate a field with a name:
1 |
|
If you don't need the optional parameters, you could simplify this as:
1 |
|
To dynamically populate the number of items you have in stock, you could use a $fromAI()
expression like this:
1 |
|
Templates#
You can see the $fromAI()
function in action in the following templates: