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
Sometimes you want to fetch context data only when certain conditions are met—for example, when a specific header is provided. The `requiredToFetch` property lets you specify template variables that must resolve to non-empty values for the fetch to execute.
136
+
137
+
If any required variable is missing or resolves to an empty string, the fetch is **skipped** (not treated as an error), and the `defaultValue` is used if provided.
Copy file name to clipboardExpand all lines: agents-docs/content/docs/visual-builder/context-fetchers.mdx
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ Each key in the JSON should map to a fetch definition with the following propert
53
53
-**`body`** (optional): Request body for POST/PUT/PATCH requests
54
54
-**`transform`** (optional): JSONPath expression or JavaScript transform function to extract specific data from the response
55
55
-**`timeout`** (optional): Request timeout in milliseconds (defaults to 10000)
56
+
-**`requiredToFetch`** (optional): Array of template variables that must resolve to non-empty values for the fetch to execute. If any variable is missing or empty, the fetch is skipped and `defaultValue` is used instead. Useful for optional fetches that depend on request headers.
56
57
-**`responseSchema`** (optional): Valid JSON Schema object to validate the API response structure.
57
58
-**`defaultValue`** (optional): Default value to use if the fetch fails or returns no data
58
59
-**`credential`** (optional): Reference to stored credentials for authentication
@@ -91,6 +92,33 @@ Here is an example of a valid Context Variables JSON object:
91
92
}
92
93
```
93
94
95
+
### Optional Context Fetches
96
+
97
+
Use `requiredToFetch` when you want a fetch to only execute when certain headers are provided. This is useful for optional data that enhances the agent experience but isn't required.
98
+
99
+
Here's an example that fetches conversation history only when the `x-conversation-id` header is provided:
0 commit comments