{
  "id": "9yDOkFUPxgUrmtmL",
  "name": "Smart Price Monitor with AI Prediction v2",
  "tags": [],
  "nodes": [
    {
      "id": "a2c0086c-f856-46c2-818e-d4f1c2b00bd9",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2864,
        -128
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8533cf84-9cb4-42b0-8f6e-02b91d6ad1d7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3696,
        -704
      ],
      "parameters": {
        "width": 684,
        "height": 516,
        "content": "## Smart Price Monitor with AI\n\n**How it works**\n1. Fetches products from your Google Sheets\n2. Scrapes current Amazon prices\n3. Tracks price history (60 days)\n4. AI analyzes trends using GPT-4o-mini\n5. Sends email alerts for buying opportunities\n6. Updates tracking sheet with recommendations\n\n**Setup**\n\u2611 Connect Google Sheets OAuth2\n\u2611 Connect Gmail OAuth2\n\u2611 Add OpenAI API key\n\u2611 Create two sheets: \"Products\" and \"Price History\"\n\u2611 Replace placeholder IDs with your Google Sheets document ID\n\n**Customize**\n\u2022 Change schedule trigger for automation\n\u2022 Adjust CSS selector for non-Amazon sites\n\u2022 Modify AI model (gpt-4o-mini \u2194 gpt-4o) for a better analysis"
      },
      "typeVersion": 1
    },
    {
      "id": "9f5353ae-948a-4ed0-bf13-d7b0ec9b8a2a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2928,
        -704
      ],
      "parameters": {
        "color": 7,
        "width": 596,
        "height": 768,
        "content": "## Section 1. Get products to monitor\n\n### Purpose: \nGets the urls products from your google sheet product.\n\n### What it does:\n- Connects to your Google Sheets document\n- Reads all rows from the \"Products\" sheet\n- Each row contains: Product URL, Name, Target Price, and your Email\n\n### Required columns in your sheet:\n- URL_Product: Amazon product link\n- Product_Name: Product description\n- Target_Price: Your desired purchase price\n- User_Email: Email for notifications"
      },
      "typeVersion": 1
    },
    {
      "id": "99dcb462-5727-446f-84e3-905e7c624705",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2288,
        -464
      ],
      "parameters": {
        "color": 6,
        "width": 684,
        "height": 528,
        "content": "## Section 2. Fetch & extract price\n\n### **Purpose**:\nExtract the URL that you want to monitor in Amazon\n\n### **What it does:**\n- Visits the product URL from your sheet\n- Searches the HTML for the price element\n- Extracts just the price number\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5eab55ab-c20d-4804-a981-f5e881026799",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        -448
      ],
      "parameters": {
        "color": 7,
        "width": 692,
        "height": 512,
        "content": "## 3. Track price history\n\n### Purpose: \nRetrieves past price records for this product and records current price in the history sheet\n\n### What it does:\n- Searches \"Price History\" sheet for this product's URL\n- Gets all previous price checks (up to 60 days)\n- Checks if price was already recorded today\n- Adds new row to \"Price History\" sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "b1120fb3-d5ac-4845-8c16-97bb0c96c100",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -544
      ],
      "parameters": {
        "color": 6,
        "width": 876,
        "height": 608,
        "content": "## 4. AI analysis: is the perfect price for me?\n\n### Purpose:\nCalculates statistics and formats data for AI analysis, makes recomendations and creates visual price history chart\n\n### What it does:\n- Calculates 60-day average price\n- Finds minimum and maximum prices\n- Sends price data to OpenAI's GPT model\n- AI analyzes trends, patterns, and statistics\n- Predicted Trend: RISING/FALLING/STABLE\n- Generates buy/wait recommendation\n- Uses QuickChart.io API to generate chart\n- Shows last 30 days of price data\n- Displays your target price as reference line\n- Creates chart URL for email"
      },
      "typeVersion": 1
    },
    {
      "id": "d2f6a4a6-8417-45fe-8ff1-fc83ec269ca0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -688
      ],
      "parameters": {
        "color": 7,
        "width": 740,
        "height": 752,
        "content": "## 5. Notify & update: let me now if I should by the product\n\n### Purpose:\nNotifies you of buying opportunity and records latest analysis in your tracking sheet\n\n### What it does:\n- Sends detailed email to your address\n- Includes AI recommendation and analysis\n- Updates the product row in \"Products\" sheet with latest price check results\n- Saves AI recommendations and scores\n\n### Updated fields:\n- Last_Price: Current price found\n- Last_Check: When check was performed\n- AI_Recommendation: BUY or WAIT\n- AI_Confidence: Confidence percentage\n- Urgency_Score: Deal urgency (0-100)\n- Predicted_Trend: Price direction\n- Should_Buy: Yes/No decision"
      },
      "typeVersion": 1
    },
    {
      "id": "6253563b-4b22-4475-9bc9-3e4a3446a417",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2704,
        -288
      ],
      "parameters": {
        "color": 3,
        "width": 308,
        "height": 348,
        "content": "\u26a0\ufe0f **Replace placeholder IDs**\n\nUpdate `YOUR_GOOGLE_SHEETS_DOCUMENT_ID` in all Google Sheets nodes with your actual document ID."
      },
      "typeVersion": 1
    },
    {
      "id": "ff73629f-2c1a-462c-b32d-729d600e7779",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1856,
        -256
      ],
      "parameters": {
        "color": 3,
        "width": 224,
        "height": 300,
        "content": "\u26a0\ufe0f **CSS Selector**\n\nFor non-Amazon sites, update `.a-price-whole` selector using browser DevTools."
      },
      "typeVersion": 1
    },
    {
      "id": "5b467790-afcc-46e8-a7f8-1ce628a48837",
      "name": "Get Products",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -2592,
        -128
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 807909088,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=807909088",
          "cachedResultName": "Products_Sheet_Template"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit?usp=drivesdk",
          "cachedResultName": "Products_Sheet_Template"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "acfc302f-9350-4114-ae25-97b7c34e5078",
      "name": "Loop Products",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -2256,
        -128
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "6c2ed912-8ba1-4e4a-884d-73382595da90",
      "name": "Fetch Product Page",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2032,
        -112
      ],
      "parameters": {
        "url": "={{ $json.URL_Product }}",
        "options": {
          "timeout": 30000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3010b968-8de8-49ec-8c14-9f545c0d4452",
      "name": "Get Price History",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1488,
        -112
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $('Loop Products').item.json.URL_Product }}",
              "lookupColumn": "URL_Product"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 877762684,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=877762684",
          "cachedResultName": "Price_History_Sheet_Template"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit?usp=drivesdk",
          "cachedResultName": "Price_History_Sheet_Template"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "43183e68-bb8c-490c-ad6b-d51e3e31cf69",
      "name": "Check Duplicate",
      "type": "n8n-nodes-base.code",
      "position": [
        -1264,
        -112
      ],
      "parameters": {
        "jsCode": "// Get current data\nconst productUrl = $('Get Products').first().json.URL_Product;\nconst currentPrice = parseFloat($('Extract Price').first().json.price.replace(/[$,]/g, ''));\nconst today = $now.toFormat('yyyy-MM-dd');\nconst timestamp = $now.toISO();\n\n// Get existing history for this product today\nconst historyItems = $('Get Price History').all();\n\n// Check if there's already a record for this product today\nconst existingTodayRecord = historyItems.find(item => \n  item.json.URL_Product === productUrl && \n  item.json.Date === today\n);\n\n// Prepare the data to return (will be used by next node to update sheet)\nreturn {\n  url_product: productUrl,\n  price: currentPrice,\n  date: today,\n  timestamp: timestamp,\n  should_update: !!existingTodayRecord,\n  row_number: existingTodayRecord ? existingTodayRecord.json.row_number : null\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "c152c0d6-8822-4521-828d-b36bb8d6c5c3",
      "name": "Add to History",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1040,
        -112
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $now }}",
            "Price": "={{ $('Extract Price').first().json.price }}",
            "Timestamp": "={{ $now }}",
            "URL_Product": "={{ $('Loop Products').first().json.URL_Product }}"
          },
          "schema": [
            {
              "id": "URL_Product",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "URL_Product",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 877762684,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=877762684",
          "cachedResultName": "Price_History_Sheet_Template"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit?usp=drivesdk",
          "cachedResultName": "Price_History_Sheet_Template"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ad0d7c05-0efd-44e6-943c-35bae37f1546",
      "name": "Prepare AI Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -752,
        -112
      ],
      "parameters": {
        "jsCode": "// Get current price\nconst currentPriceText = $('Extract Price').first().json.price;\nconst currentPrice = parseFloat(currentPriceText.replace(/[$,]/g, ''));\n\n// Get price history (last 60 days)\nconst historyItems = $('Get Price History').all();\n\n// Sort by date descending and get last 60 entries\nconst priceHistory = historyItems\n  .map(item => ({\n    date: item.json.Date,\n    price: parseFloat(item.json.Price)\n  }))\n  .sort((a, b) => new Date(b.date) - new Date(a.date))\n  .slice(0, 60);\n\n// Calculate statistics\nconst prices = priceHistory.map(h => h.price);\nconst avgPrice = prices.length > 0 ? prices.reduce((a, b) => a + b, 0) / prices.length : currentPrice;\nconst minPrice = prices.length > 0 ? Math.min(...prices) : currentPrice;\nconst maxPrice = prices.length > 0 ? Math.max(...prices) : currentPrice;\n\n// Prepare data for AI\nconst last30Days = priceHistory.slice(0, 30);\nconst priceData = last30Days.map(h => `${h.date}: $${h.price.toFixed(2)}`).join('\\n');\n\nconst targetPrice = $('Get Products').first().json.Target_Price;\n\nreturn {\n  current_price: currentPrice,\n  target_price: targetPrice,\n  avg_price_60d: avgPrice.toFixed(2),\n  min_price_60d: minPrice.toFixed(2),\n  max_price_60d: maxPrice.toFixed(2),\n  history_length: priceHistory.length,\n  price_data_text: priceData,\n  full_history: priceHistory\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "9fc0ce09-8f88-499b-a322-09d761b374b6",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -544,
        -112
      ],
      "parameters": {
        "text": "=Analyze this product price history and tell me if I should buy now or wait.\n\nCurrent Price: {{ $json.current_price }}  \nTarget Price: {{ $json.target_price }} \nAverage (60 days): {{ $json.avg_price_60d }}\nMin (60 days): {{ $json.min_price_60d }} \nMax (60 days): {{ $json.max_price_60d }}\nPrice History (last 30 days):\n{{ $json.price_data_text }}\n\nProvide your analysis in JSON format with: recommendation, confidence, reason, urgency_score, predicted_trend.",
        "options": {
          "systemMessage": "You are a price prediction expert. Analyze price history and provide buying recommendations. Always respond in valid JSON format with these exact fields: recommendation (BUY/WAIT), confidence (0-100), reason (brief explanation), urgency_score (0-100), predicted_trend (RISING/FALLING/STABLE)."
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "080b40f3-e02a-4f2e-8f15-03bd8c146e72",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -544,
        96
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "759fa1da-ac35-41b4-8ab9-759079bc259f",
      "name": "Parse AI Response",
      "type": "n8n-nodes-base.code",
      "position": [
        -256,
        -112
      ],
      "parameters": {
        "jsCode": "// Parse AI response\nlet aiResponse;\ntry {\n  const content =  $input.first().json.output || $input.first().json.text || '';\n  // Try to extract JSON if wrapped in markdown\n  const jsonMatch = content.match(/```json\\s*([\\s\\S]*?)```/) || content.match(/({[\\s\\S]*})/);\n  const jsonStr = jsonMatch ? jsonMatch[1] : content;\n  aiResponse = JSON.parse(jsonStr.trim());\n} catch (error) {\n  // Fallback if parsing fails\n  aiResponse = {\n    recommendation: 'WAIT',\n    confidence: 50,\n    reason: 'Unable to parse AI response',\n    urgency_score: 50,\n    predicted_trend: 'STABLE'\n  };\n}\n\n// Get data from Loop context\nconst loopItem = $('Loop Products').first().json;\nconst productUrl = loopItem.URL_Product;\nconst productName = loopItem.Product_Name || 'Product';\nconst userEmail = loopItem.User_Email;\nconst targetPrice = loopItem.Target_Price;\n\n// Get analysis data\nconst analysisData = $('Prepare AI Data').item.json;\nconst currentPrice = analysisData.current_price;\nconst avgPrice = analysisData.avg_price_60d;\nconst minPrice = analysisData.min_price_60d;\nconst maxPrice = analysisData.max_price_60d;\nconst priceHistory = analysisData.full_history;\n\n// Determine if should buy\nconst shouldBuy = aiResponse.recommendation === 'BUY' && currentPrice <= targetPrice;\n\n// Prepare chart data\nconst chartData = priceHistory.slice(0, 30).reverse();\nconst chartLabels = chartData.map(h => h.date);\nconst chartPrices = chartData.map(h => h.price);\n\nreturn {\n  product_url: productUrl,\n  product_name: productName,\n  user_email: userEmail,\n  current_price: currentPrice,\n  target_price: targetPrice,\n  avg_price: avgPrice,\n  min_price: minPrice,\n  max_price: maxPrice,\n  ai_recommendation: aiResponse.recommendation,\n  ai_confidence: aiResponse.confidence,\n  ai_reason: aiResponse.reason,\n  urgency_score: aiResponse.urgency_score,\n  predicted_trend: aiResponse.predicted_trend,\n  should_buy: shouldBuy,\n  chart_labels: chartLabels,\n  chart_prices: chartPrices\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "8f078b55-0694-4edc-8a4b-faddd0ee9f83",
      "name": "Generate Chart",
      "type": "n8n-nodes-base.code",
      "position": [
        -80,
        -112
      ],
      "parameters": {
        "jsCode": "// Generate QuickChart.io URL for price history chart\nconst labels = $json.chart_labels;\nconst prices = $json.chart_prices;\nconst currentPrice = $json.current_price;\nconst targetPrice = $json.target_price;\n\nconst chartConfig = {\n  type: 'line',\n  data: {\n    labels: labels,\n    datasets: [\n      {\n        label: 'Price History',\n        data: prices,\n        borderColor: 'rgb(75, 192, 192)',\n        backgroundColor: 'rgba(75, 192, 192, 0.2)',\n        tension: 0.1,\n        fill: true\n      },\n      {\n        label: 'Target Price',\n        data: Array(labels.length).fill(targetPrice),\n        borderColor: 'rgb(255, 99, 132)',\n        borderDash: [5, 5],\n        fill: false,\n        pointRadius: 0\n      }\n    ]\n  },\n  options: {\n    title: {\n      display: true,\n      text: 'Price History (Last 30 Days)'\n    },\n    scales: {\n      yAxes: [{\n        ticks: {\n          callback: function(value) {\n            return '$' + value.toFixed(2);\n          }\n        }\n      }]\n    }\n  }\n};\n\nconst encodedConfig = encodeURIComponent(JSON.stringify(chartConfig));\nconst chartUrl = `https://quickchart.io/chart?c=${encodedConfig}&width=600&height=300`;\n\nreturn {\n  ...($json),\n  chart_url: chartUrl\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "80e87ac8-1be3-4eef-8e7c-e13f09868bd3",
      "name": "Should Buy?",
      "type": "n8n-nodes-base.if",
      "position": [
        144,
        -112
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "should-buy-condition",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.should_buy }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "677c3ae3-52d0-4fcb-97d8-5671a176d1b2",
      "name": "Send Email Alert",
      "type": "n8n-nodes-base.gmail",
      "position": [
        400,
        -208
      ],
      "parameters": {
        "sendTo": "={{ $json.user_email }}",
        "message": "=<h2>Smart Price Monitor - AI Recommendation</h2>\n\n<p><strong>Product:</strong> <a href=\"{{ $json.product_url }}\">{{ $json.product_name }}</a></p>\n\n<h3>\ud83d\udcca Current Analysis</h3>\n<ul>\n  <li><strong>Current Price:</strong> ${{ $json.current_price }}</li>\n  <li><strong>Your Target:</strong> ${{ $json.target_price }}</li>\n  <li><strong>60-Day Average:</strong> ${{ $json.avg_price }}</li>\n  <li><strong>60-Day Min:</strong> ${{ $json.min_price }}</li>\n  <li><strong>60-Day Max:</strong> ${{ $json.max_price }}</li>\n</ul>\n\n<h3>\ud83e\udd16 AI Recommendation</h3>\n<ul>\n  <li><strong>Action:</strong> {{ $json.ai_recommendation }}</li>\n  <li><strong>Confidence:</strong> {{ $json.ai_confidence }}%</li>\n  <li><strong>Urgency Score:</strong> {{ $json.urgency_score }}/100</li>\n  <li><strong>Predicted Trend:</strong> {{ $json.predicted_trend }}</li>\n  <li><strong>Reason:</strong> {{ $json.ai_reason }}</li>\n</ul>\n\n<h3>\ud83d\udcc8 Price History Chart</h3>\n<p><img src=\"{{ $json.chart_url }}\" alt=\"Price History Chart\" width=\"600\"></p>\n\n<p><em>This analysis is based on historical price data and AI prediction. Always verify current price before purchasing.</em></p>",
        "options": {
          "appendAttribution": false
        },
        "subject": "=\ud83c\udfaf AI Recommends: {{ $json.ai_recommendation }} - {{ $json.product_name }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "665cad5b-6397-4427-90ab-4aae1789d93e",
      "name": "Update Products Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        640,
        -96
      ],
      "parameters": {
        "columns": {
          "value": {
            "Last_Check": "={{ $now.toISO() }}",
            "Last_Price": "={{ $('Parse AI Response').item.json.current_price }}",
            "Should_Buy": "={{ $('Parse AI Response').item.json.should_buy }}",
            "User_Email": "={{ $('Parse AI Response').item.json.user_email }}",
            "row_number": 0,
            "URL_Product": "={{ $('Parse AI Response').item.json.product_url }}",
            "Product_Name": "={{ $('Parse AI Response').item.json.product_name }}",
            "Target_Price": "={{ $('Parse AI Response').item.json.target_price }}",
            "AI_Confidence": "={{ $('Parse AI Response').item.json.ai_confidence }}",
            "Urgency_Score": "={{ $('Parse AI Response').item.json.urgency_score }}",
            "Predicted_Trend": "={{ $('Parse AI Response').item.json.predicted_trend }}",
            "AI_Recommendation": "={{ $('Parse AI Response').item.json.ai_recommendation }}"
          },
          "schema": [
            {
              "id": "URL_Product",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "URL_Product",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product_Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product_Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Target_Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Target_Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "User_Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "User_Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last_Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Last_Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last_Check",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Last_Check",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "AI_Recommendation",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "AI_Recommendation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "AI_Confidence",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "AI_Confidence",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Urgency_Score",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Urgency_Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Predicted_Trend",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Predicted_Trend",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Should_Buy",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Should_Buy",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "URL_Product"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 807909088,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=807909088",
          "cachedResultName": "Products_Sheet_Template"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit?usp=drivesdk",
          "cachedResultName": "Products_Sheet_Template"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e253c9d4-98ef-4455-b238-389ff96ce2be",
      "name": "Extract Price",
      "type": "n8n-nodes-base.html",
      "position": [
        -1792,
        -112
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "price",
              "cssSelector": ".a-price-whole"
            }
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6f5c108f-7750-4aed-a2c3-474a89101202",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Should Buy?": {
      "main": [
        [
          {
            "node": "Send Email Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Products Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Products": {
      "main": [
        [
          {
            "node": "Loop Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Price": {
      "main": [
        [
          {
            "node": "Get Price History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Products": {
      "main": [
        [],
        [
          {
            "node": "Fetch Product Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to History": {
      "main": [
        [
          {
            "node": "Prepare AI Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Chart": {
      "main": [
        [
          {
            "node": "Should Buy?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Get Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Duplicate": {
      "main": [
        [
          {
            "node": "Add to History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare AI Data": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Alert": {
      "main": [
        [
          {
            "node": "Update Products Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Price History": {
      "main": [
        [
          {
            "node": "Check Duplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Generate Chart",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Product Page": {
      "main": [
        [
          {
            "node": "Extract Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Products Sheet": {
      "main": [
        [
          {
            "node": "Loop Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}