8
n8n 中文网amn8n.com

我的工作流 2

高级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 25 个节点。主要使用 If, Code, Merge, Slack, EmailSend 等节点。 结合 AI 竞品监控和收入优化的自动化动态定价

前置要求
  • Slack Bot Token 或 Webhook URL
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "VhEwspDqzu7ssFVE",
  "meta": {
    "instanceId": "f4b0efaa33080e7774e0d9285c40c7abcd2c6f7cf1a8b901fa7106170dd4cda3",
    "templateCredsSetupCompleted": true
  },
  "name": "我的工作流 2",
  "tags": [
    {
      "id": "IxkcJ2IpYIxivoHV",
      "name": "Content Strategy",
      "createdAt": "2025-07-25T12:57:37.677Z",
      "updatedAt": "2025-07-25T12:57:37.677Z"
    },
    {
      "id": "PAKIJ2Mm9EvRcR3u",
      "name": "Trend Monitoring",
      "createdAt": "2025-07-25T12:57:37.670Z",
      "updatedAt": "2025-07-25T12:57:37.670Z"
    },
    {
      "id": "YtfXmaZk44MYedPO",
      "name": "Dynamic Pricing",
      "createdAt": "2025-07-25T16:24:30.369Z",
      "updatedAt": "2025-07-25T16:24:30.369Z"
    },
    {
      "id": "DxXGubfBzRKh6L8T",
      "name": "Revenue Optimization",
      "createdAt": "2025-07-25T16:24:30.370Z",
      "updatedAt": "2025-07-25T16:24:30.370Z"
    }
  ],
  "nodes": [
    {
      "id": "a6fbe4c4-1091-432d-b21a-9bdc41133bb2",
      "name": "每小时价格监控触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "notes": "Triggers every hour for real-time price optimization",
      "position": [
        -2896,
        -160
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ad01958e-33d3-4b19-95c3-302b57b0e309",
      "name": "价格配置处理器",
      "type": "n8n-nodes-base.code",
      "position": [
        -2208,
        -32
      ],
      "parameters": {
        "jsCode": "// Dynamic Pricing Configuration & Product Management\n// Created: 25/7/2025\n\nconst pricingConfig = {\n  // Product catalog with pricing parameters\n  products: [\n    {\n      id: 'PROD-001',\n      name: 'Wireless Bluetooth Headphones',\n      category: 'Electronics',\n      current_price: 79.99,\n      cost_price: 35.00,\n      min_margin: 0.25, // 25% minimum margin\n      max_margin: 0.65, // 65% maximum margin\n      min_price: 45.00,\n      max_price: 120.00,\n      inventory_level: 150,\n      monthly_sales: 45,\n      competitor_products: [\n        'Sony WH-CH720N',\n        'JBL Tune 760NC',\n        'Sennheiser HD 450BT'\n      ],\n      search_keywords: ['wireless headphones', 'bluetooth headphones', 'noise canceling']\n    },\n    {\n      id: 'PROD-002',\n      name: 'Smart Fitness Tracker',\n      category: 'Wearables',\n      current_price: 149.99,\n      cost_price: 65.00,\n      min_margin: 0.30,\n      max_margin: 0.70,\n      min_price: 85.00,\n      max_price: 200.00,\n      inventory_level: 75,\n      monthly_sales: 28,\n      competitor_products: [\n        'Fitbit Charge 5',\n        'Garmin Vivosmart 4',\n        'Samsung Galaxy Fit2'\n      ],\n      search_keywords: ['fitness tracker', 'smart watch', 'activity monitor']\n    },\n    {\n      id: 'PROD-003',\n      name: 'Portable Phone Charger',\n      category: 'Accessories',\n      current_price: 29.99,\n      cost_price: 12.00,\n      min_margin: 0.20,\n      max_margin: 0.60,\n      min_price: 15.00,\n      max_price: 45.00,\n      inventory_level: 300,\n      monthly_sales: 120,\n      competitor_products: [\n        'Anker PowerCore 10000',\n        'RAVPower 20000mAh',\n        'Belkin Boost Charge'\n      ],\n      search_keywords: ['power bank', 'portable charger', 'phone battery']\n    }\n  ],\n  \n  // Competitor monitoring configuration\n  competitors: {\n    'Amazon': {\n      base_url: 'https://www.amazon.com/s?k=',\n      price_selector: '.a-price-whole',\n      weight: 0.35 // Influence on pricing decisions\n    },\n    'Best Buy': {\n      base_url: 'https://www.bestbuy.com/site/searchpage.jsp?st=',\n      price_selector: '.visually-hidden',\n      weight: 0.25\n    },\n    'Walmart': {\n      base_url: 'https://www.walmart.com/search?q=',\n      price_selector: '[data-automation-id=\"product-price\"]',\n      weight: 0.20\n    },\n    'Target': {\n      base_url: 'https://www.target.com/s?searchTerm=',\n      price_selector: '[data-test=\"product-price\"]',\n      weight: 0.20\n    }\n  },\n  \n  // Pricing strategy parameters\n  strategies: {\n    aggressive: {\n      description: 'Beat competitor prices by 5-10%',\n      price_adjustment: -0.075, // Average 7.5% below competitors\n      margin_tolerance: 0.15, // Accept 15% margin reduction\n      inventory_threshold: 100 // Use when inventory > 100\n    },\n    competitive: {\n      description: 'Match competitor average prices',\n      price_adjustment: 0.00, // Match competitor average\n      margin_tolerance: 0.05, // Accept 5% margin reduction\n      inventory_threshold: 50 // Use when inventory 50-100\n    },\n    premium: {\n      description: 'Price 10-20% above competitors',\n      price_adjustment: 0.15, // 15% above competitors\n      margin_tolerance: -0.10, // Allow 10% margin increase\n      inventory_threshold: 0 // Use when inventory < 50\n    }\n  },\n  \n  // Market demand indicators\n  demand_factors: {\n    seasonality: {\n      'Q4': 1.3, // Holiday season boost\n      'Q1': 0.8, // Post-holiday decline\n      'Q2': 1.0, // Normal demand\n      'Q3': 1.1  // Back-to-school boost\n    },\n    day_of_week: {\n      'Monday': 0.9,\n      'Tuesday': 0.95,\n      'Wednesday': 1.0,\n      'Thursday': 1.05,\n      'Friday': 1.2, // Weekend shopping\n      'Saturday': 1.3,\n      'Sunday': 1.1\n    },\n    time_of_day: {\n      'morning': 0.8,   // 6AM-12PM\n      'afternoon': 1.2, // 12PM-6PM\n      'evening': 1.4,   // 6PM-10PM\n      'night': 0.6      // 10PM-6AM\n    }\n  },\n  \n  // Revenue optimization settings\n  optimization: {\n    revenue_weight: 0.6,  // 60% focus on revenue\n    margin_weight: 0.25,  // 25% focus on margin\n    velocity_weight: 0.15, // 15% focus on sales velocity\n    \n    // Price change constraints\n    max_price_change: 0.15, // Maximum 15% price change per hour\n    min_change_threshold: 0.02, // Only change price if >2% difference\n    price_change_frequency: 1, // Hours between price changes\n    \n    // Performance thresholds\n    low_performance_threshold: 0.7, // Sales velocity < 70% of target\n    high_performance_threshold: 1.3  // Sales velocity > 130% of target\n  }\n};\n\n// Get current market context\nconst now = new Date();\nconst currentHour = now.getHours();\nconst currentDay = now.toLocaleDateString('en-US', { weekday: 'long' });\nconst currentQuarter = Math.ceil((now.getMonth() + 1) / 3);\n\n// Determine time-based demand factors\nlet timeOfDay = 'night';\nif (currentHour >= 6 && currentHour < 12) timeOfDay = 'morning';\nelse if (currentHour >= 12 && currentHour < 18) timeOfDay = 'afternoon';\nelse if (currentHour >= 18 && currentHour < 22) timeOfDay = 'evening';\n\nconst demandMultiplier = \n  pricingConfig.demand_factors.seasonality[`Q${currentQuarter}`] *\n  pricingConfig.demand_factors.day_of_week[currentDay] *\n  pricingConfig.demand_factors.time_of_day[timeOfDay];\n\n// Generate competitor monitoring tasks\nconst monitoringTasks = [];\nconst competitors = Object.keys(pricingConfig.competitors);\n\n// Create monitoring tasks for each product-competitor combination\npricingConfig.products.forEach(product => {\n  competitors.forEach(competitor => {\n    product.search_keywords.forEach(keyword => {\n      monitoringTasks.push({\n        product_id: product.id,\n        product_name: product.name,\n        competitor: competitor,\n        search_keyword: keyword,\n        search_url: pricingConfig.competitors[competitor].base_url + encodeURIComponent(keyword),\n        competitor_weight: pricingConfig.competitors[competitor].weight,\n        current_price: product.current_price,\n        cost_price: product.cost_price,\n        inventory_level: product.inventory_level,\n        monthly_sales: product.monthly_sales\n      });\n    });\n  });\n});\n\n// Session tracking\nconst sessionId = `pricing_${Date.now()}`;\nconst timestamp = now.toISOString();\n\n// Generate comprehensive monitoring configuration\nreturn [{\n  json: {\n    sessionId: sessionId,\n    timestamp: timestamp,\n    market_context: {\n      current_hour: currentHour,\n      current_day: currentDay,\n      current_quarter: currentQuarter,\n      time_of_day: timeOfDay,\n      demand_multiplier: demandMultiplier\n    },\n    config: pricingConfig,\n    monitoring_tasks: monitoringTasks,\n    total_monitoring_tasks: monitoringTasks.length,\n    products_count: pricingConfig.products.length,\n    competitors_count: competitors.length\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "5da725c9-5cf0-406e-a929-a5eaf7d86e10",
      "name": "拆分监控任务",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1616,
        -96
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "1d1e1e73-96ed-48a1-b35f-c6763c7432fc",
      "name": "任务处理器",
      "type": "n8n-nodes-base.code",
      "position": [
        -1056,
        -160
      ],
      "parameters": {
        "jsCode": "// Task Processing and Competitor URL Generation\nconst items = $input.all();\nconst configData = items[0].json;\nconst batchData = $('Split Monitoring Tasks').item.json;\n\n// Get current monitoring task\nconst currentTask = configData.monitoring_tasks[batchData.index];\n\n// Add market context to current task\nconst enhancedTask = {\n  ...currentTask,\n  ...configData.market_context,\n  config: configData.config,\n  batchIndex: batchData.index,\n  totalBatches: configData.monitoring_tasks.length\n};\n\nreturn [{\n  json: enhancedTask\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "44854565-bda3-4823-b8aa-221c9d0862aa",
      "name": "AI 竞争对手价格抓取器",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        -448,
        192
      ],
      "parameters": {
        "userPrompt": "Extract competitor pricing data from this e-commerce search results page. Focus on products similar to our target product and their pricing information. Use this schema: { \"competitor\": \"Amazon\", \"search_keyword\": \"wireless headphones\", \"products_found\": [{ \"product_name\": \"Sony WH-CH720N Wireless Headphones\", \"brand\": \"Sony\", \"price\": 89.99, \"original_price\": 129.99, \"discount_percentage\": 31, \"rating\": 4.5, \"review_count\": 1247, \"availability\": \"In Stock\", \"shipping_info\": \"Free shipping\", \"seller\": \"Amazon\", \"product_url\": \"https://amazon.com/dp/B09XXXX\", \"features\": [\"Noise Canceling\", \"30hr Battery\"], \"similar_to_target\": true, \"relevance_score\": 0.85 }], \"price_statistics\": { \"min_price\": 45.99, \"max_price\": 199.99, \"avg_price\": 92.45, \"median_price\": 89.99, \"price_range\": 154.00 }, \"market_insights\": { \"total_products\": 12, \"brands_found\": [\"Sony\", \"JBL\", \"Bose\"], \"avg_rating\": 4.3, \"price_trend\": \"stable\", \"promotion_frequency\": \"high\" } }",
        "websiteUrl": "={{ $json.search_url }}"
      },
      "typeVersion": 1
    },
    {
      "id": "8ef3100b-2c01-403d-8d51-15fc3bed6ee3",
      "name": "AI 需求分析抓取器",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        -448,
        -32
      ],
      "parameters": {
        "userPrompt": "Analyze search demand trends for this product keyword to assess market demand and pricing opportunities. Extract trend data and demand indicators. Schema: { \"keyword\": \"wireless headphones\", \"search_volume_trend\": \"rising\", \"interest_score\": 78, \"related_queries\": [{ \"query\": \"best wireless headphones\", \"growth\": \"+25%\" }, { \"query\": \"cheap bluetooth headphones\", \"growth\": \"+15%\" }], \"geographic_interest\": [{ \"region\": \"United States\", \"interest\": 100 }, { \"region\": \"Canada\", \"interest\": 67 }], \"seasonal_patterns\": { \"current_vs_avg\": 1.15, \"peak_months\": [\"November\", \"December\"], \"low_months\": [\"January\", \"February\"] }, \"demand_indicators\": { \"price_sensitivity\": \"medium\", \"brand_loyalty\": \"low\", \"purchase_urgency\": \"medium\", \"comparison_shopping\": \"high\" }, \"market_saturation\": \"medium\", \"growth_opportunity\": \"high\" }",
        "websiteUrl": "={{ 'https://trends.google.com/trends/explore?q=' + encodeURIComponent($json.search_keyword) + '&date=now%201-d' }}"
      },
      "typeVersion": 1
    },
    {
      "id": "08667817-4134-4999-a74f-a83cf0080614",
      "name": "AI 客户情绪抓取器",
      "type": "n8n-nodes-scrapegraphai.scrapegraphAi",
      "position": [
        -448,
        416
      ],
      "parameters": {
        "userPrompt": "Analyze customer reviews and sentiment for products in this category to understand price sensitivity and value perception. Extract customer insights that inform pricing decisions. Schema: { \"category\": \"wireless headphones\", \"total_reviews_analyzed\": 156, \"sentiment_analysis\": { \"positive\": 0.68, \"neutral\": 0.22, \"negative\": 0.10 }, \"price_mentions\": [{ \"price_point\": \"$50-80\", \"sentiment\": \"positive\", \"frequency\": 45, \"context\": \"good value for money\" }, { \"price_point\": \"$80-120\", \"sentiment\": \"mixed\", \"frequency\": 32, \"context\": \"expensive but worth it\" }], \"value_drivers\": [{ \"feature\": \"battery life\", \"importance\": 0.85, \"satisfaction\": 0.78 }, { \"feature\": \"sound quality\", \"importance\": 0.92, \"satisfaction\": 0.81 }], \"price_complaints\": [{ \"issue\": \"overpriced for features\", \"frequency\": 23 }, { \"issue\": \"better alternatives available\", \"frequency\": 18 }], \"purchase_drivers\": [\"sound quality\", \"brand reputation\", \"battery life\", \"comfort\"], \"price_elasticity_indicators\": { \"willingness_to_pay_premium\": 0.34, \"price_sensitivity_score\": 0.67, \"brand_premium_acceptance\": 0.45 } }",
        "websiteUrl": "={{ 'https://www.amazon.com/s?k=' + encodeURIComponent($json.search_keyword + ' reviews') + '&sort=review-rank' }}"
      },
      "typeVersion": 1
    },
    {
      "id": "28f0d262-548e-4f3d-b979-dd3f7a83a723",
      "name": "合并价格数据",
      "type": "n8n-nodes-base.merge",
      "position": [
        160,
        -160
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "mergeByFields": {
          "values": [
            {}
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1f84e997-4771-42fb-bb6e-b9d38693e80e",
      "name": "价格优化引擎",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        -16
      ],
      "parameters": {
        "jsCode": "// Advanced Pricing Optimization Algorithm\nconst allData = $input.all();\nconst taskData = allData[0].json;\nconst competitorData = allData[1]?.json?.result || {};\nconst demandData = allData[2]?.json?.result || {};\nconst sentimentData = allData[3]?.json?.result || {};\n\n// Advanced pricing optimization engine\nconst pricingOptimizer = {\n  // Calculate optimal price based on multiple factors\n  calculateOptimalPrice(currentPrice, competitorPrices, demandFactors, customerSentiment, productData) {\n    const factors = {\n      competitor_influence: 0.35,\n      demand_influence: 0.25,\n      sentiment_influence: 0.20,\n      inventory_influence: 0.10,\n      margin_influence: 0.10\n    };\n    \n    // Competitor pricing analysis\n    const competitorScore = this.analyzeCompetitorPricing(currentPrice, competitorPrices);\n    \n    // Demand analysis\n    const demandScore = this.analyzeDemand(demandFactors, taskData.demand_multiplier);\n    \n    // Customer sentiment analysis\n    const sentimentScore = this.analyzeSentiment(customerSentiment, currentPrice);\n    \n    // Inventory level analysis\n    const inventoryScore = this.analyzeInventory(productData.inventory_level, productData.monthly_sales);\n    \n    // Margin protection analysis\n    const marginScore = this.analyzeMargin(currentPrice, productData.cost_price);\n    \n    // Calculate weighted optimization score\n    const optimizationScore = \n      (competitorScore * factors.competitor_influence) +\n      (demandScore * factors.demand_influence) +\n      (sentimentScore * factors.sentiment_influence) +\n      (inventoryScore * factors.inventory_influence) +\n      (marginScore * factors.margin_influence);\n    \n    // Convert score to price adjustment\n    const priceAdjustment = this.scoreToPrice(optimizationScore, currentPrice, productData);\n    \n    return {\n      current_price: currentPrice,\n      recommended_price: priceAdjustment.new_price,\n      price_change: priceAdjustment.change_amount,\n      price_change_percentage: priceAdjustment.change_percentage,\n      optimization_score: optimizationScore,\n      factor_scores: {\n        competitor: competitorScore,\n        demand: demandScore,\n        sentiment: sentimentScore,\n        inventory: inventoryScore,\n        margin: marginScore\n      },\n      confidence_level: this.calculateConfidence(competitorPrices, demandFactors, customerSentiment),\n      strategy_recommendation: this.recommendStrategy(optimizationScore, productData)\n    };\n  },\n  \n  // Analyze competitor pricing impact\n  analyzeCompetitorPricing(currentPrice, competitorData) {\n    if (!competitorData.price_statistics) return 0;\n    \n    const avgCompetitorPrice = competitorData.price_statistics.avg_price;\n    const minCompetitorPrice = competitorData.price_statistics.min_price;\n    const maxCompetitorPrice = competitorData.price_statistics.max_price;\n    \n    // Calculate position relative to competitors\n    const relativePosition = (currentPrice - avgCompetitorPrice) / avgCompetitorPrice;\n    \n    // Score based on competitive position\n    if (relativePosition > 0.15) return -0.8; // Too expensive, reduce price\n    if (relativePosition > 0.05) return -0.4; // Slightly expensive\n    if (relativePosition > -0.05) return 0.0; // Competitive\n    if (relativePosition > -0.15) return 0.3; // Good value\n    return 0.6; // Excellent value, can increase\n  },\n  \n  // Analyze demand factors\n  analyzeDemand(demandData, demandMultiplier) {\n    let demandScore = 0;\n    \n    // Search volume trend impact\n    if (demandData.search_volume_trend === 'rising') demandScore += 0.4;\n    else if (demandData.search_volume_trend === 'falling') demandScore -= 0.4;\n    \n    // Interest score impact\n    const interestScore = (demandData.interest_score || 50) / 100;\n    demandScore += (interestScore - 0.5) * 0.6;\n    \n    // Seasonal/time-based demand multiplier\n    demandScore += (demandMultiplier - 1.0) * 0.5;\n    \n    return Math.max(-1, Math.min(1, demandScore));\n  },\n  \n  // Analyze customer sentiment\n  analyzeSentiment(sentimentData, currentPrice) {\n    if (!sentimentData.price_elasticity_indicators) return 0;\n    \n    const priceElasticity = sentimentData.price_elasticity_indicators;\n    let sentimentScore = 0;\n    \n    // Price sensitivity analysis\n    const priceSensitivity = priceElasticity.price_sensitivity_score || 0.5;\n    sentimentScore -= (priceSensitivity - 0.5) * 0.8;\n    \n    // Willingness to pay premium\n    const premiumWillingness = priceElasticity.willingness_to_pay_premium || 0.3;\n    sentimentScore += (premiumWillingness - 0.3) * 0.6;\n    \n    // Brand premium acceptance\n    const brandPremium = priceElasticity.brand_premium_acceptance || 0.4;\n    sentimentScore += (brandPremium - 0.4) * 0.4;\n    \n    return Math.max(-1, Math.min(1, sentimentScore));\n  },\n  \n  // Analyze inventory levels\n  analyzeInventory(inventoryLevel, monthlySales) {\n    const monthsOfInventory = inventoryLevel / (monthlySales || 1);\n    \n    if (monthsOfInventory > 6) return -0.6; // Excess inventory, reduce price\n    if (monthsOfInventory > 3) return -0.3; // High inventory\n    if (monthsOfInventory > 1) return 0.0;  // Normal inventory\n    if (monthsOfInventory > 0.5) return 0.4; // Low inventory, increase price\n    return 0.8; // Very low inventory\n  },\n  \n  // Analyze margin protection\n  analyzeMargin(currentPrice, costPrice) {\n    const currentMargin = (currentPrice - costPrice) / currentPrice;\n    \n    if (currentMargin < 0.2) return 0.8;  // Low margin, increase price\n    if (currentMargin < 0.3) return 0.4;  // Acceptable margin\n    if (currentMargin < 0.5) return 0.0;  // Good margin\n    if (currentMargin < 0.6) return -0.2; // High margin, can reduce\n    return -0.4; // Very high margin\n  },\n  \n  // Convert optimization score to price adjustment\n  scoreToPrice(score, currentPrice, productData) {\n    // Base price adjustment percentage\n    const baseAdjustment = score * 0.15; // Max 15% adjustment\n    \n    // Apply constraints\n    const maxChange = taskData.config.optimization.max_price_change;\n    const constrainedAdjustment = Math.max(-maxChange, Math.min(maxChange, baseAdjustment));\n    \n    // Calculate new price\n    const newPrice = currentPrice * (1 + constrainedAdjustment);\n    \n    // Apply product-specific constraints\n    const finalPrice = Math.max(\n      productData.min_price || 0,\n      Math.min(productData.max_price || 9999, newPrice)\n    );\n    \n    // Check minimum change threshold\n    const changeAmount = finalPrice - currentPrice;\n    const changePercentage = changeAmount / currentPrice;\n    \n    if (Math.abs(changePercentage) < taskData.config.optimization.min_change_threshold) {\n      return {\n        new_price: currentPrice, // No change\n        change_amount: 0,\n        change_percentage: 0\n      };\n    }\n    \n    return {\n      new_price: Math.round(finalPrice * 100) / 100, // Round to 2 decimals\n      change_amount: Math.round(changeAmount * 100) / 100,\n      change_percentage: Math.round(changePercentage * 10000) / 100 // Percentage with 2 decimals\n    };\n  },\n  \n  // Calculate confidence level\n  calculateConfidence(competitorData, demandData, sentimentData) {\n    let confidence = 0.5; // Base confidence\n    \n    // More data = higher confidence\n    if (competitorData.products_found?.length > 5) confidence += 0.2;\n    if (demandData.interest_score > 70) confidence += 0.15;\n    if (sentimentData.total_reviews_analyzed > 100) confidence += 0.15;\n    \n    return Math.min(1.0, confidence);\n  },\n  \n  // Recommend pricing strategy\n  recommendStrategy(optimizationScore, productData) {\n    const inventory = productData.inventory_level;\n    const strategies = taskData.config.strategies;\n    \n    if (optimizationScore < -0.3 && inventory > strategies.aggressive.inventory_threshold) {\n      return 'aggressive';\n    } else if (optimizationScore > 0.3 && inventory < strategies.premium.inventory_threshold) {\n      return 'premium';\n    } else {\n      return 'competitive';\n    }\n  }\n};\n\n// Execute pricing optimization\nconst productData = {\n  inventory_level: taskData.inventory_level,\n  monthly_sales: taskData.monthly_sales,\n  cost_price: taskData.cost_price,\n  min_price: taskData.config.products.find(p => p.id === taskData.product_id)?.min_price,\n  max_price: taskData.config.products.find(p => p.id === taskData.product_id)?.max_price\n};\n\nconst pricingRecommendation = pricingOptimizer.calculateOptimalPrice(\n  taskData.current_price,\n  competitorData,\n  demandData,\n  sentimentData,\n  productData\n);\n\n// Calculate revenue projections\nconst revenueProjection = {\n  current_revenue_estimate: taskData.current_price * taskData.monthly_sales,\n  projected_revenue_estimate: pricingRecommendation.recommended_price * taskData.monthly_sales * (1 + (demandData.interest_score || 50) / 500),\n  revenue_change_estimate: 0\n};\nrevenueProjection.revenue_change_estimate = revenueProjection.projected_revenue_estimate - revenueProjection.current_revenue_estimate;\n\n// Compile comprehensive pricing analysis\nconst pricingAnalysis = {\n  session_id: taskData.sessionId,\n  timestamp: new Date().toISOString(),\n  product_info: {\n    id: taskData.product_id,\n    name: taskData.product_name,\n    category: taskData.config.products.find(p => p.id === taskData.product_id)?.category,\n    current_price: taskData.current_price,\n    cost_price: taskData.cost_price\n  },\n  market_analysis: {\n    competitor: taskData.competitor,\n    search_keyword: taskData.search_keyword,\n    competitor_data: competitorData,\n    demand_data: demandData,\n    sentiment_data: sentimentData\n  },\n  pricing_recommendation: pricingRecommendation,\n  revenue_projection: revenueProjection,\n  market_context: taskData.market_context || {},\n  batch_info: {\n    batch_index: taskData.batchIndex,\n    total_batches: taskData.totalBatches\n  }\n};\n\nreturn [{ json: pricingAnalysis }];"
      },
      "typeVersion": 2
    },
    {
      "id": "863baca7-51c3-4e8e-9f26-b8ac88f722b3",
      "name": "价格变更过滤器",
      "type": "n8n-nodes-base.if",
      "position": [
        1424,
        -80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "significant-price-change",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ Math.abs($json.pricing_recommendation.price_change_percentage) }}",
              "rightValue": 2
            },
            {
              "id": "high-confidence",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.pricing_recommendation.confidence_level }}",
              "rightValue": 0.7
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "0a6015f3-9594-43f6-aadb-24b1272078a4",
      "name": "价格更新 API 调用",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2080,
        -80
      ],
      "parameters": {
        "url": "={{ 'https://your-ecommerce-api.com/products/' + $json.product_info.id + '/price' }}",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "price",
              "value": "={{ $json.pricing_recommendation.recommended_price }}"
            },
            {
              "name": "previous_price",
              "value": "={{ $json.product_info.current_price }}"
            },
            {
              "name": "change_reason",
              "value": "={{ 'Automated optimization: ' + $json.pricing_recommendation.strategy_recommendation + ' strategy' }}"
            },
            {
              "name": "confidence_score",
              "value": "={{ $json.pricing_recommendation.confidence_level }}"
            },
            {
              "name": "effective_date",
              "value": "={{ new Date().toISOString() }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_TOKEN"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f48d631a-3296-4815-a462-c6c83c3f282a",
      "name": "价格历史记录器",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2128,
        128
      ],
      "parameters": {
        "columns": {
          "value": {
            "Strategy": "={{ $json.pricing_recommendation.strategy_recommendation }}",
            "New_Price": "={{ $json.pricing_recommendation.recommended_price }}",
            "Timestamp": "={{ $json.timestamp }}",
            "Competitor": "={{ $json.market_analysis.competitor }}",
            "Confidence": "={{ $json.pricing_recommendation.confidence_level }}",
            "Product_ID": "={{ $json.product_info.id }}",
            "Session_ID": "={{ $json.session_id }}",
            "Demand_Score": "={{ $json.pricing_recommendation.factor_scores.demand }}",
            "Price_Change": "={{ $json.pricing_recommendation.price_change }}",
            "Product_Name": "={{ $json.product_info.name }}",
            "Market_Context": "={{ $json.market_context.time_of_day + ' - ' + $json.market_context.current_day }}",
            "Previous_Price": "={{ $json.product_info.current_price }}",
            "Revenue_Change": "={{ $json.revenue_projection.revenue_change_estimate }}",
            "Sentiment_Score": "={{ $json.pricing_recommendation.factor_scores.sentiment }}",
            "Change_Percentage": "={{ $json.pricing_recommendation.price_change_percentage }}",
            "Revenue_Projection": "={{ $json.revenue_projection.projected_revenue_estimate }}",
            "Competitor_Avg_Price": "={{ $json.market_analysis.competitor_data.price_statistics?.avg_price || 'N/A' }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Pricing_History"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "1your-pricing-dashboard-sheet-id"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "c033cad3-3efe-4504-9c48-56ffb6efdc0a",
      "name": "收入分析记录器",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2112,
        272
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ new Date().toISOString().split('T')[0] }}",
            "Hour": "={{ new Date().getHours() }}",
            "Product_ID": "={{ $json.product_info.id }}",
            "Session_ID": "={{ $json.session_id }}",
            "Revenue_Impact": "={{ $json.revenue_projection.revenue_change_estimate }}",
            "Inventory_Level": "={{ $json.product_info.inventory_level || 0 }}",
            "Strategy_Applied": "={{ $json.pricing_recommendation.strategy_recommendation }}",
            "Demand_Multiplier": "={{ $json.market_context.demand_multiplier || 1 }}",
            "Price_Sensitivity": "={{ $json.market_analysis.sentiment_data.price_elasticity_indicators?.price_sensitivity_score || 0.5 }}",
            "Optimization_Score": "={{ $json.pricing_recommendation.optimization_score }}",
            "Competitor_Price_Avg": "={{ $json.market_analysis.competitor_data.price_statistics?.avg_price || 0 }}",
            "Current_Revenue_Rate": "={{ $json.revenue_projection.current_revenue_estimate }}",
            "Projected_Revenue_Rate": "={{ $json.revenue_projection.projected_revenue_estimate }}"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Revenue_Analytics"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "1your-revenue-analytics-sheet-id"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "ba6667ca-f603-4a50-a7cd-5242dd8a35f5",
      "name": "价格警报发送器",
      "type": "n8n-nodes-base.slack",
      "position": [
        2144,
        480
      ],
      "parameters": {
        "text": "=💰 **Price Optimization Alert**\n\n📦 **Product**: {{ $json.product_info.name }} ({{ $json.product_info.id }})\n💵 **Price Change**: ${{ $json.product_info.current_price }} → ${{ $json.pricing_recommendation.recommended_price }}\n📈 **Change**: {{ $json.pricing_recommendation.price_change_percentage > 0 ? '+' : '' }}{{ $json.pricing_recommendation.price_change_percentage }}%\n\n🎯 **Strategy**: {{ $json.pricing_recommendation.strategy_recommendation.toUpperCase() }}\n📊 **Confidence**: {{ Math.round($json.pricing_recommendation.confidence_level * 100) }}%\n\n**Market Analysis**:\n• 🏪 Competitor Avg: ${{ $json.market_analysis.competitor_data.price_statistics?.avg_price || 'N/A' }}\n• 📈 Demand Score: {{ Math.round($json.pricing_recommendation.factor_scores.demand * 100) }}/100\n• 💭 Sentiment Score: {{ Math.round($json.pricing_recommendation.factor_scores.sentiment * 100) }}/100\n\n💡 **Revenue Impact**: {{ $json.revenue_projection.revenue_change_estimate > 0 ? '+' : '' }}${{ Math.round($json.revenue_projection.revenue_change_estimate) }}/month",
        "channel": "pricing-alerts",
        "attachments": [],
        "otherOptions": {
          "icon_emoji": ":money_with_wings:"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "092569d1-062b-4065-8fd8-5d4620889402",
      "name": "价格报告发送器",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2320,
        48
      ],
      "webhookId": "db7ac9a0-5d67-48b8-bc71-4349335ee9f1",
      "parameters": {
        "options": {
          "allowUnauthorizedCerts": false
        },
        "subject": "=🎯 Dynamic Pricing Update - {{ $json.product_info.name }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "4b29177c-0f1a-4e04-8f42-e98a24771777",
      "name": "工作流概述",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3136,
        416
      ],
      "parameters": {
        "color": 2,
        "width": 580,
        "height": 656,
        "content": "# 💰 AI 驱动的动态价格优化器"
      },
      "typeVersion": 1
    },
    {
      "id": "c6823f8e-b8c0-4664-a8f1-a41f85875bb1",
      "name": "步骤 1:每小时触发器指南",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3120,
        -832
      ],
      "parameters": {
        "color": 4,
        "width": 584,
        "height": 882,
        "content": "# ⏱️ 步骤 1:每小时价格监控触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "0e01fd2d-66b2-40f3-9a4b-71ef34e5964e",
      "name": "步骤 2:配置处理器",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2400,
        -848
      ],
      "parameters": {
        "width": 524,
        "height": 1016,
        "content": "# 🔧 步骤 2:价格配置处理器"
      },
      "typeVersion": 1
    },
    {
      "id": "795704cb-5998-44d5-a28b-dba4d61ecfa3",
      "name": "步骤 3:任务拆分",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1808,
        -848
      ],
      "parameters": {
        "color": 6,
        "width": 520,
        "height": 972,
        "content": "# 🔄 步骤 3:拆分监控任务"
      },
      "typeVersion": 1
    },
    {
      "id": "a5ac5442-b660-4b05-bfd3-6e1e09599ec6",
      "name": "步骤 4:任务处理",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1232,
        -848
      ],
      "parameters": {
        "width": 520,
        "height": 908,
        "content": "# 🎛️ 步骤 4:任务处理器"
      },
      "typeVersion": 1
    },
    {
      "id": "00f15e33-1fdd-42b0-9ee2-3fab33578d0a",
      "name": "步骤 5-7:AI 抓取网络",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -880
      ],
      "parameters": {
        "color": 3,
        "width": 560,
        "height": 1528,
        "content": "# 🤖 步骤 5-7:多源 AI 抓取网络"
      },
      "typeVersion": 1
    },
    {
      "id": "9ce3e860-67ae-4aab-b9cd-c6269bd454a2",
      "name": "步骤 8:数据合并",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -880
      ],
      "parameters": {
        "color": 5,
        "width": 520,
        "height": 972,
        "content": "# 🔗 步骤 8:合并价格数据"
      },
      "typeVersion": 1
    },
    {
      "id": "4e7939e9-7ce9-494a-b3eb-3196401be13f",
      "name": "步骤 9:优化引擎",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -896
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 1130,
        "content": "# 🧠 步骤 9:价格优化引擎"
      },
      "typeVersion": 1
    },
    {
      "id": "072f6675-ad8c-4817-8cce-809410a2dc5b",
      "name": "步骤 10:价格变更过滤器",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        -896
      ],
      "parameters": {
        "color": 6,
        "width": 520,
        "height": 1010,
        "content": "# 🎯 步骤 10:价格变更过滤器"
      },
      "typeVersion": 1
    },
    {
      "id": "762ffd8e-29a7-4758-a952-806937912878",
      "name": "Steps 11-15: Analytics & Communication",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1872,
        -928
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 1588,
        "content": "# 📊 Steps 11-15: Analytics & Communication\n\n**These Nodes**: Comprehensive tracking, reporting, and team communication system\n\n## Step 11: Price Update API Call\n- **E-commerce Integration**: Direct price updates to your platform\n- **API Authentication**: Secure connection to pricing system\n- **Batch Processing**: Efficient bulk price updates\n- **Error Handling**: Retry logic and failure management\n\n## Steps 12-13: Google Sheets Logging\n- **Pricing History**: Every change logged with full context\n- **Revenue Analytics**: Performance tracking and projections\n- **Trend Analysis**: Historical patterns and insights\n- **Dashboard Integration**: Real-time reporting capabilities\n\n## Step 14: Slack Notifications\n- **Instant Alerts**: Immediate notifications for price changes\n- **Smart Formatting**: Rich context with market analysis\n- **Team Coordination**: Channel-based communication\n- **Performance Metrics**: Summary statistics and trends\n\n## Step 15: Email Reports\n- **Executive Summaries**: HTML-formatted comprehensive reports\n- **Market Intelligence**: Competitor analysis and insights\n- **Revenue Impact**: Financial performance and projections\n- **Strategic Recommendations**: Next steps and opportunities\n\n## Success Tracking\n- **Real-Time Monitoring**: Continuous performance measurement\n- **ROI Analysis**: Revenue impact and optimization effectiveness\n- **Market Position**: Competitive advantage tracking"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c1049f9a-f6ff-4423-aae3-8f7b17f5e238",
  "connections": {
    "Task Processor": {
      "main": [
        [
          {
            "node": "AI Competitor Price Scraper",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Demand Analysis Scraper",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Customer Sentiment Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Pricing Data": {
      "main": [
        [
          {
            "node": "Pricing Optimization Engine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Price Change Filter": {
      "main": [
        [
          {
            "node": "Price Update API Call",
            "type": "main",
            "index": 0
          },
          {
            "node": "Pricing Alert Sender",
            "type": "main",
            "index": 0
          },
          {
            "node": "Pricing Report Sender",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Monitoring Tasks": {
      "main": [
        [
          {
            "node": "Task Processor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Demand Analysis Scraper": {
      "main": [
        [
          {
            "node": "Merge Pricing Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "AI Competitor Price Scraper": {
      "main": [
        [
          {
            "node": "Merge Pricing Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pricing Optimization Engine": {
      "main": [
        [
          {
            "node": "Price Change Filter",
            "type": "main",
            "index": 0
          },
          {
            "node": "Pricing History Logger",
            "type": "main",
            "index": 0
          },
          {
            "node": "Revenue Analytics Logger",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Customer Sentiment Scraper": {
      "main": [
        [
          {
            "node": "Merge Pricing Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Hourly Pricing Monitor Trigger": {
      "main": [
        [
          {
            "node": "Pricing Configuration Processor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pricing Configuration Processor": {
      "main": [
        [
          {
            "node": "Split Monitoring Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
高级
节点数量25
分类2
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流