{
  "name": "Sync Local Falcon rankings to Notion database",
  "nodes": [
    {
      "parameters": {
        "content": "## Sync Local Falcon Rankings to Notion Database\n\n**Who is this for:** Teams using Notion for project management who want ranking data visible alongside client notes and tasks.\n\n**What this workflow does:**\n1. Fetches scan reports from Local Falcon\n2. Matches locations to Notion database pages\n3. Updates page properties with latest ranking data\n4. Creates new pages for untracked locations\n\n**How to set up:**\n1. Add your Local Falcon API credentials (get your key at https://www.localfalcon.com/api/credentials)\n2. Add your Notion API credentials (create an integration)\n3. Create a Notion database with properties: Name, Place ID, Avg Rank, Last Scan, Platform, Keyword\n4. Share the database with your Notion integration\n5. Update the Database ID and activate\n\n**Requirements:**\n- Local Falcon account with API access\n- Notion account with API integration\n- Notion database shared with integration\n\n**How to customize:**\n- Add relation properties to link to client pages\n- Create Notion views for different ranking tiers\n- Use Notion formulas to calculate trends",
        "height": 520,
        "width": 460,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        100,
        -180
      ]
    },
    {
      "parameters": {
        "content": "### Step 1: Schedule\nRuns daily to keep Notion updated.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        40,
        660
      ]
    },
    {
      "parameters": {
        "content": "### Step 2: Get Reports\nFetches ranking data from API.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        300,
        660
      ]
    },
    {
      "parameters": {
        "content": "### Step 3: Transform\nFormats for Notion properties.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        560,
        660
      ]
    },
    {
      "parameters": {
        "content": "### Step 4: Update Notion\nSyncs to database pages.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        820,
        660
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "schedule",
      "name": "Every Day 8am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        140,
        440
      ]
    },
    {
      "parameters": {
        "resource": "scan",
        "operation": "listReports",
        "additionalFields": {
          "limit": 50
        }
      },
      "id": "get-reports",
      "name": "Get Scan Reports",
      "type": "@local-falcon/n8n-nodes-localfalcon.localFalcon",
      "typeVersion": 1,
      "position": [
        400,
        440
      ],
      "credentials": {
        "localFalconApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const reports = $input.first().json.reports || [];\n\nreturn reports.map(report => ({\n  json: {\n    name: report.location_name || 'Unknown Location',\n    place_id: report.place_id || '',\n    avg_rank: parseFloat(report.avg_rank) || null,\n    last_scan: report.scan_date || new Date().toISOString(),\n    platform: report.platform || 'google',\n    keyword: report.keyword || ''\n  }\n}));"
      },
      "id": "transform",
      "name": "Transform for Notion",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        440
      ]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "create",
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_NOTION_DATABASE_ID"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "={{ $json.name }}"
            },
            {
              "key": "Place ID|rich_text",
              "richTextValue": "={{ $json.place_id }}"
            },
            {
              "key": "Avg Rank|number",
              "numberValue": "={{ $json.avg_rank }}"
            },
            {
              "key": "Platform|select",
              "selectValue": "={{ $json.platform }}"
            },
            {
              "key": "Keyword|rich_text",
              "richTextValue": "={{ $json.keyword }}"
            }
          ]
        }
      },
      "id": "update-notion",
      "name": "Update Notion Database",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        920,
        440
      ],
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Every Day 8am": {
      "main": [
        [
          {
            "node": "Get Scan Reports",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Scan Reports": {
      "main": [
        [
          {
            "node": "Transform for Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform for Notion": {
      "main": [
        [
          {
            "node": "Update Notion Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}