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 };
1818
1919/**
2020 * Make an API request to Apify
21- *
2221 */
2322export async function apiRequest (
2423 this : IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions ,
@@ -29,15 +28,21 @@ export async function apiRequest(
2928 const query = qs || { } ;
3029 const endpoint = `https://api.apify.com${ uri } ` ;
3130
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+
3239 const options : IRequestOptions = {
3340 json : true ,
3441 ...rest ,
3542 method,
3643 qs : query ,
3744 url : endpoint ,
38- headers : {
39- 'x-apify-integration-platform' : 'n8n' ,
40- } ,
45+ headers,
4146 } ;
4247
4348 if ( method === 'GET' ) {
@@ -256,3 +261,8 @@ export function customBodyParser(input: string | object) {
256261 return input ;
257262 }
258263}
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