8
n8n 中文网amn8n.com

竞品价格监控

中级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Slack, Webhook, HttpRequest 等节点。 带AI组件和警报的价格监控仪表板

前置要求
  • Slack Bot Token 或 Webhook URL
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "CompetitorPriceMonitoring2024",
  "meta": {
    "instanceId": "competitor-price-monitoring-instance",
    "templateCredsSetupCompleted": false
  },
  "name": "竞品价格监控",
  "tags": [
    "price-monitoring",
    "competitor-analysis",
    "e-commerce",
    "google-sheets",
    "automation",
    "alerts"
  ],
  "nodes": [
    {
      "id": "daily-price-trigger",
      "name": "每日价格检查触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        400,
        700
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "manual-price-trigger",
      "name": "手动价格检查 Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        400,
        500
      ],
      "webhookId": "price-monitoring-webhook",
      "parameters": {
        "path": "price-check-webhook",
        "options": {
          "noResponseBody": false
        },
        "httpMethod": "GET"
      },
      "typeVersion": 1.1
    },
    {
      "id": "amazon-scraper",
      "name": "Amazon 价格爬虫",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        400
      ],
      "parameters": {
        "url": "https://www.amazon.com/s?k=wireless+headphones",
        "options": {
          "headers": {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "bestbuy-scraper",
      "name": "Best Buy 价格爬虫",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        600
      ],
      "parameters": {
        "url": "https://www.bestbuy.com/site/searchpage.jsp?st=wireless+headphones",
        "options": {
          "headers": {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "target-scraper",
      "name": "Target 价格爬虫",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        800
      ],
      "parameters": {
        "url": "https://www.target.com/s?searchTerm=wireless+headphones",
        "options": {
          "headers": {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "scrapegraph-ai-prices",
      "name": "AI 价格数据提取器",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        1200,
        600
      ],
      "parameters": {
        "userPrompt": "Extract product pricing information from this e-commerce website. Focus on wireless headphones and similar audio products. Use this schema for response: { \"request_id\": \"unique_id\", \"status\": \"completed\", \"website_url\": \"source_url\", \"products\": [{ \"product_name\": \"Product Title\", \"brand\": \"Brand Name\", \"current_price\": 99.99, \"original_price\": 129.99, \"discount_percentage\": 23, \"currency\": \"USD\", \"product_url\": \"https://product-page-url.com\", \"image_url\": \"https://image-url.com\", \"rating\": 4.5, \"review_count\": 1250, \"availability\": \"In Stock\", \"shipping_info\": \"Free shipping\", \"prime_eligible\": true, \"category\": \"Electronics/Audio\", \"model_number\": \"WH-1000XM4\", \"key_features\": [\"Noise Canceling\", \"30hr Battery\", \"Quick Charge\"] }] }",
        "websiteUrl": "={{ $json.url || 'https://www.amazon.com/s?k=wireless+headphones' }}"
      },
      "credentials": {
        "scrapegraphAIApi": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "price-analysis-code",
      "name": "价格分析与智能",
      "type": "n8n-nodes-base.code",
      "notes": "Analyzes pricing data,\ndetects changes, and\ngenerates competitive intelligence",
      "position": [
        1600,
        600
      ],
      "parameters": {
        "jsCode": "// Process extracted product data and analyze price changes\nconst inputData = $input.all();\nconst processedProducts = [];\n\n// Configuration for tracking specific products/brands\nconst trackingConfig = {\n  targetBrands: ['Sony', 'Apple', 'Bose', 'Sennheiser', 'Audio-Technica', 'Beats'],\n  priceThresholds: {\n    significant_drop: 0.15, // 15% price drop\n    significant_increase: 0.10, // 10% price increase\n    discount_threshold: 0.20 // 20%+ discount worth noting\n  },\n  competitors: {\n    'Amazon': { weight: 0.4, priority: 'High' },\n    'Best Buy': { weight: 0.3, priority: 'Medium' },\n    'Target': { weight: 0.3, priority: 'Medium' }\n  }\n};\n\n// Function to calculate price insights\nfunction analyzePricing(product, source) {\n  const insights = {\n    is_on_sale: false,\n    discount_level: 'none',\n    price_competitiveness: 'unknown',\n    value_score: 0\n  };\n  \n  // Check if product is on sale\n  if (product.original_price && product.current_price < product.original_price) {\n    insights.is_on_sale = true;\n    const discountPercent = product.discount_percentage || \n      ((product.original_price - product.current_price) / product.original_price * 100);\n    \n    if (discountPercent >= 30) insights.discount_level = 'high';\n    else if (discountPercent >= 15) insights.discount_level = 'moderate';\n    else insights.discount_level = 'low';\n  }\n  \n  // Calculate value score (price vs rating)\n  if (product.rating && product.current_price) {\n    insights.value_score = (product.rating * 20) / product.current_price;\n  }\n  \n  return insights;\n}\n\n// Function to detect significant changes (would compare with historical data)\nfunction detectPriceChanges(product, source) {\n  // In a real implementation, this would compare with previous prices from database\n  // For now, we'll simulate some logic based on discount levels\n  const changes = {\n    price_direction: 'stable',\n    change_significance: 'none',\n    alert_worthy: false,\n    change_percentage: 0\n  };\n  \n  // Simulate price change detection based on discount percentage\n  if (product.discount_percentage) {\n    changes.price_direction = 'down';\n    changes.change_percentage = -product.discount_percentage;\n    \n    if (product.discount_percentage >= trackingConfig.priceThresholds.significant_drop * 100) {\n      changes.change_significance = 'high';\n      changes.alert_worthy = true;\n    } else if (product.discount_percentage >= 10) {\n      changes.change_significance = 'moderate';\n      changes.alert_worthy = true;\n    }\n  }\n  \n  return changes;\n}\n\n// Function to generate competitive intelligence\nfunction generateCompetitiveIntel(product, source) {\n  return {\n    market_position: product.current_price < 100 ? 'budget' : \n                    product.current_price < 300 ? 'mid-range' : 'premium',\n    brand_strength: trackingConfig.targetBrands.includes(product.brand) ? 'strong' : 'moderate',\n    source_reliability: trackingConfig.competitors[source]?.weight || 0.2,\n    customer_satisfaction: product.rating >= 4.0 ? 'high' : \n                          product.rating >= 3.0 ? 'moderate' : 'low'\n  };\n}\n\n// Process each input (multiple HTTP requests from different sources)\ninputData.forEach(input => {\n  const sourceUrl = input.json.website_url || 'unknown';\n  const sourceName = sourceUrl.includes('amazon') ? 'Amazon' :\n                    sourceUrl.includes('bestbuy') ? 'Best Buy' :\n                    sourceUrl.includes('target') ? 'Target' : 'Unknown';\n  \n  if (input.json.result && input.json.result.products) {\n    input.json.result.products.forEach(product => {\n      // Only process products from target brands or above certain rating\n      if (trackingConfig.targetBrands.includes(product.brand) || \n          (product.rating && product.rating >= 4.0)) {\n        \n        const pricingInsights = analyzePricing(product, sourceName);\n        const priceChanges = detectPriceChanges(product, sourceName);\n        const competitiveIntel = generateCompetitiveIntel(product, sourceName);\n        \n        processedProducts.push({\n          json: {\n            // Product Identification\n            product_id: `${sourceName.toLowerCase()}_${product.model_number || Date.now()}_${Math.random().toString(36).substr(2, 5)}`,\n            product_name: product.product_name,\n            brand: product.brand,\n            model_number: product.model_number,\n            category: product.category,\n            \n            // Pricing Data\n            current_price: product.current_price,\n            original_price: product.original_price,\n            discount_percentage: product.discount_percentage,\n            currency: product.currency || 'USD',\n            \n            // Source Information\n            source: sourceName,\n            source_url: sourceUrl,\n            product_url: product.product_url,\n            source_priority: trackingConfig.competitors[sourceName]?.priority || 'Low',\n            \n            // Product Quality Metrics\n            rating: product.rating,\n            review_count: product.review_count,\n            availability: product.availability,\n            shipping_info: product.shipping_info,\n            \n            // Pricing Insights\n            is_on_sale: pricingInsights.is_on_sale,\n            discount_level: pricingInsights.discount_level,\n            value_score: Math.round(pricingInsights.value_score * 100) / 100,\n            \n            // Price Change Analysis\n            price_direction: priceChanges.price_direction,\n            change_significance: priceChanges.change_significance,\n            alert_worthy: priceChanges.alert_worthy,\n            change_percentage: priceChanges.change_percentage,\n            \n            // Competitive Intelligence\n            market_position: competitiveIntel.market_position,\n            brand_strength: competitiveIntel.brand_strength,\n            customer_satisfaction: competitiveIntel.customer_satisfaction,\n            \n            // Metadata\n            scraped_at: new Date().toISOString(),\n            tracking_priority: priceChanges.alert_worthy ? 'High' : \n                             pricingInsights.is_on_sale ? 'Medium' : 'Low',\n            \n            // Features for analysis\n            key_features: product.key_features || [],\n            image_url: product.image_url\n          }\n        });\n      }\n    });\n  }\n});\n\nreturn processedProducts;"
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "google-sheets-storage",
      "name": "Google Sheets 价格日志",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2000,
        600
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "product_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product ID",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "product_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Name",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "brand",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Brand",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "current_price",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "Current Price",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "original_price",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "Original Price",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "discount_percentage",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "Discount %",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "rating",
              "type": "number",
              "display": true,
              "required": false,
              "displayName": "Rating",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "availability",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Availability",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "is_on_sale",
              "type": "boolean",
              "display": true,
              "required": false,
              "displayName": "On Sale",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "market_position",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Market Position",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "tracking_priority",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Priority",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "scraped_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Scraped At",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "product_url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product URL",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "product_id"
          ]
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/edit#gid=0",
          "cachedResultName": "Price Data"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/edit#gid=0",
          "cachedResultName": "Price Monitoring Sheet"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "price-alert-filter",
      "name": "价格变化警报过滤器",
      "type": "n8n-nodes-base.if",
      "position": [
        1600,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "price-drop-alert",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.alert_worthy }}",
              "rightValue": true
            },
            {
              "id": "high-discount-alert",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.discount_percentage }}",
              "rightValue": 20
            },
            {
              "id": "new-low-price",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.change_significance }}",
              "rightValue": "high"
            }
          ],
          "combineOperation": "any"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "slack-price-alert",
      "name": "Slack 价格警报",
      "type": "n8n-nodes-base.slack",
      "position": [
        2000,
        400
      ],
      "parameters": {
        "text": "💰 **PRICE ALERT** 💰\n\n**{{ $json.product_name }}** by {{ $json.brand }}\n\n💸 **Current Price**: ${{ $json.current_price }}\n{% if $json.original_price %}🏷️ **Original Price**: ${{ $json.original_price }}\n✨ **Discount**: {{ $json.discount_percentage }}% OFF{% endif %}\n\n**Source**: {{ $json.source }}\n{% if $json.rating %}⭐ **Rating**: {{ $json.rating }}/5 ({{ $json.review_count }} reviews){% endif %}\n📦 **Availability**: {{ $json.availability }}\n\n**Why this matters:**\n{% if $json.change_significance == 'high' %}🚨 **SIGNIFICANT PRICE DROP** - This is a major price change!\n{% elif $json.discount_percentage >= 25 %}🔥 **HUGE DISCOUNT** - Over 25% off!\n{% elif $json.is_on_sale %}💯 **ON SALE** - Great time to buy!\n{% endif %}\n\n**Market Intelligence:**\n📊 Market Position: {{ $json.market_position | title }}\n🎯 Customer Satisfaction: {{ $json.customer_satisfaction | title }}\n💎 Value Score: {{ $json.value_score }}/10\n\n🛒 [**Buy Now**]({{ $json.product_url }})\n\n*Priority: {{ $json.tracking_priority }} | Tracked at {{ $json.scraped_at | date('short') }}*",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "C1234567890"
        },
        "otherOptions": {
          "includeLinkPreviews": true
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "sticky-triggers",
      "name": "便签 - 触发器",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        250
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# 步骤 1:价格监控触发器 ⏰"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-scraping",
      "name": "便签 - 爬虫",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# 步骤 2:多平台爬虫 🛒"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-ai-extraction",
      "name": "便签 - AI 提取",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# 步骤 3:AI 价格数据提取 🤖"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-analysis",
      "name": "便签 - 分析",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1480,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# 步骤 4:价格分析与智能 📊"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-storage-alerts",
      "name": "便签 - 存储与警报",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1880,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# 步骤 5:数据存储与警报 💾"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "price-monitoring-v1.0",
  "connections": {
    "Amazon Price Scraper": {
      "main": [
        [
          {
            "node": "AI Price Data Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Target Price Scraper": {
      "main": [
        [
          {
            "node": "AI Price Data Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Best Buy Price Scraper": {
      "main": [
        [
          {
            "node": "AI Price Data Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Price Data Extractor": {
      "main": [
        [
          {
            "node": "Price Analysis & Intelligence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Price Check Trigger": {
      "main": [
        [
          {
            "node": "Amazon Price Scraper",
            "type": "main",
            "index": 0
          },
          {
            "node": "Best Buy Price Scraper",
            "type": "main",
            "index": 0
          },
          {
            "node": "Target Price Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Price Change Alert Filter": {
      "main": [
        [
          {
            "node": "Slack Price Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Price Check Webhook": {
      "main": [
        [
          {
            "node": "Amazon Price Scraper",
            "type": "main",
            "index": 0
          },
          {
            "node": "Best Buy Price Scraper",
            "type": "main",
            "index": 0
          },
          {
            "node": "Target Price Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Price Analysis & Intelligence": {
      "main": [
        [
          {
            "node": "Google Sheets Price Log",
            "type": "main",
            "index": 0
          },
          {
            "node": "Price Change Alert Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 市场调研, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量15
分类2
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流