电商产品优化 - Bright Data与OpenAI
中级
这是一个AI领域的自动化工作流,包含 9 个节点。主要使用 Code, HttpRequest, ManualTrigger, Agent, OpenAi 等节点,结合人工智能技术实现智能自动化。 使用Bright Data和OpenAI进行电商产品优化
前置要求
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "8212eef3ce503a3ff3b5a20b8326474820fb627fc1c3dc8486795debd39d8d25",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "93bc29f2-3004-4daa-8def-89cf9b4ad46a",
"name": "当点击\"执行工作流\"时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
0,
0
],
"parameters": {},
"typeVersion": 1
},
{
"id": "8a6e68ec-ff87-4c6b-b629-34021258a582",
"name": "BrightData",
"type": "@brightdata/n8n-nodes-brightdata.brightData",
"position": [
220,
0
],
"parameters": {
"urls": "[\n {\"url\":\"https://www.amazon.com/AmazonBasics-Multipurpose-Copy-Printer-Paper/dp/B01FV0F8H8/ref=zg_bs_g_office-products_d_sccl_1/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/Scotch-Shipping-Packaging-Dispenser-142-6/dp/B000J07BRQ/ref=zg_bs_g_office-products_d_sccl_2/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/Amazon-Basics-Premium-Colored-Multicolor/dp/B07D93R5HV/ref=zg_bs_g_office-products_d_sccl_3/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/HP-Cartridge-Black-3YM57AN-Tri-Color/dp/B08412PTS8/ref=zg_bs_g_office-products_d_sccl_4/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/HP-Printer-Paper-Print20-200060R/dp/B001AFL8GY/ref=zg_bs_g_office-products_d_sccl_5/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/Scotch-Shipping-Packaging-Dispenser-142L/dp/B000MVV6AA/ref=zg_bs_g_office-products_d_sccl_6/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/Amazon-Basics-50-Sheet-Legal-Inches/dp/B00QSR9URI/ref=zg_bs_g_office-products_d_sccl_7/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/Sharpie-Permanent-Markers-Resistant-Coloring/dp/B00006IFHD/ref=zg_bs_g_office-products_d_sccl_8/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/AmazonBasics-Thermal-Laminating-Plastic-Laminator/dp/B079KL4C91/ref=zg_bs_g_office-products_d_sccl_9/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/YSAGi-Leather-Protector-Non-Slip-Waterproof/dp/B0BMTPC44X/ref=zg_bs_g_office-products_d_sccl_10/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/EZlifego-Multipurpose-Removable-Transparent-Household/dp/B07VNSXY31/ref=zg_bs_g_office-products_d_sccl_11/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/BIC-Highlighter-Chisel-Assorted-5-Count/dp/B000Q5ZGIA/ref=zg_bs_g_office-products_d_sccl_12/142-6608713-4877828?psc=1\"},\n {\"url\":\"https://www.amazon.com/Academic-Planner-2025-2026-Monthly-Calendar/dp/B0DXPSZDP9/ref=zg_bs_g_office-products_d_sccl_22/142-6608713-4877828?psc=1\"}\n]\n",
"resource": "webScrapper",
"dataset_id": {
"__rl": true,
"mode": "list",
"value": "gd_l1vijixj9g2vp7563",
"cachedResultName": "Amazon best seller products"
},
"requestOptions": {}
},
"credentials": {
"brightdataApi": {
"id": "YOUR_BRIGHTDATA_CREDENTIAL_ID",
"name": "BrightData account"
}
},
"typeVersion": 1
},
{
"id": "7a817929-aa8a-4813-9fd0-e778c46ad173",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
440,
0
],
"parameters": {
"jsCode": "// get all incoming items\nconst allInputItems = $input.all(); \n\nlet jsonlString = \"\";\n// define the training prompt\nconst systemMessage = \"You are an expert marketing assistant specializing in writing compelling and informative product descriptions.\";\n\n// loop through each item retrieved from the input\nfor (const item of allInputItems) {\n const product = item.json; \n\n // validate if the product data exists and is an object\n if (!product || typeof product !== 'object') {\n console.warn('Skipping an item because product data is missing or not an object:', item);\n continue;\n }\n\n // extract product data\n const title = product.title || \"N/A\";\n const brand = product.brand || \"N/A\";\n let featuresString = \"Not specified\";\n if (product.features && Array.isArray(product.features) && product.features.length > 0) {\n featuresString = product.features.slice(0, 5).join(', '); \n }\n // create a snippet of the original product description for training\n const originalDescSnippet = (product.description || \"No original description available.\").substring(0, 250) + \"...\";\n // create prompt with specific details about the product\n const userPrompt = `Generate a product description for the following item. Title: ${title}. Brand: ${brand}. Key Features: ${featuresString}. Original Description Snippet: ${originalDescSnippet}.`;\n\n // create template for the kind of description the AI should generate\n let idealDescription = `Discover the ${title} from ${brand}, a top-choice for discerning customers. `;\n idealDescription += `Key highlights include: ${featuresString}. `;\n if (product.rating) {\n idealDescription += `Boasting an impressive customer rating of ${product.rating} out of 5 stars! `;\n }\n idealDescription += `This product, originally described as \"${originalDescSnippet}\", is perfect for anyone seeking quality and reliability. `;\n idealDescription += `Don't miss out on the ${product.availability === \"In Stock\" ? \"readily available\" : \"upcoming\"} ${title} – enhance your collection today!`;\n\n // create a training example object in the format expected by OpenAI\n const trainingExample = {\n messages: [\n { role: \"system\", content: systemMessage },\n { role: \"user\", content: userPrompt },\n { role: \"assistant\", content: idealDescription }\n ]\n };\n jsonlString += JSON.stringify(trainingExample) + \"\\n\";\n}\n\n// remove any leading or trailing whitespace\nconst fileContentString = jsonlString.trim();\n\n// check if any product data was actually processed\nif (fileContentString.length === 0) {\n console.warn(\"No product data was processed, outputting empty file content.\");\n return [{ \n json: { error: \"No products processed\", fileNameToUse: \"data.jsonl\" },\n binary: {} \n }];\n}\n\n// convert the final JSONL string into a Buffer (raw binary data)\nconst buffer = Buffer.from(fileContentString, 'utf-8');\n// define the filename that will be used when this data is sent to OpenAI\nconst actualFileNameForOpenAI = \"data.jsonl\";\n// define the MIME type for the file\nconst mimeType = 'application/jsonl'; \n\n// prepare the binary data for output\nconst binaryData = await this.helpers.prepareBinaryData(buffer, actualFileNameForOpenAI, mimeType);\n\n// return the processed data\nreturn [{\n json: {\n processedFileName: actualFileNameForOpenAI \n },\n binary: {\n // the \"Input Data Field Name\" in the OpenAI node\n \"data.jsonl\": binaryData \n }\n}];"
},
"typeVersion": 2
},
{
"id": "9e8f8656-79c5-4d8a-8e27-f07907ba852e",
"name": "OpenAI",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
660,
0
],
"parameters": {
"options": {
"purpose": "fine-tune"
},
"resource": "file",
"binaryPropertyName": "data.jsonl"
},
"credentials": {
"openAiApi": {
"id": "YOUR_OPENAI_CREDENTIAL_ID",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "f391f934-1804-41ad-9ad5-303c613999b6",
"name": "HTTP 请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
840,
0
],
"parameters": {
"url": "https://api.openai.com/v1/fine_tuning/jobs",
"method": "POST",
"options": {},
"jsonBody": "={\n \"training_file\": \"{{ $json.id }}\",\n \"model\": \"gpt-4o-mini-2024-07-18\"\n} ",
"sendBody": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "openAiApi"
},
"credentials": {
"openAiApi": {
"id": "YOUR_OPENAI_CREDENTIAL_ID",
"name": "OpenAi account"
}
},
"typeVersion": 4.2
},
{
"id": "add8279c-fdaf-4e6c-9b6b-242a85295cf5",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
0,
200
],
"webhookId": "aa97eb0d-e190-40b8-aecd-f36f239f7ad1",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "72c8af8d-45e0-4ae8-b10b-723e8bf1f61c",
"name": "AI 代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
220,
200
],
"parameters": {
"options": {}
},
"typeVersion": 2
},
{
"id": "392b85ba-0ded-4838-ba17-df858e7f922d",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
260,
420
],
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "YOUR_FINE_TUNED_MODEL_ID"
},
"options": {
"responseFormat": "text"
}
},
"credentials": {
"openAiApi": {
"id": "YOUR_OPENAI_CREDENTIAL_ID",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "cab8fbc8-5cff-4b14-a36d-d7d89a83cf6e",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-380,
-480
],
"parameters": {
"width": 280,
"height": 1080,
"content": "此n8n工作流自动化抓取Amazon产品数据,并将其用于微调自定义OpenAI模型以生成营销文案。"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Code": {
"main": [
[
{
"node": "OpenAI",
"type": "main",
"index": 0
}
]
]
},
"OpenAI": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"BrightData": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "BrightData",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
AI智能体:数秒内精准匹配LinkedIn人脉
AI智能体:数秒内精准匹配LinkedIn人脉
Set
Code
Split Out
+10
15 节点Badr
人工智能
AI房地产经纪人:端到端运营自动化(网络、数据、语音)
AI房地产经纪人:端到端运营自动化(网络、数据、语音)
If
Set
Code
+16
45 节点Sam Yassine
销售
支持文本、语音、图像和PDF的AI驱动WhatsApp聊天机器人(RAG)
支持文本、语音、图像和PDF的AI驱动WhatsApp聊天机器人(RAG)
Set
Code
Switch
+15
35 节点NovaNode
工程
自动化博客撰写与社交媒体推广代理
使用GPT-4、Perplexity和WordPress自动化SEO博客创建+社交媒体
Set
Code
Gmail
+21
79 节点LukaszB
设计
在Braze中更新现有邮件模板
使用AI为Instagram、Facebook、LinkedIn和X自动化社交媒体内容
Set
Gmail
Merge
+22
73 节点LukaszB
设计
使用OpenAI模型进行微调
集成Google Drive的OpenAI模型端到端自动化微调
Google Drive
Http Request
Manual Trigger
+5
9 节点Davide
人工智能
工作流信息
难度等级
中级
节点数量9
分类1
节点类型9
作者
Daniel Shashko
@tomaxAI automation specialist and a marketing enthusiast. More than 6 years of experience in SEO/GEO. Senior SEO at Bright Data.
外部链接
在 n8n.io 查看 →
分享此工作流