๐งโ๐ฆฏ GPT-4o์ Google ์คํ๋ ๋์ํธ๋ฅผ ์ฌ์ฉํ์ฌ ์น ์ ๊ทผ์ฑ ๊ฐ์
์ด๊ฒ์Product, AI, Marketing๋ถ์ผ์์๋ํ ์ํฌํ๋ก์ฐ๋ก, 14๊ฐ์ ๋ ธ๋๋ฅผ ํฌํจํฉ๋๋ค.์ฃผ๋ก If, Set, Code, Limit, HttpRequest ๋ฑ์ ๋ ธ๋๋ฅผ ์ฌ์ฉํ๋ฉฐ์ธ๊ณต์ง๋ฅ ๊ธฐ์ ์ ๊ฒฐํฉํ์ฌ ์ค๋งํธ ์๋ํ๋ฅผ ๊ตฌํํฉ๋๋ค. ๐งโ๐ฆฏ GPT-4o์ Google ์คํ๋ ๋์ํธ๋ฅผ ์ฌ์ฉํ์ฌ ์น ์ ๊ทผ์ฑ์ ๊ฐ์ ํ์ธ์
- โข๋์ API์ ์ธ์ฆ ์ ๋ณด๊ฐ ํ์ํ ์ ์์
- โขGoogle Sheets API ์ธ์ฆ ์ ๋ณด
- โขOpenAI API Key
์ฌ์ฉ๋ ๋ ธ๋ (14)
์นดํ ๊ณ ๋ฆฌ
{
"meta": {
"instanceId": "=",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "bdc398f0-a882-4fbe-ac37-7ca7e15a1081",
"name": "์คํฐํค ๋
ธํธ4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2080,
-200
],
"parameters": {
"width": 460,
"height": 340,
"content": "\n[๐ฅ Check My Tutorial](https://www.youtube.com/watch?v=LwTIro6Rapk)"
},
"typeVersion": 1
},
{
"id": "d132a584-770e-438c-bd98-28a9c1afa780",
"name": "'Test workflow' ํด๋ฆญ ์",
"type": "n8n-nodes-base.manualTrigger",
"position": [
1000,
120
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d51eec9d-a177-4f5e-89e5-c73b6109f5ce",
"name": "ํญ๋ชฉ ๋ฐ๋ณต",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2100,
640
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "41da741b-1c1d-4d41-9a96-85cadacd1c8e",
"name": "์คํฐํค ๋
ธํธ1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1000,
-200
],
"parameters": {
"color": 7,
"width": 1040,
"height": 460,
"content": "### 1. First Block: audit the page to extract all the images with their respective alternative text\nThis workflow sends an HTTP request to collect the HTML processed by the Javascript node to list all the images in the page with their alternative texts. The results are saved in a Google Sheet.\n\n#### How to setup?\n- **Set your page link** in the first node\n- **Record the results in a Google Sheet Node**:\n 1. Add your Google Sheet API credentials to access the Google Sheet file\n 2. Select the file using the list, an URL or an ID\n 3. Select the sheet in which you want to record your working sessions\n 4. Map the fields\n [Learn more about the Google Sheet Node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets)\n"
},
"typeVersion": 1
},
{
"id": "e7a269cd-a2da-4ea9-9ec8-c023c45b9e96",
"name": "ํ์ด์ง ๋งํฌ",
"type": "n8n-nodes-base.set",
"position": [
1200,
120
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "e69e5e68-5cd1-4f81-a940-2e5202d5589b",
"name": "url",
"type": "string",
"value": "https://www.samirsaci.com/sustainable-business-strategy-with-data-analytics/"
},
{
"id": "8839ac43-5d6a-4656-b555-714f836fc687",
"name": "baseUrl",
"type": "string",
"value": "https://www.samirsaci.com"
}
]
}
},
"notesInFlow": true,
"typeVersion": 3.4
},
{
"id": "6e6b7801-1f4c-4d00-826d-184dff58cee1",
"name": "๊ฒฐ๊ณผ ๋ค์ด๋ก๋",
"type": "n8n-nodes-base.googleSheets",
"position": [
1440,
640
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "=",
"value": "gid=0",
"cachedResultUrl": "=",
"cachedResultName": "="
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "=",
"cachedResultUrl": "=",
"cachedResultName": "="
}
},
"typeVersion": 4.5
},
{
"id": "1a137755-3f14-4881-93a5-db7f8678fa0d",
"name": "altLength < 50",
"type": "n8n-nodes-base.if",
"position": [
1660,
640
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a3b0ca70-0496-4966-94fd-f2927ce02ba9",
"operator": {
"type": "number",
"operation": "lt"
},
"leftValue": "={{ $json.altLength }}",
"rightValue": 100
}
]
}
},
"typeVersion": 2.2
},
{
"id": "60ea3935-313e-4d16-a8b8-a2fe7da8df82",
"name": "๊ธฐ๋ก ์ ํ",
"type": "n8n-nodes-base.limit",
"position": [
1880,
560
],
"parameters": {
"maxItems": 5
},
"typeVersion": 1
},
{
"id": "5785deb6-1bf4-40a6-b556-42aad4c01c83",
"name": "๋์ฒด ํ
์คํธ ์์ฑ",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
2320,
560
],
"parameters": {
"text": "Please generate the alternative text (alt text) for this image under 150 characters.\t",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-2024-05-13",
"cachedResultName": "GPT-4O-2024-05-13"
},
"options": {
"maxTokens": 150
},
"resource": "image",
"imageUrls": "={{ $('altLength < 50').item.json.src }}",
"operation": "analyze"
},
"notesInFlow": true,
"typeVersion": 1.8
},
{
"id": "86051a7f-e91a-4913-9c19-772673ff6306",
"name": "๊ฒฐ๊ณผ ์
๋ฐ์ดํธ",
"type": "n8n-nodes-base.googleSheets",
"position": [
2540,
640
],
"parameters": {
"columns": {
"value": {
"page": "=",
"index": "={{ $('Loop Over Items').item.json.index }}",
"newAlt": "={{ $json.content }}"
},
"schema": [
{
"id": "index",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "index",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page",
"type": "string",
"display": true,
"required": false,
"displayName": "page",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "src",
"type": "string",
"display": true,
"required": false,
"displayName": "src",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "alt",
"type": "string",
"display": true,
"required": false,
"displayName": "alt",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "altLength",
"type": "string",
"display": true,
"required": false,
"displayName": "altLength",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "newAlt",
"type": "string",
"display": true,
"required": false,
"displayName": "newAlt",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "row_number",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "row_number",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"index"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "update",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "=",
"cachedResultName": "="
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "=",
"cachedResultUrl": "=",
"cachedResultName": "="
}
},
"typeVersion": 4.5
},
{
"id": "b1ab97f7-a89e-40c8-ada3-22fcc6da2dcd",
"name": "์คํฐํค ๋
ธํธ",
"type": "n8n-nodes-base.stickyNote",
"position": [
1000,
320
],
"parameters": {
"color": 7,
"width": 1920,
"height": 520,
"content": "### 2. SecondBlock: generate alternative text for the image with altLength < 50\nThis workflow sends an HTTP request to collect the HTML processed by the Javascript node to list all the images in the page with their alternative texts. The results are saved in a Google Sheet.\n\n#### How to setup?\n- **Set your page link** in the first node\n- **Record the results in a Google Sheet Node**:\n 1. Add your Google Sheet API credentials to access the Google Sheet file\n 2. Select the file using the list, an URL or an ID\n 3. Select the sheet in which you want to record your working sessions\n 4. Map the fields\n [Learn more about the Google Sheet Node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets)\n"
},
"typeVersion": 1
},
{
"id": "c1bf1dcf-6789-43dd-9f15-29895c30fd23",
"name": "๊ฒฐ๊ณผ ์ ์ฅ",
"type": "n8n-nodes-base.googleSheets",
"position": [
1860,
120
],
"parameters": {
"columns": {
"value": {
"alt": "={{ $json.alt }}",
"src": "={{ $json.src }}",
"page": "={{ $('Page Link').item.json.url }}",
"index": "={{ $json.index }}",
"altLength": "={{ $json.altLength }}"
},
"schema": [
{
"id": "index",
"type": "string",
"display": true,
"required": false,
"displayName": "index",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "page",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "page",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "src",
"type": "string",
"display": true,
"required": false,
"displayName": "src",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "alt",
"type": "string",
"display": true,
"required": false,
"displayName": "alt",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "altLength",
"type": "string",
"display": true,
"required": false,
"displayName": "altLength",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "newAlt",
"type": "string",
"display": true,
"required": false,
"displayName": "newAlt",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "=",
"cachedResultName": "="
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "=",
"cachedResultUrl": "=",
"cachedResultName": "="
}
},
"notesInFlow": true,
"typeVersion": 4.5
},
{
"id": "fe71094e-3a22-4cda-90ad-4174258a9086",
"name": "HTML ๋ค์ด๋ก๋",
"type": "n8n-nodes-base.httpRequest",
"position": [
1420,
120
],
"parameters": {
"url": "={{ $json.url }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "405fe4cf-5271-465c-8e2a-1f5d024228b6",
"name": "altText ํฌํจ ์ด๋ฏธ์ง URL ๊ฐ์ ธ์ค๊ธฐ",
"type": "n8n-nodes-base.code",
"position": [
1640,
120
],
"parameters": {
"jsCode": "const html = $input.first().json.data;\nconst baseUrl = $('Page Link').first().json.baseUrl;\n\nconst imgTagRegex = /<img\\b[^>]*>/gi;\nconst altAttrRegex = /alt\\s*=\\s*[\"']([^\"']*)[\"']/i;\nconst srcAttrRegex = /src\\s*=\\s*[\"']([^\"']*)[\"']/i;\n\nconst imageTags = html.match(imgTagRegex) || [];\n\nconst results = imageTags.map((tag, index) => {\n const altMatch = tag.match(altAttrRegex);\n const srcMatch = tag.match(srcAttrRegex);\n\n let alt = altMatch ? altMatch[1] : '[No alt text]';\n let src = srcMatch ? srcMatch[1] : '[No src]';\n\n // If src is relative, manually join with baseUrl\n if (src !== '[No src]' && !src.startsWith('http')) {\n if (baseUrl.endsWith('/') && src.startsWith('/')) {\n src = baseUrl + src.slice(1);\n } else if (!baseUrl.endsWith('/') && !src.startsWith('/')) {\n src = baseUrl + '/' + src;\n } else {\n src = baseUrl + src;\n }\n }\n\n return {\n index: index + 1,\n src,\n alt,\n altLength: alt.length,\n };\n});\n\nreturn results.map(item => ({ json: item }));"
},
"typeVersion": 2
}
],
"pinData": {},
"connections": {
"e7a269cd-a2da-4ea9-9ec8-c023c45b9e96": {
"main": [
[
{
"node": "fe71094e-3a22-4cda-90ad-4174258a9086",
"type": "main",
"index": 0
}
]
]
},
"fe71094e-3a22-4cda-90ad-4174258a9086": {
"main": [
[
{
"node": "405fe4cf-5271-465c-8e2a-1f5d024228b6",
"type": "main",
"index": 0
}
]
]
},
"60ea3935-313e-4d16-a8b8-a2fe7da8df82": {
"main": [
[
{
"node": "d51eec9d-a177-4f5e-89e5-c73b6109f5ce",
"type": "main",
"index": 0
}
]
]
},
"86051a7f-e91a-4913-9c19-772673ff6306": {
"main": [
[
{
"node": "d51eec9d-a177-4f5e-89e5-c73b6109f5ce",
"type": "main",
"index": 0
}
]
]
},
"1a137755-3f14-4881-93a5-db7f8678fa0d": {
"main": [
[
{
"node": "60ea3935-313e-4d16-a8b8-a2fe7da8df82",
"type": "main",
"index": 0
}
]
]
},
"d51eec9d-a177-4f5e-89e5-c73b6109f5ce": {
"main": [
[],
[
{
"node": "5785deb6-1bf4-40a6-b556-42aad4c01c83",
"type": "main",
"index": 0
}
]
]
},
"6e6b7801-1f4c-4d00-826d-184dff58cee1": {
"main": [
[
{
"node": "1a137755-3f14-4881-93a5-db7f8678fa0d",
"type": "main",
"index": 0
}
]
]
},
"5785deb6-1bf4-40a6-b556-42aad4c01c83": {
"main": [
[
{
"node": "86051a7f-e91a-4913-9c19-772673ff6306",
"type": "main",
"index": 0
}
]
]
},
"405fe4cf-5271-465c-8e2a-1f5d024228b6": {
"main": [
[
{
"node": "c1bf1dcf-6789-43dd-9f15-29895c30fd23",
"type": "main",
"index": 0
}
]
]
},
"d132a584-770e-438c-bd98-28a9c1afa780": {
"main": [
[
{
"node": "e7a269cd-a2da-4ea9-9ec8-c023c45b9e96",
"type": "main",
"index": 0
},
{
"node": "6e6b7801-1f4c-4d00-826d-184dff58cee1",
"type": "main",
"index": 0
}
]
]
}
}
}์ด ์ํฌํ๋ก์ฐ๋ฅผ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์?
์์ JSON ๊ตฌ์ฑ ์ฝ๋๋ฅผ ๋ณต์ฌํ์ฌ n8n ์ธ์คํด์ค์์ ์ ์ํฌํ๋ก์ฐ๋ฅผ ์์ฑํ๊ณ "JSON์์ ๊ฐ์ ธ์ค๊ธฐ"๋ฅผ ์ ํํ ํ, ๊ตฌ์ฑ์ ๋ถ์ฌ๋ฃ๊ณ ํ์์ ๋ฐ๋ผ ์ธ์ฆ ์ค์ ์ ์์ ํ์ธ์.
์ด ์ํฌํ๋ก์ฐ๋ ์ด๋ค ์๋๋ฆฌ์ค์ ์ ํฉํ๊ฐ์?
์ค๊ธ - ์ ํ, ์ธ๊ณต์ง๋ฅ, ๋ง์ผํ
์ ๋ฃ์ธ๊ฐ์?
์ด ์ํฌํ๋ก์ฐ๋ ์์ ํ ๋ฌด๋ฃ์ด๋ฉฐ ์ง์ ๊ฐ์ ธ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋ค๋ง, ์ํฌํ๋ก์ฐ์์ ์ฌ์ฉํ๋ ํ์ฌ ์๋น์ค(์: OpenAI API)๋ ์ฌ์ฉ์ ์ง์ ๋น์ฉ์ ์ง๋ถํด์ผ ํ ์ ์์ต๋๋ค.
๊ด๋ จ ์ํฌํ๋ก์ฐ ์ถ์ฒ
Samir Saci
@samirsaciAutomation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci
์ด ์ํฌํ๋ก์ฐ ๊ณต์