콘텐츠로 이동
📣 인포그랩에서 OpenAI 기술 기반으로 자체 개발한 자동화 번역 프로그램을 통해 n8n 공식 문서의 한글판을 국내 최초로 제공합니다.

워크플로우 2: 보고서 생성#

이 워크플로우에서는 다양한 출처의 데이터를 병합하고, 바이너리 데이터를 변환하며, 파일을 생성하고, 이에 대한 알림을 전송합니다. 최종 워크플로우는 다음과 같아야 합니다:

데이터 집계 및 파일 생성용 워크플로우 2
데이터 집계 및 파일 생성용 워크플로우 2

작업을 더 쉽게 하기 위해, 워크플로우를 세 부분으로 나눕니다.

1부: 다양한 출처의 데이터 가져오기#

워크플로우의 첫 번째 부분은 다섯 개의 노드로 구성됩니다:

워크플로우 1: 다양한 출처의 데이터 가져오기
워크플로우 1: 다양한 출처의 데이터 가져오기
  1. HTTP Request node를 사용하여 회사 데이터를 저장하는 API 엔드포인트에서 데이터를 가져옵니다. 다음 노드 매개변수를 구성합니다:

    • Method: Get
    • URL: 이 과정에 등록했을 때 이메일로 받은 Dataset URL
    • Authentication: Generic Credential Type
      • Generic Auth Type: Header Auth
      • Credentials for Header Auth: 이 과정에 등록했을 때 이메일로 받은 Header Auth 이름과 Header Auth 값
    • Send Headers: true로 설정
      • Specify Headers: Using Fields Below 선택
      • Name: unique_id
      • Value: 이 과정에 등록했을 때 이메일로 받은 고유 ID
  2. Airtable node를 사용하여 customers 테이블(여기서 regionsubregion 필드를 업데이트했습니다)에서 데이터를 나열합니다.

  3. Merge node를 사용하여 Airtable과 HTTP Request 노드에서 customerID의 입력 필드를 기준으로 데이터를 병합합니다.
  4. Sort node를 사용하여 orderPrice를 기준으로 데이터를 내림차순으로 정렬합니다.

퀴즈 질문

  • 고객 1에게 배정된 직원의 이름은 무엇인가요?
  • 고객 2의 주문 상태는 무엇인가요?
  • 가장 높은 주문 가격은 얼마인가요?

2부: 지역 판매를 위한 파일 생성#

워크플로우의 두 번째 부분은 네 개의 노드로 구성됩니다:

워크플로우 2: 지역 판매를 위한 파일 생성
워크플로우 2: 지역 판매를 위한 파일 생성
  1. If node를 사용하여 Americas 지역의 주문만 표시합니다.
  2. Convert to File를 사용하여 들어오는 데이터를 JSON에서 바이너리 형식으로 변환합니다. 각 항목을 별도의 파일로 변환합니다. (보고서의 이름을 orderID에 기반하여 정할 수 있다면 보너스 점수를 드립니다!)
  3. Gmail node (또는 다른 이메일 노드)를 사용하여 귀하가 접근할 수 있는 주소로 파일을 이메일로 전송합니다. 데이터 속성을 포함한 첨부파일을 추가해야 합니다.
  4. Discord node를 사용하여 n8n Discord 채널 #course-level-two에 메시지를 보냅니다. 노드에서 다음 매개변수를 구성합니다:
    • Webhook URL: 이 과정에 등록했을 때 이메일로 받은 Discord URL.
    • Text: "나는 ID {label ID} 레이블과 함께 이메일로 파일을 보냈다. 나의 ID: " 후에 등록했을 때 이메일로 받은 고유 ID가 옵니다.
      중괄호 {} 안의 텍스트는 노드의 데이터에서 참조한 expressions로 대체해야 합니다.

퀴즈 질문

  • Americas 지역에 배정된 주문은 몇 건인가요?
  • Americas 지역의 주문 총 가격은 얼마인가요?
  • Write Binary File node가 반환하는 항목 수는 얼마인가요?

Part 3: 총 판매를 위한 파일 생성#

워크플로의 세 번째 부분은 다섯 개의 노드로 구성됩니다:

Workflow 3: Generating files for total sales
워크플로 3: 총 판매를 위한 파일 생성
  1. Loop Over Items node를 사용하여 Item Lists 노드의 데이터를 5개 배치로 나눕니다.
  2. Set node를 사용하여 이전 노드의 표현식을 참조하여 네 가지 값을 설정합니다: customerEmail, customerRegion, customerSince, 및 orderPrice.
  3. Date & Time node를 사용하여 customerSince 필드의 날짜 형식을 MM/DD/YYYY 형식으로 변경합니다.
    • Include Input Fields 옵션을 설정하여 모든 데이터를 함께 유지합니다.
  4. Convert to File node를 사용하여 파일 이름을 표현식으로 설정된 CSV 스프레드시트를 생성합니다: {{$runIndex > 0 ? 'file_low_orders':'file_high_orders'}}.
  5. Discord node를 사용하여 n8n Discord 채널 #course-level-two에 메시지를 보냅니다. 노드에서 다음 매개변수를 구성합니다:
    • Webhook URL: 이 과정에 등록할 때 이메일로 받은 Discord URL입니다.
    • Text: "스프레드시트를 생성했습니다 {file name}. 내 ID:"는 이 과정에 등록할 때 이메일로 보낸 고유 ID입니다.
      {file name}을 이전 Convert to File node의 데이터를 참조하는 표현식으로 교체해야 합니다.

퀴즈 질문

  • 첫 번째 항목 배치의 최소 주문 가격은 얼마입니까?
  • 고객 7의 서식이 지정된 날짜는 무엇입니까?
  • Convert to File node는 몇 개의 항목을 반환합니까?
해결책을 보여주세요

노드의 구성을 확인하려면 아래의 JSON 워크플로 코드 를 복사하여 Editor UI에 붙여넣기 하십시오:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
{
"meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "cb484ba7b742928a2048bf8829668bed5b5ad9787579adea888f05980292a4a7"
},
"nodes": [
    {
    "parameters": {
        "sendTo": "bart@n8n.io",
        "subject": "Your TPS Reports",
        "emailType": "text",
        "message": "TPS 보고서를 첨부했습니다.",
        "options": {
        "attachmentsUi": {
            "attachmentsBinary": [
            {}
            ]
        }
        }
    },
    "id": "d889eb42-8b34-4718-b961-38c8e7839ea6",
    "name": "Gmail",
    "type": "n8n-nodes-base.gmail",
    "typeVersion": 2.1,
    "position": [
        2100,
        500
    ],
    "credentials": {
        "gmailOAuth2": {
        "id": "HFesCcFcn1NW81yu",
        "name": "Gmail 계정 7"
        }
    }
    },
    {
    "parameters": {},
    "id": "c0236456-40be-4f8f-a730-e56cb62b7b5c",
    "name": "When clicking \"Test workflow\"",
    "type": "n8n-nodes-base.manualTrigger",
    "typeVersion": 1,
    "position": [
        780,
        600
    ]
    },
    {
    "parameters": {
        "url": "https://internal.users.n8n.cloud/webhook/level2-erp",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
        "parameters": [
            {
            "name": "unique_id",
            "value": "recFIcD6UlSyxaVMQ"
            }
        ]
        },
        "options": {}
    },
    "id": "cc106fa0-6630-4c84-aea4-a4c7a3c149e9",
    "name": "HTTP Request",
    "type": "n8n-nodes-base.httpRequest",
    "typeVersion": 4.1,
    "position": [
        1000,
        500
    ],
    "credentials": {
        "httpHeaderAuth": {
        "id": "qeHdJdqqqaTC69cm",
        "name": "Course L2 Credentials"
        }
    }
    },
    {
    "parameters": {
        "operation": "search",
        "base": {
        "__rl": true,
        "value": "apprtKkVasbQDbFa1",
        "mode": "list",
        "cachedResultName": "All your base",
        "cachedResultUrl": "https://airtable.com/apprtKkVasbQDbFa1"
        },
        "table": {
        "__rl": true,
        "value": "tblInZ7jeNdlUOvxZ",
        "mode": "list",
        "cachedResultName": "Course L2, Workflow 1",
        "cachedResultUrl": "https://airtable.com/apprtKkVasbQDbFa1/tblInZ7jeNdlUOvxZ"
        },
        "options": {}
    },
    "id": "e5ae1927-b531-401c-9cb2-ecf1f2836ba6",
    "name": "Airtable",
    "type": "n8n-nodes-base.airtable",
    "typeVersion": 2,
    "position": [
        1000,
        700
    ],
    "credentials": {
        "airtableTokenApi": {
        "id": "MIplo6lY3AEsdf7L",
        "name": "Airtable 개인 액세스 토큰 계정 4"
        }
    }
    },
    {
    "parameters": {
        "mode": "combine",
        "mergeByFields": {
        "values": [
            {
            "field1": "customerID",
            "field2": "customerID"
            }
        ]
        },
        "options": {}
    },
    "id": "1cddc984-7fca-45e0-83b8-0c502cb4c78c",
    "name": "Merge",
    "type": "n8n-nodes-base.merge",
    "typeVersion": 2.1,
    "position": [
        1220,
        600
    ]
    },
    {
    "parameters": {
        "sortFieldsUi": {
        "sortField": [
            {
            "fieldName": "orderPrice",
            "order": "descending"
            }
        ]
        },
        "options": {}
    },
    "id": "2f55af2e-f69b-4f61-a9e5-c7eefaad93ba",
    "name": "Sort",
    "type": "n8n-nodes-base.sort",
    "typeVersion": 1,
    "position": [
        1440,
        600
    ]
    },
    {
    "parameters": {
        "conditions": {
        "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
        },
        "conditions": [
            {
            "id": "d3afe65c-7c80-4caa-9d1c-33c62fbc2197",
            "leftValue": "={{ $json.region }}",
            "rightValue": "Americas",
            "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
            }
            }
        ],
        "combinator": "and"
        },
        "options": {}
    },
    "id": "2ed874a9-5bcf-4cc9-9b52-ea503a562892",
    "name": "If",
    "type": "n8n-nodes-base.if",
    "typeVersion": 2,
    "position": [
        1660,
        500
    ]
    },
    {
    "parameters": {
        "operation": "toJson",
        "mode": "each",
        "options": {
        "fileName": "=report_orderID_{{ $('If').item.json.orderID }}.json"
        }
    },
    "id": "d93b4429-2200-4a84-8505-16266fedfccd",
    "name": "Convert to File",
    "type": "n8n-nodes-base.convertToFile",
    "typeVersion": 1.1,
    "position": [
        1880,
        500
    ]
    },
    {
    "parameters": {
        "authentication": "webhook",
        "content": "이메일을 사용하여 ID 레이블을 포함한 파일을 보냈고 이진 파일 {file name}을 작성했습니다. 내 ID: 123",
        "options": {}
    },
    "id": "26f43f2c-1422-40de-9f40-dd2d80926b1c",
    "name": "Discord",
    "type": "n8n-nodes-base.discord",
    "typeVersion": 2,
    "position": [
        2320,
        500
    ],
    "credentials": {
        "discordWebhookApi": {
        "id": "WEBrtPdoLrhlDYKr",
        "name": "L2 과정 Discord Webhook 계정"
        }
    }
    },
    {
    "parameters": {
        "batchSize": 5,
        "options": {}
    },
    "id": "0fa1fbf6-fe77-4044-a445-c49a1db37dec",
    "name": "Loop Over Items",
    "type": "n8n-nodes-base.splitInBatches",
    "typeVersion": 3,
    "position": [
        1660,
        700
    ]
    },
    {
    "parameters": {
        "assignments": {
        "assignments": [
            {
            "id": "ce839b80-c50d-48f5-9a24-bb2df6fdd2ff",
            "name": "customerEmail",
            "value": "={{ $json.customerEmail }}",
            "type": "string"
            },
            {
            "id": "0c613366-3808-45a2-89cc-b34c7b9f3fb7",
            "name": "region",
            "value": "={{ $json.region }}",
            "type": "string"
            },
            {
            "id": "0f19a88c-deb0-4119-8965-06ed62a840b2",
            "name": "customerSince",
            "value": "={{ $json.customerSince }}",
            "type": "string"
            },
            {
            "id": "a7e890d6-86af-4839-b5df-d2a4efe923f7",
            "name": "orderPrice",
            "value": "={{ $json.orderPrice }}",
            "type": "number"
            }
        ]
        },
        "options": {}
    },
    "id": "09b8584c-4ead-4007-a6cd-edaa4669a757",
    "name": "Edit Fields",
    "type": "n8n-nodes-base.set",
    "typeVersion": 3.3,
    "position": [
        1880,
        700
    ]
    },
    {
    "parameters": {
        "operation": "formatDate",
        "date": "={{ $json.customerSince }}",
        "options": {
        "includeInputFields": true
        }
    },
    "id": "c96fae90-e080-48dd-9bff-3e4506aafb86",
    "name": "Date & Time",
    "type": "n8n-nodes-base.dateTime",
    "typeVersion": 2,
    "position": [
        2100,
        700
    ]
    },
    {
    "parameters": {
        "options": {
        "fileName": "={{$runIndex > 0 ? 'file_low_orders':'file_high_orders'}}"
        }
    },
    "id": "43dc8634-2f16-442b-a754-89f47c51c591",
    "name": "Convert to File1",
    "type": "n8n-nodes-base.convertToFile",
    "typeVersion": 1.1,
    "position": [
        2320,
        700
    ]
    },
    {
    "parameters": {
        "authentication": "webhook",
        "content": "스프레드시트를 생성했습니다 {file name}. 내 ID: 123",
        "options": {}
    },
    "id": "05da1c22-d1f6-4ea6-9102-f74f9ae2e9d3",
    "name": "Discord1",
    "type": "n8n-nodes-base.discord",
    "typeVersion": 2,
    "position": [
        2540,
        700
    ],
    "credentials": {
        "discordWebhookApi": {
        "id": "WEBrtPdoLrhlDYKr",
        "name": "L2 과정 Discord Webhook 계정"
        }
    }
    }
],
"connections": {
    "Gmail": {
    "main": [
        [
        {
            "node": "Discord",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "When clicking \"Test workflow\"": {
    "main": [
        [
        {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
        },
        {
            "node": "Airtable",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "HTTP Request": {
    "main": [
        [
        {
            "node": "Merge",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Airtable": {
    "main": [
        [
        {
            "node": "Merge",
            "type": "main",
            "index": 1
        }
        ]
    ]
    },
    "Merge": {
    "main": [
        [
        {
            "node": "Sort",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Sort": {
    "main": [
        [
        {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
        },
        {
            "node": "If",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "If": {
    "main": [
        [
        {
            "node": "Convert to File",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Convert to File": {
    "main": [
        [
        {
            "node": "Gmail",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Loop Over Items": {
    "main": [
        null,
        [
        {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Edit Fields": {
    "main": [
        [
        {
            "node": "Date & Time",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Date & Time": {
    "main": [
        [
        {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Convert to File1": {
    "main": [
        [
        {
            "node": "Discord1",
            "type": "main",
            "index": 0
        }
        ]
    ]
    },
    "Discord1": {
    "main": [
        [
        {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
        }
        ]
    ]
    }
},
"pinData": {}
}
인포레터에서 최신 DevOps 트렌드를 격주로 만나보세요!