File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ type IApiRequestOptions = IRequestOptions & { uri?: string };
18
18
19
19
/**
20
20
* Make an API request to Apify
21
- *
22
21
*/
23
22
export async function apiRequest (
24
23
this : IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions ,
@@ -29,15 +28,21 @@ export async function apiRequest(
29
28
const query = qs || { } ;
30
29
const endpoint = `https://api.apify.com${ uri } ` ;
31
30
31
+ const headers : Record < string , string > = {
32
+ 'x-apify-integration-platform' : 'n8n' ,
33
+ } ;
34
+
35
+ if ( isUsedAsAiTool ( this . getNode ( ) . type ) ) {
36
+ headers [ 'x-apify-integration-ai-tool' ] = 'true' ;
37
+ }
38
+
32
39
const options : IRequestOptions = {
33
40
json : true ,
34
41
...rest ,
35
42
method,
36
43
qs : query ,
37
44
url : endpoint ,
38
- headers : {
39
- 'x-apify-integration-platform' : 'n8n' ,
40
- } ,
45
+ headers,
41
46
} ;
42
47
43
48
if ( method === 'GET' ) {
@@ -256,3 +261,8 @@ export function customBodyParser(input: string | object) {
256
261
return input ;
257
262
}
258
263
}
264
+
265
+ export function isUsedAsAiTool ( nodeType : string ) : boolean {
266
+ const parts = nodeType . split ( '.' ) ;
267
+ return parts [ parts . length - 1 ] === 'apifyTool' ;
268
+ }
You can’t perform that action at this time.
0 commit comments