{
  "name": "Trigger Local Falcon scan from webhook request",
  "nodes": [
    {
      "parameters": {
        "content": "## Trigger Local Falcon Scan from Webhook Request\n\n**Who is this for:** Developers and agencies who need to trigger on-demand Local Falcon scans programmatically from external applications, websites, or automation tools.\n\n**What this workflow does:**\n1. Exposes a webhook URL that accepts POST requests\n2. Validates incoming scan parameters\n3. Runs a one-off scan via Local Falcon API\n4. Returns the report key for tracking results\n\n**How to set up:**\n1. Add your Local Falcon API credentials (get your key at https://www.localfalcon.com/api/credentials)\n2. Activate the workflow\n3. Copy the webhook URL from the Webhook node (click to view)\n4. Send POST requests with scan parameters to trigger scans\n\n**Requirements:**\n- Local Falcon account with API access and scan credits\n- Application or tool capable of sending HTTP POST requests\n\n**How to customize:**\n- Add authentication to the webhook for security\n- Store results in a database or Google Sheet\n- Send completion notifications via email or Slack\n- Add rate limiting logic to prevent overuse",
        "height": 500,
        "width": 440,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        140,
        -140
      ]
    },
    {
      "parameters": {
        "content": "### Request Format\n\n```json\nPOST /webhook/local-falcon-scan\n{\n  \"place_id\": \"ChIJ...\",\n  \"keyword\": \"pizza near me\",\n  \"lat\": \"40.7128\",\n  \"lng\": \"-74.0060\",\n  \"grid_size\": 7,\n  \"radius\": 1,\n  \"platform\": \"google\"\n}\n```\n\n**Required:** place_id, keyword, lat, lng\n**Optional:** grid_size (default 7), radius (default 1), platform (default google), measurement (default mi)",
        "height": 300,
        "width": 340
      },
      "id": "sticky-format",
      "name": "Sticky Note Format",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        600,
        -140
      ]
    },
    {
      "parameters": {
        "content": "### Step 1: Webhook\nReceives POST requests with scan parameters.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        80,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 2: Defaults\nMerges request data with default values.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        340,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 3: Run Scan\nExecutes one-off scan via Local Falcon API.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        600,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 4: Respond\nReturns scan result with report key.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        860,
        640
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "local-falcon-scan",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook",
      "name": "Receive Scan Request",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        180,
        420
      ]
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={\n  \"place_id\": \"{{ $json.body.place_id }}\",\n  \"keyword\": \"{{ $json.body.keyword }}\",\n  \"lat\": \"{{ $json.body.lat }}\",\n  \"lng\": \"{{ $json.body.lng }}\",\n  \"platform\": \"{{ $json.body.platform || 'google' }}\",\n  \"grid_size\": {{ $json.body.grid_size || 7 }},\n  \"radius\": {{ $json.body.radius || 1 }},\n  \"measurement\": \"{{ $json.body.measurement || 'mi' }}\"\n}",
        "options": {}
      },
      "id": "defaults",
      "name": "Apply Defaults",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        440,
        420
      ]
    },
    {
      "parameters": {
        "resource": "scan",
        "operation": "run",
        "platform": "={{ $json.platform }}",
        "placeId": "={{ $json.place_id }}",
        "keyword": "={{ $json.keyword }}",
        "lat": "={{ $json.lat }}",
        "lng": "={{ $json.lng }}",
        "gridSize": "={{ $json.grid_size }}",
        "radius": "={{ $json.radius }}",
        "measurement": "={{ $json.measurement }}"
      },
      "id": "run-scan",
      "name": "Run Local Falcon Scan",
      "type": "@local-falcon/n8n-nodes-localfalcon.localFalcon",
      "typeVersion": 1,
      "position": [
        700,
        420
      ],
      "credentials": {
        "localFalconApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"success\": true,\n  \"report_key\": \"{{ $json.report_key }}\",\n  \"message\": \"Scan initiated successfully\",\n  \"details\": {\n    \"keyword\": \"{{ $('Apply Defaults').item.json.keyword }}\",\n    \"platform\": \"{{ $('Apply Defaults').item.json.platform }}\",\n    \"grid_size\": {{ $('Apply Defaults').item.json.grid_size }}\n  }\n}",
        "options": {}
      },
      "id": "respond",
      "name": "Return Scan Result",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        960,
        420
      ]
    }
  ],
  "connections": {
    "Receive Scan Request": {
      "main": [
        [
          {
            "node": "Apply Defaults",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply Defaults": {
      "main": [
        [
          {
            "node": "Run Local Falcon Scan",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Local Falcon Scan": {
      "main": [
        [
          {
            "node": "Return Scan Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}