{
  "name": "TrendTrack — Shop Discovery → Notion candidates",
  "nodes": [
    {
      "parameters": {},
      "id": "3d461c06-0ba8-4e25-9198-ed32d3046c92",
      "name": "Run Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [240, 304]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "categorySearch",
              "value": "beauty",
              "type": "string"
            },
            {
              "id": "2",
              "name": "country",
              "value": "FR",
              "type": "string"
            },
            {
              "id": "3",
              "name": "minActiveAds",
              "value": 10,
              "type": "number"
            },
            {
              "id": "4",
              "name": "limit",
              "value": 50,
              "type": "number"
            },
            {
              "id": "5",
              "name": "notionDatabaseId",
              "value": "YOUR_SHOP_CANDIDATES_DB",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a45ba18d-33bf-49a6-88a6-39622d91a249",
      "name": "Set Parameters",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [464, 304]
    },
    {
      "parameters": {
        "url": "https://api.trendtrack.io/v1/facets/categories",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "search",
              "value": "={{ $json.categorySearch }}"
            },
            {
              "name": "limit",
              "value": "1"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $env.TRENDTRACK_API_KEY }}"
            }
          ]
        },
        "options": {}
      },
      "id": "c81a6162-80e3-451b-9366-13c6a43d3e2b",
      "name": "Resolve Category",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [688, 304]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "1",
              "leftValue": "={{ ($json.data || []).length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "3334a3fb-3c32-4245-b71a-67589d3e1c38",
      "name": "Has Category Match",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.3,
      "position": [880, 304]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.trendtrack.io/v1/shops/query",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $env.TRENDTRACK_API_KEY }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ googleCategoryIds: [$json.data[0].id], mainMarketCountries: [$('Set Parameters').first().json.country], minActiveAds: $('Set Parameters').first().json.minActiveAds, adsTimePeriod: 'last7d', sortBy: 'monthlyVisits', order: 'desc', limit: $('Set Parameters').first().json.limit }) }}",
        "options": {}
      },
      "id": "867befe0-b304-43ca-9b47-0223f3d4aa98",
      "name": "Query Shops",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [1104, 304]
    },
    {
      "parameters": {
        "fieldToSplitOut": "data",
        "options": {}
      },
      "id": "253473f6-1f0c-43bf-8dcc-26f8f31b310c",
      "name": "Split Shops",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [1328, 304]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "title",
              "value": "={{ $json.name || $json.domain }}",
              "type": "string"
            },
            {
              "id": "2",
              "name": "domain",
              "value": "={{ $json.domain }}",
              "type": "string"
            },
            {
              "id": "3",
              "name": "shopUrl",
              "value": "={{ \"https://\" + $json.domain }}",
              "type": "string"
            },
            {
              "id": "4",
              "name": "monthlyVisits",
              "value": "={{ $json.traffic?.monthlyVisits ?? 0 }}",
              "type": "number"
            },
            {
              "id": "5",
              "name": "activeAds",
              "value": "={{ $json.advertising?.activeAds ?? 0 }}",
              "type": "number"
            },
            {
              "id": "6",
              "name": "country",
              "value": "={{ $json.profile?.countryCode || $('Set Parameters').first().json.country }}",
              "type": "string"
            },
            {
              "id": "7",
              "name": "category",
              "value": "={{ $('Resolve Category').first().json.data[0]?.name || '' }}",
              "type": "string"
            },
            {
              "id": "8",
              "name": "screenshotUrl",
              "value": "={{ $json.screenshotUrl || \"\" }}",
              "type": "string"
            },
            {
              "id": "9",
              "name": "databaseId",
              "value": "={{ $('Set Parameters').first().json.notionDatabaseId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "1e3ceecc-45ad-4ca9-bf6a-326c49da7806",
      "name": "Format Notion Properties",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1552, 304]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.databaseId }}"
        },
        "title": "={{ $json.title }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Domain|rich_text",
              "type": "rich_text",
              "textContent": "={{ $json.domain }}"
            },
            {
              "key": "Shop URL|url",
              "type": "url",
              "urlValue": "={{ $json.shopUrl }}"
            },
            {
              "key": "Monthly Visits|number",
              "type": "number",
              "numberValue": "={{ $json.monthlyVisits }}"
            },
            {
              "key": "Active Ads|number",
              "type": "number",
              "numberValue": "={{ $json.activeAds }}"
            },
            {
              "key": "Country|rich_text",
              "type": "rich_text",
              "textContent": "={{ $json.country }}"
            },
            {
              "key": "Category|rich_text",
              "type": "rich_text",
              "textContent": "={{ $json.category }}"
            }
          ]
        },
        "options": {}
      },
      "id": "73a219a5-5880-40d1-bc4c-1d583fdce667",
      "name": "Create Notion Candidate",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [1760, 304]
    }
  ],
  "connections": {
    "Run Manually": {
      "main": [
        [
          {
            "node": "Set Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Parameters": {
      "main": [
        [
          {
            "node": "Resolve Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resolve Category": {
      "main": [
        [
          {
            "node": "Has Category Match",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Category Match": {
      "main": [
        [
          {
            "node": "Query Shops",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Shops": {
      "main": [
        [
          {
            "node": "Split Shops",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Shops": {
      "main": [
        [
          {
            "node": "Format Notion Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Notion Properties": {
      "main": [
        [
          {
            "node": "Create Notion Candidate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": true
  },
  "tags": []
}
