{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "469eec11-a949-40e2-bddd-410a17919fb8",
      "name": "HTML",
      "type": "n8n-nodes-base.html",
      "position": [
        880,
        48
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "dataPropertyName": "html",
        "extractionValues": {
          "values": [
            {
              "key": "body",
              "cssSelector": "body"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "25d9c998-7fb7-4491-b375-3ba0fb3c4368",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -144,
        32
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QAMgjU-zPxSzc7sheLnOreGTuwzHuETu10hBV1XOV7E/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1QAMgjU-zPxSzc7sheLnOreGTuwzHuETu10hBV1XOV7E",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QAMgjU-zPxSzc7sheLnOreGTuwzHuETu10hBV1XOV7E/edit?usp=drivesdk",
          "cachedResultName": "Price monitoring"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "12d0d284-5fd2-47e4-9853-4437e63ddf38",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        64,
        32
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "794f84fb-5780-4f7b-9974-f269fc9b8a55",
      "name": "Code in JavaScript1",
      "type": "n8n-nodes-base.code",
      "position": [
        592,
        48
      ],
      "parameters": {
        "jsCode": "// Map HTTP Request output to HTML node expected format\nreturn items.map(item => {\n  return {\n    json: {\n      html: item.json.data, // move HTML content to 'html'\n      link: item.json.link, // keep your link if needed\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "16deac07-4ff5-49a9-b459-f3ef2b70a6e9",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1088,
        48
      ],
      "parameters": {
        "text": "=extract the price and name of the product from this:|\n {{ $json.body }}\n\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "7258880c-0438-47eb-a2c6-d01cb9c9c34d",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1088,
        288
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "77bbfb54-7dcd-4ab4-87f4-34ad0a083717",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1808,
        48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1bd05628-422c-44da-8f1d-6e2497cff2c4",
              "operator": {
                "type": "number",
                "operation": "lte"
              },
              "leftValue": "={{ $json.price }}",
              "rightValue": "={{ $('Get row(s) in sheet').item.json['Desired price'] }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "075f2f65-d305-4d54-8e00-ce0e1760f0a5",
      "name": "Code in JavaScript2",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        48
      ],
      "parameters": {
        "jsCode": "const text = $json.output;\n\nconst nameMatch = text.match(/Product Name:\\*\\*\\s*(.*)/);\nconst priceMatch = text.match(/Price:\\*\\*\\s*Rs\\.?([\\d,\\.]+)/);\n\nlet name = nameMatch ? nameMatch[1].trim() : null;\nlet price = priceMatch ? priceMatch[1].replace(/,/g, \"\") : null;\n\nreturn [\n  {\n    json: {\n      name: name,\n      price: price ? Number(price) : null\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5912b2c0-4fb4-49a2-8c16-33a1de907759",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2112,
        32
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Product price is now equal to your desired price: {{ $('Get row(s) in sheet').item.json['Desired price'] }}",
        "options": {},
        "subject": "\\desired price is equal"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b03d7a09-354e-4540-892d-64f75e5b974e",
      "name": "Decodo",
      "type": "@decodo/n8n-nodes-decodo.decodo",
      "position": [
        352,
        48
      ],
      "parameters": {},
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "b9f911c4-21bd-4f2e-9361-0c05730b954f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        -384
      ],
      "parameters": {
        "width": 1424,
        "height": 384,
        "content": "\n\n## How it works:\nThis workflow monitors prices by pulling URLs from a Google Sheet and processing them in a loop. It uses the Decodo node for data handling. JavaScript formats data for the HTML node. An AI Agent, powered by Google Gemini, analyzes the full page content to extract the product name and price. The workflow compares the current price against the \"Desired Price\" from the sheet and sends a Gmail notification if a match or price drop is found.\n\n\n## Setup Steps\n1. Google Sheets: Connect the Google Sheets account and select the \"Price monitoring\" document. Ensure it has columns for the product link and \"Desired price.\"\n2. Decodo Node: Configure the Decodo node to process the input from the loop. This node acts as the primary data bridge before the HTML extraction.\n3. AI Configuration: Ensure the Google Gemini API credentials are active in the Chat Model node. The agent is prompted to find \"price\" and \"name\" specifically.\n4. Logic Check: The If node is set to \"Less Than or Equal (<=)\". It compares the AI's extracted price with the value in the Google Sheet row.\n5. Gmail: Authorize Gmail to send alerts to the recipient specified in the \"Send a message\" node.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "afb329d2-539a-4608-b456-273ebd8a369f",
      "name": "Daily Run",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -368,
        32
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e06ca996-474c-4129-b223-432d17a40390",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 688,
        "height": 224,
        "content": "\n## Data Sourcing & Iteration\nThis section manages the workflow timing and retrieves the target product list from Google Sheets. The Loop Over Items node ensures each URL is processed individually to prevent data collisions.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "257ab95a-7eba-4b4b-92cb-4fa85cd4a3e4",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        112
      ],
      "parameters": {
        "color": 7,
        "width": 752,
        "height": 272,
        "content": "\n\n\n\n\n\n\n\n\n\n\n## Raw Content Extraction & Prep\nThis zone handles the raw data retrieval. The Decodo node processes the input, followed by a JavaScript node that cleans the data for the HTML node. We extract the full <body> here to ensure the AI has the complete context of the page."
      },
      "typeVersion": 1
    },
    {
      "id": "3b3b0a24-2d78-4ffc-b117-9b3eefd9fd3a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 448,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## AI Intelligence & Data Parsing\nThis is the core of the workflow. The AI Agent uses Google Gemini to analyze the HTML text. It is prompted to find and return the Product Name and Current Price, transforming web data into usable information.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7f9dff5f-7ed3-40f4-8392-170bccd77e52",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1552,
        80
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 256,
        "content": "\n\n\n\n\n\n## Validation & Alerting Logic\n\nThis is the final stage. A Regex script extracts the numerical price from the AI\u2019s response. The If Node compares this to the \"Desired Price.\" If the price matches, a Gmail alert is triggered; otherwise, the loop continues."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decodo": {
      "main": [
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code in JavaScript2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Run": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Decodo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript2": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}