인터랙티브 실습 튜토리얼을 통해 코드 노드(JavaScript) 기본 지식 배우기
중급
이것은Miscellaneous분야의자동화 워크플로우로, 12개의 노드를 포함합니다.주로 Set, Code, SplitOut, ManualTrigger 등의 노드를 사용하며. 교환형 실습 튜토리얼을 통해 코드 노드(JavaScript) 기본 지식을 배우기
사전 요구사항
- •특별한 사전 요구사항 없이 가져와 바로 사용 가능합니다
사용된 노드 (12)
카테고리
워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
"meta": {
"instanceId": "e409ea34548a2afe2dffba31130cd1cf2e98ebe2afaeed2a63caf2a0582d1da0"
},
"nodes": [
{
"id": "e36b580a-9314-453c-88d6-7ffb948e79a8",
"name": "1. 샘플 데이터",
"type": "n8n-nodes-base.set",
"position": [
500,
480
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "38ce3db6-ce1d-4091-9645-39e674ad1782",
"name": "users",
"type": "array",
"value": "=[{\"firstName\":\"Alice\",\"lastName\":\"Smith\",\"birthDate\":\"1990-05-15\"},{\"firstName\":\"Bob\",\"lastName\":\"Jones\",\"birthDate\":\"1985-11-22\"},{\"firstName\":\"Charlie\",\"lastName\":\"Brown\",\"birthDate\":\"2001-02-10\"}, {\"firstName\":\"Alex\",\"lastName\":\"Garcia\",\"birthDate\":\"1995-07-30\"}]"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "d77a1d9a-376a-451c-9fc3-174a60fb787a",
"name": "2. 사용자 분리하기",
"type": "n8n-nodes-base.splitOut",
"position": [
720,
480
],
"parameters": {
"options": {},
"fieldToSplitOut": "users"
},
"typeVersion": 1
},
{
"id": "39ab2c6f-11ce-4e1e-a6c7-327d758f6d0c",
"name": "3. 각 사용자 처리",
"type": "n8n-nodes-base.code",
"position": [
1040,
480
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "// This code runs for EACH user individually.\n\n// 1. Get the data for the current item\nconst user = $input.item.json;\n\n// 2. Perform operations\nconst fullName = `${user.firstName} ${user.lastName}`;\n\nconst birthDate = new Date(user.birthDate);\nconst ageDiffMs = Date.now() - birthDate.getTime();\nconst ageDate = new Date(ageDiffMs);\nconst age = Math.abs(ageDate.getUTCFullYear() - 1970);\n\nconsole.log(`Processing user: ${fullName}, Age: ${age}`);\n\n// 3. Return the new data, keeping the original fields\nreturn {\n ...user, // This keeps the original data (firstName, lastName, etc.)\n fullName: fullName,\n age: age\n};"
},
"typeVersion": 2
},
{
"id": "9f4aa08e-f15f-4215-843c-87997e6d6cff",
"name": "5. 평균 나이 계산",
"type": "n8n-nodes-base.code",
"position": [
1840,
480
],
"parameters": {
"jsCode": "// This code runs only ONCE for ALL users.\n\n// 1. Get all items from the previous node\nconst allUsers = $items();\n\n// 2. Perform an aggregation\nconst totalAge = allUsers.reduce((sum, item) => {\n return sum + item.json.age;\n}, 0);\n\nconst userCount = allUsers.length;\nconst averageAge = totalAge / userCount;\n\nconsole.log(`Calculated average age for ${userCount} users.`);\n\n// 3. Return a single new item with the result\nreturn [\n {\n json: {\n totalUsers: userCount,\n averageAge: parseFloat(averageAge.toFixed(2)) // Format to 2 decimal places\n }\n }\n];"
},
"typeVersion": 2
},
{
"id": "2e7f0710-0b4a-450e-8e87-591c5324f5c7",
"name": "4. 외부 데이터 가져오기 (고급)",
"type": "n8n-nodes-base.code",
"position": [
1440,
480
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "// ADVANCED: This code calls an external API for each user.\n\n// 1. Get the data for the current item\nconst user = $input.item.json;\n\n// 2. Use a helper function to make an HTTP request\n// We'll use a free API to guess the gender based on the first name.\nconst url = `https://api.genderize.io?name=${user.firstName}`;\n\nconsole.log(`Fetching external data for ${user.firstName} from ${url}`)\n\n// this.helpers.httpRequest is a powerful built-in function.\n// We use 'await' because it's an asynchronous operation.\nconst response = await this.helpers.httpRequest({ url: url, json: true });\n\n// 3. Return the original data merged with the new API data\nreturn {\n ...user, // Keep all existing data (fullName, age, etc.)\n gender: response.gender,\n genderProbability: response.probability\n};"
},
"typeVersion": 2
},
{
"id": "809e91c4-02b6-4d12-b8f0-e9cd96d92c24",
"name": "스티키 노트",
"type": "n8n-nodes-base.stickyNote",
"position": [
440,
240
],
"parameters": {
"color": 5,
"width": 440,
"height": 420,
"content": "#### ▶️ STARTING POINT: Sample Data\n\nThese nodes prepare our data for the tutorial.\n\n1. **`1. Sample Data`**: Creates a list of users. Feel free to edit the values here to experiment!\n2. **`2. Split Out Users`**: Splits the list into multiple items, one for each user. This is necessary so the next Code nodes can process them one by one."
},
"typeVersion": 1
},
{
"id": "bc8ec047-8595-4a07-8422-09779f8490c0",
"name": "스티키 노트1",
"type": "n8n-nodes-base.stickyNote",
"position": [
900,
80
],
"parameters": {
"color": 7,
"width": 380,
"height": 580,
"content": "#### ⚙️ LESSON 1: Processing Each Item\n\nThis node is in **\"Run Once for Each Item\"** mode. It executes once for every user.\n\n**Goal:** Enrich each user's data.\n\n**Key Concepts:**\n* `$input.item.json`: Accesses the data of the *current* item being processed.\n* `return { ... }`: Returns an object that becomes the new output for the item. The `...user` trick keeps the original data.\n\n\nRun the workflow and check this node's output: you'll see multiple items, each with a new `fullName` and `age`."
},
"typeVersion": 1
},
{
"id": "acd0b48a-ca88-4dae-ab19-b91db5050e8b",
"name": "스티키 노트2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1300,
60
],
"parameters": {
"color": 6,
"width": 380,
"height": 600,
"content": "#### 🚀 ADVANCED LESSON 2: Using Helpers\n\nThis node also runs for each item, but demonstrates a powerful, advanced feature.\n\n**Goal:** Enrich data by calling an external API from code.\n\n**Key Concepts:**\n* `this.helpers.httpRequest`: A built-in function to make API calls directly. This is great for dynamic URLs or when you need to add logic before or after the call.\n* `await`: We use this because making an API call is an *asynchronous* operation.\n\n\nCheck the output: each user now has `gender` data fetched from the web!"
},
"typeVersion": 1
},
{
"id": "da000098-d03f-40a9-b017-fab8223a6afc",
"name": "스티키 노트3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1700,
80
],
"parameters": {
"color": 7,
"width": 380,
"height": 580,
"content": "#### ⚙️ LESSON 3: Processing All Items at Once\n\nThis node is in **\"Run Once for All Items\"** mode. It runs only once and sees all items at the same time.\n\n**Goal:** Aggregate data to create a summary.\n\n**Key Concepts:**\n* `$items()`: Returns an **array** of all items from the previous node.\n* `return [ { json: { ... } } ]`: Returns an array containing a single new item with the final result.\n\n\nCheck this node's output: there is only one item containing the total user count and their average age."
},
"typeVersion": 1
},
{
"id": "5c84ce9f-32d0-4222-9b1a-3887677bdabe",
"name": "6. 바이너리 파일 생성하기 (전문가)",
"type": "n8n-nodes-base.code",
"position": [
2240,
480
],
"parameters": {
"jsCode": "// LESSON 4 (EXPERT): Creating a binary file.\n\n// This node runs only ONCE for ALL items.\n\n// 1. Get all items from the previous node\nconst allUsers = $(\"4. Fetch External Data (Advanced)\").all();\n\n// 2. Create a CSV string from the data\nlet csvContent = \"FullName,Age,GenderGuess,ProcessedBy\\n\"; // CSV Header\n\nfor (const item of allUsers) {\n const user = item.json;\n const row = `\"${user.fullName}\",${user.age},${user.gender},n8n`;\n csvContent += row + \"\\n\";\n}\n\n// 3. Use a helper to create a binary file from the string\nconst binaryData = await this.helpers.prepareBinaryData(Buffer.from(csvContent), 'user_report.csv');\n\n// 4. Return a new item containing the binary data\nreturn [\n {\n json: {\n reportGenerated: new Date().toISOString(),\n userCount: allUsers.length\n },\n binary: {\n 'report': binaryData\n }\n }\n];"
},
"typeVersion": 2
},
{
"id": "498b1bf2-1ced-4343-b459-9b6226fa8c46",
"name": "스티키 노트4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2100,
80
],
"parameters": {
"color": 3,
"width": 380,
"height": 580,
"content": "#### 📄 EXPERT LESSON 4: Creating Files\n\n**Goal:** Aggregate all items and generate a binary file (like a CSV in that case).\n**Mode:** `Run Once for All Items`\n\n**Key Concepts:**\n* `$(\"4. Fetch External Data (Advanced)\").all()`: Gets an array of ALL items from the 4th step.\n* `this.helpers.prepareBinaryData`: Converts raw data (like a text string) into a proper binary file that n8n can use.\n* `Buffer`: A standard way to handle binary data in JavaScript."
},
"typeVersion": 1
},
{
"id": "c97edb6b-77ac-48ea-8e00-507770cc6373",
"name": "튜토리얼 시작",
"type": "n8n-nodes-base.manualTrigger",
"position": [
220,
480
],
"parameters": {},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"e36b580a-9314-453c-88d6-7ffb948e79a8": {
"main": [
[
{
"node": "d77a1d9a-376a-451c-9fc3-174a60fb787a",
"type": "main",
"index": 0
}
]
]
},
"c97edb6b-77ac-48ea-8e00-507770cc6373": {
"main": [
[
{
"node": "e36b580a-9314-453c-88d6-7ffb948e79a8",
"type": "main",
"index": 0
}
]
]
},
"d77a1d9a-376a-451c-9fc3-174a60fb787a": {
"main": [
[
{
"node": "39ab2c6f-11ce-4e1e-a6c7-327d758f6d0c",
"type": "main",
"index": 0
}
]
]
},
"39ab2c6f-11ce-4e1e-a6c7-327d758f6d0c": {
"main": [
[
{
"node": "2e7f0710-0b4a-450e-8e87-591c5324f5c7",
"type": "main",
"index": 0
}
]
]
},
"9f4aa08e-f15f-4215-843c-87997e6d6cff": {
"main": [
[
{
"node": "5c84ce9f-32d0-4222-9b1a-3887677bdabe",
"type": "main",
"index": 0
}
]
]
},
"2e7f0710-0b4a-450e-8e87-591c5324f5c7": {
"main": [
[
{
"node": "9f4aa08e-f15f-4215-843c-87997e6d6cff",
"type": "main",
"index": 0
}
]
]
}
}
}자주 묻는 질문
이 워크플로우를 어떻게 사용하나요?
위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.
이 워크플로우는 어떤 시나리오에 적합한가요?
중급 - 기타
유료인가요?
이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.
관련 워크플로우 추천
🎓 병행 처리를 사용하여 속도가 중요한 작업 흐름 최적화(확산-집합)
🎓 병렬 처리(확산/집합)를 사용하여 속도 중요한 작업 흐름 최적화
If
Set
Code
+
If
Set
Code
34 노드Lucas Peyrin
엔지니어링
대기 노드를 포함한 장기 실행 워크플로우 상태 관리 시스템
대기 노드를 포함한 장기 실행 워크플로우 상태 관리 시스템
If
Set
Code
+
If
Set
Code
42 노드Lucas Peyrin
엔지니어링
🧑🎓 상호작용 도전과 즉시 피드백을 통해 JSON 기술 테스트
🧑🎓 상호작용적인 도전과 즉시 피드백을 통해 JSON 기술을 테스트하세요
If
Set
Html
+
If
Set
Html
61 노드Lucas Peyrin
기타
GPT-5 nano 및 Yoast SEO를 사용한 WordPress SEO 최적화 자동화
GPT-5 nano 및 Yoast SEO를 사용한 WordPress SEO 최적화 자동화
Set
Code
Gmail
+
Set
Code
Gmail
35 노드Oriol Seguí
기타
Gemini RAG 파이프라인을 사용하여 문서 전문가 채팅 로봇을 구축
사용법 Gemini RAG 파이프라인을 사용하여 문서 전문가 채팅 로봇 구축
Set
Html
Filter
+
Set
Html
Filter
48 노드Lucas Peyrin
내부 위키
AI 분석을 사용하여 바이러스적 YouTube 비디오를 검출하고 이메일 보고서를 전송
AI를 사용하여 바이러스성 YouTube 비디오를 검출하고 이메일 보고서를 전송
Set
Code
Sort
+
Set
Code
Sort
26 노드gclbck
기타
워크플로우 정보
난이도
중급
노드 수12
카테고리1
노드 유형5
저자
Lucas Peyrin
@lucaspeyrinInnovative builder with a passion for crafting automation solutions that solve real-world challenges. From streamlining workflows to driving efficiency, my work empowers teams and individuals to achieve more with less effort. Experienced in developing scalable tools and strategies that deliver results with n8n, supabase and cline.
외부 링크
n8n.io에서 보기 →
이 워크플로우 공유