Files
n8nworkflows.xyz/workflows/Loop Over Items — Beginner Example-7152/loop_over_items_beginner_example.json
nusquama f91b107023 creation
2025-11-12 16:17:39 +01:00

1 line
4.8 KiB
JSON
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"meta":{"instanceId":"efb474b59b0341d7791932605bd9ff04a6c7ed9941fdd53dc4a2e4b99a6f9439","templateCredsSetupCompleted":true},"nodes":[{"id":"bdd87769-9f12-4bd1-8dd9-1b90ec218209","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[600,-540],"parameters":{"options":{}},"typeVersion":3},{"id":"6209e2d5-4c6e-4239-8275-a8d3411cb6f9","name":"OpenAI Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[820,-120],"parameters":{"model":{"__rl":true,"mode":"list","value":"gpt-4o-mini"},"options":{}},"credentials":{"openAiApi":{"id":"ghJTvay8CvwXDsXz","name":"OpenAi account"}},"typeVersion":1.2},{"id":"8e3ecba2-5a55-40bc-ba3a-b3cb0d581630","name":"Tool: Inject Creativity","type":"@n8n/n8n-nodes-langchain.toolThink","position":[1060,-100],"parameters":{},"typeVersion":1},{"id":"a73bc4ac-78f7-4410-ac1a-0952415dbe9f","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[-740,-900],"parameters":{"width":2260,"height":1140,"content":"## 📬 Need Help or Want to Customize This?\n📧 [robert@ynteractive.com](mailto:robert@ynteractive.com) \n🔗 [LinkedIn](https://www.linkedin.com/in/robert-breen-29429625/)\n\n\n## 🔧 Step-by-Step Setup\n\n### 1⃣ Run Workflow\n\n- **Node**: `Manual Trigger (Run Workflow)`\n- **Purpose**: Manually start the workflow for testing or learning.\n\n\n### 2⃣ Create Random Data\n\n- **Node**: `Create Random Data (Code)`\n- **What it does**: Simulates incoming data with multiple content ideas.\n\n\n### 3⃣ Loop Over Items\n\n- **Node**: `Loop Over Items (SplitInBatches)`\n- **Purpose**: Sends one record at a time to the next node.\n- **Why It Matters**: Loops in n8n are created using this node when you want to iterate over multiple items.\n\n\n### 4⃣ Create Captions with AI\n\n- **Node**: `Create Captions (LangChain Agent)`\n- **Prompt**: \n```text\nidea: {{ $json.idea }}\n```\n- **System Message**: \n```text\nYou are a helpful assistant creating captions for a LinkedIn post. Please create a LinkedIn caption for the idea.\n```\n- **Model**: GPT-4o Mini or GPT-3.5\n- **Credentials Required**:\n - **OpenAI Credential** \n - Go to: [OpenAI API Keys](https://platform.openai.com/account/api-keys)\n - Create a key and add it in n8n under credentials as “OpenAi account”\n\n\n### 5⃣ Inject Creativity (Optional)\n\n- **Node**: `Tool: Inject Creativity (LangChain Tool)`\n- **Purpose**: Demonstrates optional LangChain tools that can enhance or manipulate input/output.\n- **Why Its Cool**: A great way to show chaining tools to AI agents.\n\n\n\n\n\n"},"typeVersion":1},{"id":"a523d13f-653d-4a91-a672-b0bd5d558f27","name":"Run Workflow","type":"n8n-nodes-base.manualTrigger","position":[220,-680],"parameters":{},"typeVersion":1},{"id":"f0e1af9b-2785-47b1-a38c-3e108bff67f8","name":"Create Random Data","type":"n8n-nodes-base.code","position":[380,-540],"parameters":{"jsCode":"return [\n {\n json: {\n row_number: 2,\n id: 1,\n Date: '2025-07-30',\n idea: 'n8n rises to the top',\n caption: '',\n complete: ''\n }\n },\n {\n json: {\n row_number: 3,\n id: 2,\n Date: '2025-07-31',\n idea: 'n8n nodes',\n caption: '',\n complete: ''\n }\n },\n {\n json: {\n row_number: 4,\n id: 3,\n Date: '2025-08-01',\n idea: 'n8n use cases for marketing',\n caption: '',\n complete: ''\n }\n }\n];\n"},"typeVersion":2},{"id":"8891b681-a7cf-44c0-aff7-79e7774120d1","name":"Create Captions","type":"@n8n/n8n-nodes-langchain.agent","position":[860,-380],"parameters":{"text":"=idea: {{ $json.idea }}","options":{"systemMessage":"You are a helpful assistant creating captions for a linkedin post. Please create a linkedin caption for the idea. "},"promptType":"define"},"typeVersion":2},{"id":"fa53cf32-03de-4667-80bb-b28f8c3a16aa","name":"Output Table","type":"n8n-nodes-base.set","position":[960,-600],"parameters":{"options":{},"assignments":{"assignments":[{"id":"331d2ca1-da0d-41ec-ac82-abe78052b84c","name":"idea","type":"string","value":"={{ $('Create Random Data').item.json.idea }}"},{"id":"019369d9-ae99-4c29-b31d-013e29c4fdb6","name":"output","type":"string","value":"={{ $json.output }}"}]}},"typeVersion":3.4}],"pinData":{},"connections":{"Run Workflow":{"main":[[{"node":"Create Random Data","type":"main","index":0}]]},"Create Captions":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Loop Over Items":{"main":[[{"node":"Output Table","type":"main","index":0}],[{"node":"Create Captions","type":"main","index":0}]]},"OpenAI Chat Model":{"ai_languageModel":[[{"node":"Create Captions","type":"ai_languageModel","index":0}]]},"Create Random Data":{"main":[[{"node":"Loop Over Items","type":"main","index":0}]]},"Tool: Inject Creativity":{"ai_tool":[[{"node":"Create Captions","type":"ai_tool","index":0}]]}}}