{
  "name": "Idealo price tracker \u2192 Google Sheets",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "daysInterval": 1,
              "triggerAtHour": 8,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "a1c2e3f4-1001-4b00-9000-000000000001",
      "name": "Every day at 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "notes": "Timezone is Europe/Bucharest (workflow settings). Change the hour to suit the client."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/stippled_starfish~idealo-de/run-sync-get-dataset-items?build=latest&timeout=180",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{APIFY_TOKEN}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"eans\": [\n    \"0195949034572\",\n    \"0195950543650\"\n  ],\n  \"searchQueries\": [\n    \"airpods pro 2\"\n  ],\n  \"country\": \"de\",\n  \"compareCountries\": [\n    \"at\"\n  ],\n  \"maxProductsPerSearch\": 1,\n  \"maxItems\": 5,\n  \"outputFormat\": \"products\",\n  \"proxyConfiguration\": {\n    \"useApifyProxy\": false\n  }\n}",
        "options": {
          "timeout": 180000
        }
      },
      "id": "a1c2e3f4-1002-4b00-9000-000000000002",
      "name": "Run Idealo actor",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        0
      ],
      "retryOnFail": true,
      "maxTries": 2,
      "waitBetweenTries": 5000,
      "notes": "Replace {{APIFY_TOKEN}} with an n8n Header Auth credential (Name = Authorization, Value = Bearer <your Apify token>). Never hard-code the token. The endpoint waits until the run finishes and returns the dataset items. This demo used no proxy."
    },
    {
      "parameters": {
        "jsCode": "// Turn the actor's product rows into one Google Sheets row each.\n// Handles both \"API returned a JSON array as one item\" and already-split items.\nconst raw = $input.all().map(i => i.json);\nlet products = [];\nif (raw.length === 1 && Array.isArray(raw[0])) {\n  products = raw[0];\n} else if (raw.length === 1 && Array.isArray(raw[0].data)) {\n  products = raw[0].data;\n} else if (raw.length === 1 && Array.isArray(raw[0].body)) {\n  products = raw[0].body;\n} else {\n  products = raw;\n}\n\nfunction localDate(iso) {\n  if (!iso) return '';\n  const d = new Date(iso);\n  const parts = new Intl.DateTimeFormat('en-GB', {\n    timeZone: 'Europe/Bucharest',\n    year: 'numeric', month: '2-digit', day: '2-digit',\n    hour: '2-digit', minute: '2-digit', second: '2-digit',\n    hour12: false,\n  }).formatToParts(d);\n  const g = (t) => parts.find(p => p.type === t).value;\n  return `${g('year')}-${g('month')}-${g('day')} ${g('hour')}:${g('minute')}:${g('second')}`;\n}\n\nreturn products\n  .filter(p => p && p.type !== 'not_found')\n  .map(p => {\n    const shop = p.cheapestShop || {};\n    return {\n      json: {\n        product: p.title || '',\n        gtin: p.gtin || '',\n        brand: p.brand || '',\n        cheapest_price: p.lowestPrice ?? '',\n        total_price_with_shipping: p.lowestTotalPrice ?? '',\n        currency: p.currency || '',\n        shop: shop.shopName || '',\n        offer_count: p.offerCount ?? '',\n        country: (p.country || '').toUpperCase(),\n        url: p.productUrl || '',\n        date_europe_bucharest: localDate(p.scrapedAt),\n      },\n    };\n  });\n"
      },
      "id": "a1c2e3f4-1003-4b00-9000-000000000003",
      "name": "Flatten products",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "resource": "sheet",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Products",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Product": "={{ $json.product }}",
            "GTIN": "={{ $json.gtin }}",
            "Brand": "={{ $json.brand }}",
            "Cheapest price": "={{ $json.cheapest_price }}",
            "Total price (incl. shipping)": "={{ $json.total_price_with_shipping }}",
            "Currency": "={{ $json.currency }}",
            "Shop": "={{ $json.shop }}",
            "Offer count": "={{ $json.offer_count }}",
            "Country": "={{ $json.country }}",
            "URL": "={{ $json.url }}",
            "Date (Europe/Bucharest)": "={{ $json.date_europe_bucharest }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Product",
              "displayName": "Product",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "GTIN",
              "displayName": "GTIN",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Brand",
              "displayName": "Brand",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Cheapest price",
              "displayName": "Cheapest price",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "Total price (incl. shipping)",
              "displayName": "Total price (incl. shipping)",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "displayName": "Currency",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Shop",
              "displayName": "Shop",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Offer count",
              "displayName": "Offer count",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country",
              "displayName": "Country",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "URL",
              "displayName": "URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Date (Europe/Bucharest)",
              "displayName": "Date (Europe/Bucharest)",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {
          "cellFormat": "USER_ENTERED",
          "useAppend": true
        }
      },
      "id": "a1c2e3f4-1004-4b00-9000-000000000004",
      "name": "Append to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        780,
        0
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "YOUR_GOOGLE_SHEETS_CREDENTIAL_ID",
          "name": "Google Sheets account"
        }
      },
      "notes": "Create a sheet named Products with the header row from README.md, then paste its spreadsheet ID in place of YOUR_GOOGLE_SHEET_ID. Connect your own Google Sheets OAuth credential."
    }
  ],
  "connections": {
    "Every day at 08:00": {
      "main": [
        [
          {
            "node": "Run Idealo actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Idealo actor": {
      "main": [
        [
          {
            "node": "Flatten products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flatten products": {
      "main": [
        [
          {
            "node": "Append to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Bucharest"
  },
  "pinData": {},
  "meta": {
    "instanceId": "REPLACE_ME"
  }
}
