{
  "id": "CompetitorPriceMonitoring2024",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "name": "Competitor Price Monitoring",
  "tags": [
    "price-monitoring",
    "competitor-analysis",
    "e-commerce",
    "google-sheets",
    "automation",
    "alerts"
  ],
  "nodes": [
    {
      "id": "daily-price-trigger",
      "name": "Daily Price Check Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        400,
        700
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "manual-price-trigger",
      "name": "Manual Price Check Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        400,
        500
      ],
      "parameters": {
        "path": "price-check-webhook",
        "options": {
          "noResponseBody": false
        },
        "httpMethod": "GET"
      },
      "typeVersion": 1.1
    },
    {
      "id": "amazon-scraper",
      "name": "Amazon Price Scraper",
      "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 Price Scraper",
      "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 Price Scraper",
      "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 Price Data Extractor",
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "price-analysis-code",
      "name": "Price Analysis & Intelligence",
      "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 Price Log",
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "price-alert-filter",
      "name": "Price Change Alert Filter",
      "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 Price Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        2000,
        400
      ],
      "parameters": {
        "text": "\ud83d\udcb0 **PRICE ALERT** \ud83d\udcb0\n\n**{{ $json.product_name }}** by {{ $json.brand }}\n\n\ud83d\udcb8 **Current Price**: ${{ $json.current_price }}\n{% if $json.original_price %}\ud83c\udff7\ufe0f **Original Price**: ${{ $json.original_price }}\n\u2728 **Discount**: {{ $json.discount_percentage }}% OFF{% endif %}\n\n**Source**: {{ $json.source }}\n{% if $json.rating %}\u2b50 **Rating**: {{ $json.rating }}/5 ({{ $json.review_count }} reviews){% endif %}\n\ud83d\udce6 **Availability**: {{ $json.availability }}\n\n**Why this matters:**\n{% if $json.change_significance == 'high' %}\ud83d\udea8 **SIGNIFICANT PRICE DROP** - This is a major price change!\n{% elif $json.discount_percentage >= 25 %}\ud83d\udd25 **HUGE DISCOUNT** - Over 25% off!\n{% elif $json.is_on_sale %}\ud83d\udcaf **ON SALE** - Great time to buy!\n{% endif %}\n\n**Market Intelligence:**\n\ud83d\udcca Market Position: {{ $json.market_position | title }}\n\ud83c\udfaf Customer Satisfaction: {{ $json.customer_satisfaction | title }}\n\ud83d\udc8e Value Score: {{ $json.value_score }}/10\n\n\ud83d\uded2 [**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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "sticky-triggers",
      "name": "Sticky Note - Triggers",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        280,
        250
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# Step 1: Price Monitoring Triggers \u23f0\n\nDual trigger system for comprehensive price tracking:\n\n## Daily Schedule Trigger\n- **Frequency**: Every 24 hours\n- **Purpose**: Regular automated price monitoring\n- **Timing**: Customizable (recommended: early morning)\n\n## Manual Webhook Trigger  \n- **Purpose**: On-demand price checks\n- **Usage**: External systems or manual triggers\n- **Endpoint**: `/price-check-webhook`\n\n## Benefits\n- Consistent daily monitoring\n- Flexible manual triggers\n- Real-time and scheduled checks\n- Comprehensive coverage"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-scraping",
      "name": "Sticky Note - Scraping",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# Step 2: Multi-Platform Scraping \ud83d\uded2\n\nParallel price scraping from major retailers:\n\n## Covered Platforms\n- **Amazon**: Largest product selection\n- **Best Buy**: Electronics specialist\n- **Target**: Retail competitor pricing\n\n## Scraping Features\n- Custom User-Agent headers\n- Parallel processing for speed\n- Error handling and retries\n- Anti-detection measures\n\n## Extensible Design\n- Easy to add new retailers\n- Category-specific searches\n- Custom search parameters\n- Rate limiting compliance"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-ai-extraction",
      "name": "Sticky Note - AI Extraction",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# Step 3: AI Price Data Extraction \ud83e\udd16\n\nScrapeGraphAI intelligently extracts product pricing:\n\n## Smart Extraction\n- **Price Detection**: Current and original prices\n- **Product Details**: Names, brands, models\n- **Quality Metrics**: Ratings and reviews\n- **Availability**: Stock status and shipping\n\n## Rich Data Points\n- Discount percentages\n- Product specifications\n- Customer ratings\n- Shipping information\n- Prime eligibility\n- Product images\n\n## AI Advantages\n- Adapts to different site layouts\n- Handles dynamic content\n- High accuracy extraction\n- Structured JSON output"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-analysis",
      "name": "Sticky Note - Analysis",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1480,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# Step 4: Price Analysis & Intelligence \ud83d\udcca\n\nAdvanced analysis of extracted pricing data:\n\n## Price Change Detection\n- **Trend Analysis**: Up, down, or stable\n- **Significance**: High, moderate, or low impact\n- **Alert Triggers**: Configurable thresholds\n- **Historical Comparison**: vs previous prices\n\n## Competitive Intelligence\n- **Market Position**: Budget, mid-range, premium\n- **Value Scoring**: Price vs quality ratio\n- **Brand Strength**: Recognition and trust\n- **Customer Satisfaction**: Review analysis\n\n## Smart Prioritization\n- High: Significant price drops\n- Medium: Regular sales and promotions\n- Low: Minor fluctuations"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-storage-alerts",
      "name": "Sticky Note - Storage & Alerts",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1880,
        150
      ],
      "parameters": {
        "color": 4,
        "width": 350,
        "height": 450,
        "content": "# Step 5: Data Storage & Alerts \ud83d\udcbe\n\nStructured logging and intelligent notifications:\n\n## Google Sheets Integration\n- **Complete Price History**: All tracked products\n- **Rich Metadata**: Analysis results and insights\n- **Easy Access**: Web interface and formulas\n- **Export Ready**: Charts and pivot tables\n\n## Smart Slack Alerts\n- **Significant Price Drops**: Immediate notifications\n- **High Discounts**: 20%+ savings alerts\n- **New Low Prices**: Historical price tracking\n- **Rich Formatting**: Actionable information\n\n## Analytics Features\n- Historical price trends\n- Competitor comparison\n- Market position tracking\n- ROI on price monitoring"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "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
          }
        ]
      ]
    }
  }
}