This workflow corresponds to n8n.io template #5597 — we link there as the canonical source.
This workflow follows the Agent → OpenAI Chat recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "rdQbhY9lEyDizxvy",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Multi-Agent Feedback Loops",
"tags": [
{
"id": "o58aq7CrdbXQHYA0",
"name": "template",
"createdAt": "2025-06-14T10:20:41.387Z",
"updatedAt": "2025-06-14T10:20:41.387Z"
}
],
"nodes": [
{
"id": "74337855-c422-4186-9510-ce899d67e39f",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-1180,
240
],
"parameters": {
"text": "=Product: {{$json[\"productDescription\"]}}",
"options": {
"systemMessage": "You are a creative branding agent. Based on this product description, generate 3 distinct name + tagline options.\n\nReturn your output in this format:\n[\n { \"name\": \"Name1\", \"tagline\": \"Tagline1\" },\n { \"name\": \"Name2\", \"tagline\": \"Tagline2\" },\n { \"name\": \"Name3\", \"tagline\": \"Tagline3\" }\n]\n"
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "e056b2fa-3e6f-4fa7-b908-dba91d01ec61",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-780,
240
],
"parameters": {
"options": {
"reset": true
}
},
"typeVersion": 3
},
{
"id": "f7c4971f-1ea8-4448-ab73-35d945d76604",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
-360,
360
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "595ebd64-59de-470c-9827-24d204db58f9",
"operator": {
"type": "number",
"operation": "equals"
},
"leftValue": "={{ $json.turn }}",
"rightValue": 5
},
{
"id": "fb2ec186-4676-4e91-85b1-af7ce745b203",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.done }}",
"rightValue": "Yes"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "b8c57f43-6f23-4e05-81c0-6c1db0264f18",
"name": "Critic Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-120,
420
],
"parameters": {
"text": "=Ideas:\n{{JSON.stringify($('Edit Fields').item.json.ideas)}}",
"options": {
"systemMessage": "You are a critical branding analyst. For each name + tagline below, provide a short flaw summary and a suggestion for improvement."
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "cdcab121-8082-4295-aa7f-475bde50414e",
"name": "Refiner Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
320,
520
],
"parameters": {
"text": "=**Original Ideas:** {{ JSON.stringify($('Edit Fields').item.json.ideas) }}\n\n**Critics Feedback:** {{ $json.output }}",
"options": {
"systemMessage": "You are a refiner. Use the original ideas and the critic\u2019s feedback to create 3 improved name + tagline combinations.\n\nBe concise, clever, and impactful.\n\nReturn your output in this format:\n[\n { \"name\": \"Name1\", \"tagline\": \"Tagline1\" },\n { \"name\": \"Name2\", \"tagline\": \"Tagline2\" },\n { \"name\": \"Name3\", \"tagline\": \"Tagline3\" }\n]\n"
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "9a63dab8-269c-4073-bdf5-8661fcbfdc82",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"position": [
-560,
360
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "1c6c6fc2-96de-469a-b30f-7ffae52c9847",
"name": "ideas",
"type": "array",
"value": "={{ $json.output }}"
},
{
"id": "1a857aee-ae3f-4e81-a09c-a9e83edd9b98",
"name": "turn",
"type": "number",
"value": "={{ $json.turn || 1}}"
},
{
"id": "d310985b-59a3-44b8-aa5a-e77f2b352ae4",
"name": "done",
"type": "string",
"value": "={{ $json.done || \"No\"}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "cdf532b0-6dd9-43e6-a1b2-76edb177e9fa",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
1180,
880
],
"parameters": {
"jsCode": "const ideas = $json.output.ideas || [];\nconst currentTurn = $json.output.turn ?? 0;\nconst currentDone = $json.output.done || \"No\";\n\nconst nextTurn = currentTurn + 1;\n\nreturn [\n {\n json: {\n ideas,\n turn: nextTurn,\n done: currentDone\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "6d853089-99d1-4ee9-bd80-34ebcc2fd5a3",
"name": "Edit Fields1",
"type": "n8n-nodes-base.set",
"position": [
1400,
880
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "21a77915-3d73-450d-bc9c-f655471a3b56",
"name": "output",
"type": "array",
"value": "={{ $json.ideas }}"
},
{
"id": "6dee88ae-c3f3-464a-a3cc-179bd28b7c5e",
"name": "turn",
"type": "number",
"value": "={{ $json.turn }}"
},
{
"id": "2f2caa57-797c-4fa3-9126-da46777a2b63",
"name": "done",
"type": "string",
"value": "={{ $json.done }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "3702b8fc-61e2-4d01-aa10-0ddb5bff48c7",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-100,
800
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "17809998-4a9c-41d9-984e-c17cc24e7769",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
880,
820
],
"parameters": {
"jsonSchemaExample": "{\n\t\"ideas\": [\n { \"name\": \"EnterpriseMind\", \"tagline\": \"Harness AI to transform your business ideas into reality.\" },\n { \"name\": \"InnoLogix\", \"tagline\": \"Capture and evolve your entrepreneurial ideas with AI-powered journaling.\" },\n { \"name\": \"VentureScript\", \"tagline\": \"Document and accelerate your startup journey with intelligent AI journaling.\" }],\n \"done\": \"Yes\",\n \"turn\": 2\n}"
},
"typeVersion": 1.2
},
{
"id": "b47e29f2-bd26-4e9f-813f-2983b1841d33",
"name": "When clicking \u2018Execute workflow\u2019",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-1360,
240
],
"parameters": {},
"typeVersion": 1
},
{
"id": "7d996197-5542-4d89-8c58-ced050c7fffc",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1920,
120
],
"parameters": {
"color": 5,
"width": 3920,
"height": 1160,
"content": "# \u2699\ufe0f Setup Guide\n## This is a workflow for user's customization.\n### \ud83e\uddd1\u200d\ud83d\udcbb Author: [Sebastian/OptiLever](www.linkedin.com/in/sebastian-9ab9b9242)\n\n### \ud83d\ude80 Prerequisite:\n\n**1. Connect to Openai API account.**\n\n\n---\n\n### \ud83d\ude80 Steps to Connect:\n\n\n1. **Edit Fields Node Setup (Initial)**\n- Locate the **\"Edit Fields\"** node at the beginning of the workflow.\n- **Edit the following fields:**\n- Ensure the input field **\"ideas\"** is set as an array.\n- Add a field **\"turn\"** to track the number of loop iterations (default value: 1).\n- Add a field **\"done\"** to track if the evaluation is complete (default value: false).\n\n\n\n2. **Critic Agent Setup**\n- Configure the **\"Critic Agent\"** node to analyze the input and provide feedback.\n- Ensure the output is structured to include suggestions for improvements.\n\n\n\n3. **Refiner Agent Setup**\n- Configure the **\"Refiner Agent\"** node to use the original input and critic feedback.\n- Ensure the output is an improved version of the input (e.g., three improved names and taglines).\n\n\n\n4. **Evaluation Agent Setup**\n- Configure the **\"Evaluation Agent\"** node to rank the refined outputs.\n- Ensure the output includes a **\"done\"** field indicating if the result is satisfactory.\n\n\n\n5. **Edit Fields Node Setup (Final)**\n- Ensure the final **\"Edit Fields\"** node matches the structure of the initial input.\n- This ensures the loop can process the data correctly in each iteration.\n\n\n\n6. **If Node Setup**\n- Configure the **\"If\"** node to check if **\"turn\"** exceeds a threshold (e.g., 5) or if **\"done\"** is true.\n- If true, exit the loop and proceed to the next step in the workflow.\n\n\n\n7. **Optional: Additional AI Agents**\n- Add additional AI agents after the loop to further process the final output.\n\n\n---\n\n\n"
},
"typeVersion": 1
},
{
"id": "d64015c8-17f1-4fcc-a12f-f29d2ac0aa75",
"name": "Evaluation agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
700,
640
],
"parameters": {
"text": "=**Results To Examine:** {{ $json.output }}\n\n**Turns Through Loop:** {{ $('Edit Fields').item.json.turn }}",
"options": {
"systemMessage": "You are an evaluator. Rank the 3 improved name ideas and taglines. Recommend if the names and taglines are so awesome that it would make anyone want to purchase from this company, or further improvement is needed (Yes/No). Output a JSON that follows this format:\n{\n\t\"ideas\": [\n { \"name\": \"EnterpriseMind\", \"tagline\": \"Harness AI to transform your business ideas into reality.\" },\n { \"name\": \"InnoLogix\", \"tagline\": \"Capture and evolve your entrepreneurial ideas with AI-powered journaling.\" },\n { \"name\": \"VentureScript\", \"tagline\": \"Document and accelerate your startup journey with intelligent AI journaling.\" }],\n \"done\": \"Yes\",\n \"turn\": 2\n}"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "40c2c451-49fd-4266-94e1-3b66cabf6ebc",
"connections": {
"If": {
"main": [
[],
[
{
"node": "Critic Agent",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Critic Agent": {
"main": [
[
{
"node": "Refiner Agent",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Refiner Agent": {
"main": [
[
{
"node": "Evaluation agent",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Evaluation agent": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Critic Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Refiner Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Evaluation agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Evaluation agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"When clicking \u2018Execute workflow\u2019": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow is designed for users who want to implement iterative AI-powered content improvement processes. It's ideal for content creators, marketers, product managers, and anyone who needs to refine ideas through multiple rounds of critique and enhancement until they meet…
Source: https://n8n.io/workflows/5597/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
🎯 Create viral TikToks, Shorts, Reels, podcasts, and ASMR videos in minutes — all on autopilot.
Generate AI viral videos with NanoBanana & VEO3, shared on socials via Blotato 2. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 94 nodes.
RAG CHATBOT Main. Uses telegram, telegramTrigger, lmChatOpenAi, n8n-nodes-mcp. Event-driven trigger; 87 nodes.
The best content automation template in the market is now even better—with “deep research” on time-sensitive topics\! Unlike most n8n content automation templates that are mainly for “demo purposes,”
Digital marketers, content creators, social media managers, and businesses who want to use AI marketing automation for YouTube Shorts without spending hours on production. This AI workflow helps anyon