Skip to content

Commit 266a6d8

Browse files
Add information about automatic AI parameters (n8n-io#2820)
Co-authored-by: Justin Ellingwood <[email protected]>
1 parent a8fd1e2 commit 266a6d8

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

docs/_images/advanced-ai/ai-stars.png

11.2 KB
Loading

docs/advanced-ai/examples/using-the-fromai-function.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
#https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
3-
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.
55
contentType: explanation
66
tags:
77
- $fromAI
@@ -12,13 +12,30 @@ hide:
1212
- tags
1313
---
1414

15-
# Let AI specify tool parameters with `$fromAI()`
15+
# Let AI specify the tool parameters
1616

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.
1818

19-
## How the `$fromAI()` function works
19+
There are two ways to do this, and you can switch between them.
2020

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+
![image showing stars icon to the right of parameter field](/_images/advanced-ai/ai-stars.png)
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.
2239

2340
/// note | Only for the Node Tools
2441
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
3451

3552
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.
3653

37-
## Parameters
54+
### Parameters
3855

3956
The `$fromAI()` function accepts the following parameters:
4057

@@ -49,7 +66,7 @@ The `$fromAI()` function accepts the following parameters:
4966

5067
<!-- vale on -->
5168

52-
## Examples
69+
### Examples
5370

5471
As an example, you could use the following `$fromAI()` expression to dynamically populate a field with a name:
5572

@@ -69,7 +86,7 @@ To dynamically populate the number of items you have in stock, you could use a `
6986
$fromAI("numItemsInStock", "Number of items in stock", "number", 5)
7087
```
7188

72-
## Templates
89+
### Templates
7390

7491
You can see the `$fromAI()` function in action in the following templates:
7592

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ nav:
14571457
- Use Google Sheets as a data source: advanced-ai/examples/data-google-sheets.md
14581458
- Call an API to fetch data: advanced-ai/examples/api-workflow-tool.md
14591459
- Set a human fallback for AI workflows: advanced-ai/examples/human-fallback.md
1460-
- Let AI specify tool parameters with `$fromAI()`: advanced-ai/examples/using-the-fromai-function.md
1460+
- Let AI specify tool parameters: advanced-ai/examples/using-the-fromai-function.md
14611461
- What is a vector database?: advanced-ai/examples/understand-vector-databases.md
14621462
- Populate a Pinecone vector database from a website: advanced-ai/examples/vector-store-website.md
14631463
- API:

0 commit comments

Comments
 (0)