{
  "name": "List and manage Local Falcon campaigns via webhook",
  "nodes": [
    {
      "parameters": {
        "content": "## List and Manage Local Falcon Campaigns via Webhook\n\n**Who is this for:** Developers building dashboards or tools that need to interact with Local Falcon campaigns programmatically.\n\n**What this workflow does:**\n1. Exposes a webhook API endpoint\n2. Supports actions: list, get, pause, resume campaigns\n3. Returns campaign data in JSON format\n4. Enables building custom campaign management interfaces\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\n4. Send requests with action parameter\n\n**Requirements:**\n- Local Falcon account with API access\n- Existing campaigns to manage\n\n**API Usage:**\n```\nGET /webhook/lf-campaigns?action=list\nGET /webhook/lf-campaigns?action=get&campaign_key=xxx\nPOST /webhook/lf-campaigns\n{\"action\": \"pause\", \"campaign_key\": \"xxx\"}\n```\n\n**How to customize:**\n- Add authentication to the webhook\n- Extend with campaign creation\n- Build a full management API\n- Add rate limiting",
        "height": 560,
        "width": 460,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        100,
        -200
      ]
    },
    {
      "parameters": {
        "content": "### Step 1: Webhook\nReceives management requests.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        40,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 2: Route Action\nDirects to appropriate handler.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        300,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 3: Execute\nPerforms the campaign action.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        560,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 4: Respond\nReturns results as JSON.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        820,
        640
      ]
    },
    {
      "parameters": {
        "httpMethod": "=GET,POST",
        "path": "lf-campaigns",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook",
      "name": "Campaign API Endpoint",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        140,
        420
      ]
    },
    {
      "parameters": {
        "jsCode": "const request = $input.first().json;\nconst action = request.query?.action || request.body?.action || 'list';\nconst campaignKey = request.query?.campaign_key || request.body?.campaign_key;\n\nreturn [{\n  json: {\n    action: action,\n    campaign_key: campaignKey\n  }\n}];"
      },
      "id": "parse-request",
      "name": "Parse Request",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        400,
        420
      ]
    },
    {
      "parameters": {
        "resource": "campaign",
        "operation": "list",
        "additionalFields": {
          "limit": 100
        }
      },
      "id": "list-campaigns",
      "name": "List Campaigns",
      "type": "@local-falcon/n8n-nodes-localfalcon.localFalcon",
      "typeVersion": 1,
      "position": [
        660,
        420
      ],
      "credentials": {
        "localFalconApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"success\": true,\n  \"action\": \"{{ $('Parse Request').item.json.action }}\",\n  \"campaigns\": {{ JSON.stringify($json.campaigns || []) }},\n  \"total\": {{ ($json.campaigns || []).length }}\n}",
        "options": {}
      },
      "id": "respond",
      "name": "Return Results",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        920,
        420
      ]
    }
  ],
  "connections": {
    "Campaign API Endpoint": {
      "main": [
        [
          {
            "node": "Parse Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Request": {
      "main": [
        [
          {
            "node": "List Campaigns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Campaigns": {
      "main": [
        [
          {
            "node": "Return Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}