{
  "name": "Sync Local Falcon rankings to HubSpot company records",
  "nodes": [
    {
      "parameters": {
        "content": "## Sync Local Falcon Rankings to HubSpot Company Records\n\n**Who is this for:** SEO agencies using HubSpot CRM who want to automatically update client company records with their latest ranking data for better client management and reporting.\n\n**What this workflow does:**\n1. Fetches recent scan reports from Local Falcon\n2. Matches locations to HubSpot companies using a custom property (place_id)\n3. Updates company records with latest avg_rank, scan date, and trend\n4. Creates activity notes for significant ranking changes\n\n**How to set up:**\n1. Add Local Falcon API credentials (get your key at https://www.localfalcon.com/api/credentials) and HubSpot API credentials\n2. Create custom properties in HubSpot: `local_falcon_place_id`, `local_falcon_avg_rank`, `local_falcon_last_scan`, `local_falcon_trend`\n3. Add place_id values to your HubSpot company records\n4. Configure the mapping in Settings node\n5. Schedule or run manually\n\n**Requirements:**\n- Local Falcon account with API access\n- HubSpot account with API access\n- Custom properties configured in HubSpot\n\n**How to customize:**\n- Sync to Contact records instead of Companies\n- Add deal stage updates based on ranking performance\n- Trigger HubSpot workflows when rankings improve\n- Include additional metrics like grid coverage",
        "height": 580,
        "width": 460,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        100,
        -220
      ]
    },
    {
      "parameters": {
        "content": "### HubSpot Custom Properties\n\nCreate these in HubSpot Settings > Properties:\n\n| Property Name | Type |\n|--------------|------|\n| `local_falcon_place_id` | Single-line text |\n| `local_falcon_avg_rank` | Number |\n| `local_falcon_last_scan` | Date |\n| `local_falcon_trend` | Single-line text |\n| `local_falcon_platform` | Single-line text |",
        "height": 220,
        "width": 340
      },
      "id": "sticky-hubspot",
      "name": "Sticky Note HubSpot",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        580,
        -220
      ]
    },
    {
      "parameters": {
        "content": "### Step 1: Schedule\nRuns daily to keep CRM current.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        40,
        680
      ]
    },
    {
      "parameters": {
        "content": "### Step 2: Get Reports\nFetches latest scan data from Local Falcon.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        300,
        680
      ]
    },
    {
      "parameters": {
        "content": "### Step 3: Transform\nFormats data for HubSpot update.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        560,
        680
      ]
    },
    {
      "parameters": {
        "content": "### Step 4: Find Company\nLooks up HubSpot company by place_id.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        820,
        680
      ]
    },
    {
      "parameters": {
        "content": "### Step 5: Update CRM\nSyncs ranking data to company record.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step5",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1080,
        680
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 7
            }
          ]
        }
      },
      "id": "schedule",
      "name": "Every Day 7am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        140,
        460
      ]
    },
    {
      "parameters": {
        "resource": "scan",
        "operation": "listReports",
        "additionalFields": {
          "limit": 50
        }
      },
      "id": "get-reports",
      "name": "Get Latest Scan Reports",
      "type": "@local-falcon/n8n-nodes-localfalcon.localFalcon",
      "typeVersion": 1,
      "position": [
        400,
        460
      ],
      "credentials": {
        "localFalconApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Transform reports array into individual items for processing\nconst reports = $input.first().json.reports || [];\n\nreturn reports.map(report => ({\n  json: {\n    place_id: report.place_id,\n    location_name: report.location_name,\n    keyword: report.keyword,\n    avg_rank: report.avg_rank,\n    platform: report.platform,\n    scan_date: report.scan_date,\n    rank_change: report.rank_change || 0,\n    trend: parseFloat(report.rank_change) > 0 ? 'declining' : \n           parseFloat(report.rank_change) < 0 ? 'improving' : 'stable'\n  }\n}));"
      },
      "id": "transform",
      "name": "Transform Report Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        460
      ]
    },
    {
      "parameters": {
        "resource": "company",
        "operation": "search",
        "filterGroups": [
          {
            "filters": [
              {
                "propertyName": "local_falcon_place_id",
                "operator": "EQ",
                "value": "={{ $json.place_id }}"
              }
            ]
          }
        ],
        "additionalFields": {}
      },
      "id": "find-company",
      "name": "Find HubSpot Company",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2,
      "position": [
        920,
        460
      ],
      "credentials": {
        "hubspotApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "company",
        "operation": "update",
        "companyId": "={{ $json.results[0].id }}",
        "updateFields": {
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "property": "local_falcon_avg_rank",
                "value": "={{ $('Transform Report Data').item.json.avg_rank }}"
              },
              {
                "property": "local_falcon_last_scan",
                "value": "={{ $('Transform Report Data').item.json.scan_date }}"
              },
              {
                "property": "local_falcon_trend",
                "value": "={{ $('Transform Report Data').item.json.trend }}"
              },
              {
                "property": "local_falcon_platform",
                "value": "={{ $('Transform Report Data').item.json.platform }}"
              }
            ]
          }
        }
      },
      "id": "update-company",
      "name": "Update Company Rankings",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2,
      "position": [
        1180,
        460
      ],
      "credentials": {
        "hubspotApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Every Day 7am": {
      "main": [
        [
          {
            "node": "Get Latest Scan Reports",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Latest Scan Reports": {
      "main": [
        [
          {
            "node": "Transform Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Report Data": {
      "main": [
        [
          {
            "node": "Find HubSpot Company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find HubSpot Company": {
      "main": [
        [
          {
            "node": "Update Company Rankings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}