{
  "name": "Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API",
  "nodes": [
    {
      "id": "10546596-ebe7-4d84-82f3-605c3201902f",
      "name": "Main Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        16
      ],
      "parameters": {
        "width": 560,
        "height": 960,
        "content": "## Get Long-Lived Facebook Page Access Token & Subscribe Webhook Fields\n\nThis utility workflow automates two critical setup steps for any Facebook automation project: it exchanges a short-lived User A"
      }
    },
    {
      "id": "f312f0c5-97b6-4513-b516-63fbd9dc9a36",
      "name": "Warning Edit",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        560
      ],
      "parameters": {
        "width": 464,
        "height": 256,
        "content": "## ⚠️ Edit this node!\n\nFill in all 4 fields before running:\n- `app_id` — from Meta App Dashboard\n- `app_secret` — from Meta App Dashboard\n- `short_user_access_token` — from Graph API Explorer\n- `field"
      }
    },
    {
      "id": "de1b33b8-c182-4c66-9b1f-428a7a13f15b",
      "name": "Section 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        96
      ],
      "parameters": {
        "width": 1296,
        "height": 496,
        "content": "## Section 1: Token Exchange\nExchanges the short-lived User Access Token → **long-lived User Access Token** (~60 days) → resolves app-scoped User ID → retrieves all **Page Access Tokens** linked to th"
      }
    },
    {
      "id": "11ed6a39-495b-4899-9c9b-555df9b08723",
      "name": "Section 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1840,
        96
      ],
      "parameters": {
        "width": 976,
        "height": 496,
        "content": "## Section 2: Per-Page Webhook Field Subscription\nSplits pages → loops one by one → **GET** currently subscribed fields → **merges** with new fields from config → **POST** combined field list to Graph"
      }
    },
    {
      "id": "bc60732f-c7fe-4875-98bc-8fe1b481a6d0",
      "name": "Author Message",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        96
      ],
      "parameters": {
        "width": 560,
        "height": 492,
        "content": "## Author Message\n\nHi! I am **Nguyen Thieu Toan (Jay Nguyen)** — a Verified n8n Creator. Thank you for using this template!\n\nThis workflow is shared with you for free. If it brings value to your work,"
      }
    },
    {
      "id": "4517d2f7-0fe1-4dc9-b5bb-5ce46a9b7226",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        544,
        368
      ]
    },
    {
      "id": "f4a52d2a-6186-4455-82c6-3426deae5d23",
      "name": "Needed Value",
      "type": "n8n-nodes-base.set",
      "position": [
        768,
        368
      ]
    },
    {
      "id": "7905085e-a83f-48ed-8a93-363672fdb42d",
      "name": "Get long-lived user access token",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        992,
        368
      ]
    },
    {
      "id": "745b52a8-487a-4a1f-aa97-d8b0dab755c3",
      "name": "Get app scoped user id",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1216,
        368
      ]
    },
    {
      "id": "132db33f-e67b-4a0d-8b9c-b70480bf02e0",
      "name": "Get long-lived page access token",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1440,
        368
      ]
    },
    {
      "id": "2a36e297-a0e9-4122-b936-e16487025df6",
      "name": "Split Out Pages",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1664,
        368
      ]
    },
    {
      "id": "31a81107-c901-46eb-afc3-cdc039cb0be8",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1888,
        368
      ]
    },
    {
      "id": "159a536c-e616-4409-81af-e6309facb131",
      "name": "GET Current Fields",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2112,
        368
      ]
    },
    {
      "id": "677c30cd-2d1c-4ae6-a1fd-7f913e85aa3f",
      "name": "Merge Fields",
      "type": "n8n-nodes-base.code",
      "position": [
        2336,
        368
      ]
    },
    {
      "id": "3fa4bffd-ea33-4a46-887e-e0f2233cc135",
      "name": "POST Merged Fields",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2560,
        368
      ]
    },
    {
      "id": "e7e53f65-979a-4e93-b57f-9945dd49fa56",
      "name": "Wait 1s (rate limit)",
      "type": "n8n-nodes-base.wait",
      "position": [
        2336,
        176
      ]
    },
    {
      "id": "f570cd62-aa67-48c5-a037-fb641c35f980",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        992
      ],
      "parameters": {
        "width": 608,
        "height": null,
        "content": "## **Related workflows**\n- [Smart human takeover & auto pause AI-powered Facebook Messenger chatbot](https://n8n.io/workflows/11920)\n- [Build a Facebook Messenger customer service AI chatbot with Goog"
      }
    }
  ],
  "connections": {
    "Merge Fields": {
      "main": [
        [
          {
            "node": "POST Merged Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Needed Value": {
      "main": [
        [
          {
            "node": "Get long-lived user access token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "GET Current Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out Pages": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET Current Fields": {
      "main": [
        [
          {
            "node": "Merge Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "POST Merged Fields": {
      "main": [
        [
          {
            "node": "Wait 1s (rate limit)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 1s (rate limit)": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get app scoped user id": {
      "main": [
        [
          {
            "node": "Get long-lived page access token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get long-lived page access token": {
      "main": [
        [
          {
            "node": "Split Out Pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get long-lived user access token": {
      "main": [
        [
          {
            "node": "Get app scoped user id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Needed Value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}