{
  "name": "TrendTrack — Daily Top Hooks Library → Notion",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "id": "cbb89cda-0cea-48b5-9858-f1cef7e31c87",
      "name": "Every Day at 7am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [240, 304]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "notionDatabaseId",
              "value": "YOUR_HOOK_LIBRARY_DB",
              "type": "string"
            },
            {
              "id": "2",
              "name": "limit",
              "value": 15,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "c9e3af68-e1ea-4ee5-ab9d-fb318317d420",
      "name": "Set Parameters",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [464, 304]
    },
    {
      "parameters": {
        "url": "https://api.trendtrack.io/v1/workspace/hooks",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "sortBy",
              "value": "totalImpressions"
            },
            {
              "name": "sortOrder",
              "value": "desc"
            },
            {
              "name": "limit",
              "value": "={{ $json.limit }}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $env.TRENDTRACK_API_KEY }}"
            }
          ]
        },
        "options": {}
      },
      "id": "b954366e-42ae-4435-abd1-ae4ef92c32ad",
      "name": "Fetch Top Hooks",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [688, 304]
    },
    {
      "parameters": {
        "fieldToSplitOut": "data",
        "options": {}
      },
      "id": "1dc6e493-8d51-4279-912f-43d91e5b5ef4",
      "name": "Split Hooks",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [912, 304]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "title",
              "value": "={{ ($json.hook?.text || 'Untitled hook').slice(0, 95) }}",
              "type": "string"
            },
            {
              "id": "2",
              "name": "fullText",
              "value": "={{ $json.hook?.text || \"\" }}",
              "type": "string"
            },
            {
              "id": "3",
              "name": "brand",
              "value": "={{ $json.brandtracker?.name || \"Unknown\" }}",
              "type": "string"
            },
            {
              "id": "4",
              "name": "usageCount",
              "value": "={{ $json.metrics?.usageCount ?? 0 }}",
              "type": "number"
            },
            {
              "id": "5",
              "name": "totalImpressions",
              "value": "={{ $json.metrics?.totalImpressions ?? 0 }}",
              "type": "number"
            },
            {
              "id": "6",
              "name": "firstUsedAt",
              "value": "={{ $json.metrics?.firstUsedAt || \"\" }}",
              "type": "string"
            },
            {
              "id": "7",
              "name": "sampleAdLink",
              "value": "={{ $json.hook?.sampleAd?.adId ? \"https://app.trendtrack.io/ad/\" + $json.hook.sampleAd.adId.replace(/^[a-z]+_/, \"\") : \"\" }}",
              "type": "string"
            },
            {
              "id": "8",
              "name": "thumbnailUrl",
              "value": "={{ $json.hook?.sampleAd?.thumbnailUrl || \"\" }}",
              "type": "string"
            },
            {
              "id": "9",
              "name": "databaseId",
              "value": "={{ $('Set Parameters').first().json.notionDatabaseId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a3e63196-1d64-46a0-a411-642c9cbb4527",
      "name": "Format Notion Properties",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [1120, 304]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.databaseId }}"
        },
        "title": "={{ $json.title }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Hook Text|rich_text",
              "type": "rich_text",
              "textContent": "={{ $json.fullText }}"
            },
            {
              "key": "Brand|rich_text",
              "type": "rich_text",
              "textContent": "={{ $json.brand }}"
            },
            {
              "key": "Usage Count|number",
              "type": "number",
              "numberValue": "={{ $json.usageCount }}"
            },
            {
              "key": "Total Impressions|number",
              "type": "number",
              "numberValue": "={{ $json.totalImpressions }}"
            },
            {
              "key": "Sample Ad|url",
              "type": "url",
              "urlValue": "={{ $json.sampleAdLink }}"
            }
          ]
        },
        "options": {}
      },
      "id": "b0198318-eef0-466c-a91e-9547768745a9",
      "name": "Create Notion Page",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [1360, 304]
    }
  ],
  "connections": {
    "Every Day at 7am": {
      "main": [
        [
          {
            "node": "Set Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Parameters": {
      "main": [
        [
          {
            "node": "Fetch Top Hooks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Top Hooks": {
      "main": [
        [
          {
            "node": "Split Hooks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Hooks": {
      "main": [
        [
          {
            "node": "Format Notion Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Notion Properties": {
      "main": [
        [
          {
            "node": "Create Notion Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": true
  },
  "tags": []
}
