{
	"createdAt": "2025-09-08T10:32:07.628Z",
	"updatedAt": "2025-09-08T10:32:07.628Z",
	"name": "Tool in Loop: Multiple invocation per loop",
	"id": "264",
	"active": false,
	"nodes": [
		{
			"parameters": {
				"workflowInputs": {
					"values": [
						{
							"name": "query"
						}
					]
				}
			},
			"type": "n8n-nodes-base.executeWorkflowTrigger",
			"typeVersion": 1.1,
			"position": [464, -144],
			"id": "d095d0a6-c44e-400a-baa2-37fcaf256181",
			"name": "When Executed by Another Workflow"
		},
		{
			"parameters": {
				"resource": "all",
				"limit": 1,
				"additionalFields": {
					"keyword": "={{ $json.query }}"
				}
			},
			"type": "n8n-nodes-base.hackerNews",
			"typeVersion": 1,
			"position": [672, -144],
			"id": "ab3d4c41-9bc3-482e-b9aa-f1b0b60f0d28",
			"name": "Hacker News2"
		},
		{
			"parameters": {},
			"type": "n8n-nodes-base.manualTrigger",
			"typeVersion": 1,
			"position": [-320, 336],
			"id": "67e1134d-c712-4f91-85d0-8bedf577600c",
			"name": "When clicking ‘Test workflow’"
		},
		{
			"parameters": {
				"jsCode": "const result = [\n  'n8n',\n  'make',\n  'zappier',\n  'workato'\n].map(i => ({ json: {name: i}}))\n\nreturn result;"
			},
			"type": "n8n-nodes-base.code",
			"typeVersion": 2,
			"position": [-96, 320],
			"id": "5d7ccb8c-1556-42fb-a17d-18f54caba4a0",
			"name": "Code"
		},
		{
			"parameters": {
				"aggregate": "aggregateAllItemData",
				"options": {}
			},
			"type": "n8n-nodes-base.aggregate",
			"typeVersion": 1,
			"position": [496, 112],
			"id": "826ae2ff-6ec0-4461-8ee1-337735f00767",
			"name": "Aggregate2"
		},
		{
			"parameters": {
				"promptType": "define",
				"text": "=Search HackerNews for following: {{ $json.data.map(i => i.name).join(', ') }}",
				"options": {}
			},
			"type": "@n8n/n8n-nodes-langchain.agent",
			"typeVersion": 2.2,
			"position": [720, 112],
			"id": "6a5b7f81-728c-48f6-807d-c271f61d19d0",
			"name": "AI Agent5"
		},
		{
			"parameters": {
				"model": {
					"__rl": true,
					"value": "gpt-4.1-nano",
					"mode": "list",
					"cachedResultName": "gpt-4.1-nano"
				},
				"options": {}
			},
			"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
			"typeVersion": 1.2,
			"position": [672, 288],
			"id": "cf585783-1e0f-4432-9bd6-7359e0ee0999",
			"name": "OpenAI Chat Model5",
			"credentials": {
				"openAiApi": {
					"id": "Zak03cqeLUOsgkFI",
					"name": "OpenAi account"
				}
			}
		},
		{
			"parameters": {
				"resource": "all",
				"limit": 1,
				"additionalFields": {
					"keyword": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Keyword', ``, 'string') }}"
				}
			},
			"type": "n8n-nodes-base.hackerNewsTool",
			"typeVersion": 1,
			"position": [944, 288],
			"id": "bb2d2150-c0f6-45a2-bf82-75bd99b3f2ed",
			"name": "Hacker News4"
		},
		{
			"parameters": {
				"batchSize": 2,
				"options": {}
			},
			"type": "n8n-nodes-base.splitInBatches",
			"typeVersion": 3,
			"position": [272, 80],
			"id": "85e03712-3d29-4ed3-a236-d50f77cc63a3",
			"name": "Loop Over Items1"
		},
		{
			"parameters": {
				"aggregate": "aggregateAllItemData",
				"options": {}
			},
			"type": "n8n-nodes-base.aggregate",
			"typeVersion": 1,
			"position": [496, 544],
			"id": "5b1944f3-aae9-4ce9-b059-ea98ad6a513f",
			"name": "Aggregate3"
		},
		{
			"parameters": {
				"promptType": "define",
				"text": "=Search HackerNews for following: {{ $json.data.map(i => i.name).join(', ') }}",
				"options": {}
			},
			"type": "@n8n/n8n-nodes-langchain.agent",
			"typeVersion": 2.2,
			"position": [720, 544],
			"id": "83c78be6-d2eb-479e-8210-c20b5b1947ec",
			"name": "AI Agent7"
		},
		{
			"parameters": {
				"batchSize": 2,
				"options": {}
			},
			"type": "n8n-nodes-base.splitInBatches",
			"typeVersion": 3,
			"position": [272, 512],
			"id": "d2038bcd-d60a-4280-acd9-dfe2aa57c7e8",
			"name": "Loop Over Items3"
		},
		{
			"parameters": {
				"model": {
					"__rl": true,
					"value": "gpt-4.1-nano",
					"mode": "list",
					"cachedResultName": "gpt-4.1-nano"
				},
				"options": {}
			},
			"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
			"typeVersion": 1.2,
			"position": [656, 800],
			"id": "ee951b3d-f7f8-4b28-99d2-2d8e45406117",
			"name": "OpenAI Chat Model7",
			"credentials": {
				"openAiApi": {
					"id": "Zak03cqeLUOsgkFI",
					"name": "OpenAi account"
				}
			}
		},
		{
			"parameters": {
				"description": "Call this tool to search Hacker News",
				"workflowId": {
					"__rl": true,
					"value": "={{ $workflow.id }}",
					"mode": "id"
				},
				"workflowInputs": {
					"mappingMode": "defineBelow",
					"value": {
						"query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}"
					},
					"matchingColumns": ["query"],
					"schema": [
						{
							"id": "query",
							"displayName": "query",
							"required": false,
							"defaultMatch": false,
							"display": true,
							"canBeUsedToMatch": true,
							"type": "string",
							"removed": false
						}
					],
					"attemptToConvertTypes": false,
					"convertFieldsToString": false
				}
			},
			"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
			"typeVersion": 2.2,
			"position": [928, 800],
			"id": "8679c23b-43ef-4d80-b18f-963b8d2e0cbf",
			"name": "Call n8n Workflow Tool3"
		}
	],
	"pinData": {},
	"connections": {
		"When Executed by Another Workflow": {
			"main": [
				[
					{
						"node": "Hacker News2",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"When clicking ‘Test workflow’": {
			"main": [
				[
					{
						"node": "Code",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"Code": {
			"main": [
				[
					{
						"node": "Loop Over Items1",
						"type": "main",
						"index": 0
					},
					{
						"node": "Loop Over Items3",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"Aggregate2": {
			"main": [
				[
					{
						"node": "AI Agent5",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"AI Agent5": {
			"main": [
				[
					{
						"node": "Loop Over Items1",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"OpenAI Chat Model5": {
			"ai_languageModel": [
				[
					{
						"node": "AI Agent5",
						"type": "ai_languageModel",
						"index": 0
					}
				]
			]
		},
		"Hacker News4": {
			"ai_tool": [
				[
					{
						"node": "AI Agent5",
						"type": "ai_tool",
						"index": 0
					}
				]
			]
		},
		"Loop Over Items1": {
			"main": [
				[],
				[
					{
						"node": "Aggregate2",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"Aggregate3": {
			"main": [
				[
					{
						"node": "AI Agent7",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"AI Agent7": {
			"main": [
				[
					{
						"node": "Loop Over Items3",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"Loop Over Items3": {
			"main": [
				[],
				[
					{
						"node": "Aggregate3",
						"type": "main",
						"index": 0
					}
				]
			]
		},
		"OpenAI Chat Model7": {
			"ai_languageModel": [
				[
					{
						"node": "AI Agent7",
						"type": "ai_languageModel",
						"index": 0
					}
				]
			]
		},
		"Call n8n Workflow Tool3": {
			"ai_tool": [
				[
					{
						"node": "AI Agent7",
						"type": "ai_tool",
						"index": 0
					}
				]
			]
		}
	},
	"settings": null,
	"versionId": null,
	"meta": null,
	"tags": []
}
