You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Let AI specify tool parameters with `$fromAI()`
4
-
description: Understand how n8n's `$fromAI()` function works and how to use it to dynamically populate parameters for AI app tools.
3
+
title: Let AI specify tool parameters
4
+
description: Understand how n8n's `$fromAI()` function works and how to use it to dynamically populate parameters for AI app tools, or use the built-in automation to complete them instead.
5
5
contentType: explanation
6
6
tags:
7
7
- $fromAI
@@ -12,13 +12,30 @@ hide:
12
12
- tags
13
13
---
14
14
15
-
# Let AI specify tool parameters with `$fromAI()`
15
+
# Let AI specify the tool parameters
16
16
17
-
When configuring [app node](/integrations/builtin/app-nodes/) tools connected to the Tools Agent, you can use the `$fromAI()` function to dynamically populate parameter values using the AI model. The AI model will fill in appropriate data given the context from the task and information from other connected tools.
17
+
When configuring [app node](/integrations/builtin/app-nodes/) 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.
18
18
19
-
## How the `$fromAI()` function works
19
+
There are two ways to do this, and you can switch between them.
20
20
21
-
The `$fromAI()` function uses AI to dynamically fill in parameters for tools connected to the [Tools AI agent](/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/tools-agent/). You can use the `$fromAI()` function in expressions within [app nodes](/integrations/builtin/app-nodes/) (like [Gmail](/integrations/builtin/app-nodes/n8n-nodes-base.gmail/), [Notion](/integrations/builtin/app-nodes/n8n-nodes-base.notion/), or [Slack](/integrations/builtin/app-nodes/n8n-nodes-base.slack/)) connected to a tool node.
21
+
## Let the model fill in the parameter
22
+
23
+
Each appropriate parameter field in the tool's editing dialog has an extra button at the end:
24
+
25
+

26
+
27
+
On activating this button, the AI Agent will fill in the expression for you, with no need for any further user input.
28
+
The field itself is filled in with a message indicating that the parameter has been defined automatically by the model.
29
+
30
+
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.
31
+
32
+
/// warning
33
+
Activating this feature will overwrite any manual definition you may have already added.
34
+
///
35
+
36
+
## Use the `$fromAI()` function
37
+
38
+
The `$fromAI()` function uses AI to dynamically fill in parameters for tools connected to the [Tools AI agent](/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/tools-agent/). You can use the `$fromAI()` function in expressions within [app nodes](/integrations/builtin/app-nodes/) (like [Gmail](/integrations/builtin/app-nodes/n8n-nodes-base.gmail/), [Notion](/integrations/builtin/app-nodes/n8n-nodes-base.notion/), or [Slack](/integrations/builtin/app-nodes/n8n-nodes-base.slack/)) which are connected to the **AI Agent** as tools.
22
39
23
40
/// note | Only for the Node Tools
24
41
The `$fromAI()` function is only available for [app node](/integrations/builtin/app-nodes/) tools connected to the Tools Agent. It isn't possible to use the `$fromAI()` function with the [Call n8n Workflow](/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolworkflow/), [Code](/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolcode/), [HTTP Request](/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolhttprequest/), or [other cluster sub-nodes](/integrations/builtin/cluster-nodes/sub-nodes/).
@@ -34,7 +51,7 @@ The `key` parameter and other arguments to the `$fromAI()` function aren't refer
34
51
35
52
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.
36
53
37
-
## Parameters
54
+
###Parameters
38
55
39
56
The `$fromAI()` function accepts the following parameters:
40
57
@@ -49,7 +66,7 @@ The `$fromAI()` function accepts the following parameters:
49
66
50
67
<!-- vale on -->
51
68
52
-
## Examples
69
+
###Examples
53
70
54
71
As an example, you could use the following `$fromAI()` expression to dynamically populate a field with a name:
55
72
@@ -69,7 +86,7 @@ To dynamically populate the number of items you have in stock, you could use a `
69
86
$fromAI("numItemsInStock", "Number of items in stock", "number", 5)
70
87
```
71
88
72
-
## Templates
89
+
###Templates
73
90
74
91
You can see the `$fromAI()` function in action in the following templates:
0 commit comments