This workflow corresponds to n8n.io template #14027 — we link there as the canonical source.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"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 Access Token for a **long-lived one**, retrieves **Page Access Tokens** for all connected Pages, then subscribes each Page to the webhook fields you need \u2014 all in one run.\n\nIf you're building a Messenger chatbot or automating Facebook Page comment replies, run this workflow once before activating your main automation.\n\n### How it works\n1. **Needed Value** \u2014 enter your App ID, App Secret, short-lived User Access Token, and the webhook fields to add.\n2. **Token Exchange** \u2014 calls the Graph API to get a long-lived User Access Token, then resolves the app-scoped User ID.\n3. **Page Tokens** \u2014 retrieves all Page Access Tokens linked to this user.\n4. **Loop per Page** \u2014 for each Page, fetches its currently subscribed webhook fields, merges them with your new fields, and POSTs the combined list back to the Graph API.\n5. **Rate Limit** \u2014 a 1-second Wait between pages prevents Graph API rate limit errors.\n\n### Setup\n* [ ] Get your **App ID** and **App Secret** from [Meta for Developers](https://developers.facebook.com/apps/).\n* [ ] Generate a **short-lived User Access Token** using [Graph API Explorer](https://developers.facebook.com/tools/explorer/) with `pages_manage_metadata` permission.\n* [ ] Fill in the **Needed Value** node with all four config fields.\n* [ ] Run the workflow manually. Copy the **Page Access Token** from the output for use in your chatbot workflows.\n\n### Customization tips\n* Change `field_to_add` to any combination: `messages`, `messaging_postbacks`, `feed`, `message_reads`.\n* Swap the Manual Trigger for a Schedule Trigger (every 50 days) to auto-refresh tokens.\n* Add a Telegram node at the end to notify yourself when subscription is updated.\n\n### LICENCE\nThis template is shared free of charge. Copyright belongs to Nguyen Thieu Toan (Jay Nguyen). Any copying or modification must credit the author."
},
"typeVersion": 1
},
{
"id": "f312f0c5-97b6-4513-b516-63fbd9dc9a36",
"name": "Warning Edit",
"type": "n8n-nodes-base.stickyNote",
"position": [
688,
560
],
"parameters": {
"color": 3,
"width": 464,
"height": 256,
"content": "## \u26a0\ufe0f Edit this node!\n\nFill in all 4 fields before running:\n- `app_id` \u2014 from Meta App Dashboard\n- `app_secret` \u2014 from Meta App Dashboard\n- `short_user_access_token` \u2014 from Graph API Explorer\n- `field_to_add` \u2014 webhook fields to subscribe (e.g. `messages,feed`)\n\nGet your token at [developers.facebook.com/tools/explorer](https://developers.facebook.com/tools/explorer)"
},
"typeVersion": 1
},
{
"id": "de1b33b8-c182-4c66-9b1f-428a7a13f15b",
"name": "Section 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
496,
96
],
"parameters": {
"color": 7,
"width": 1296,
"height": 496,
"content": "## Section 1: Token Exchange\nExchanges the short-lived User Access Token \u2192 **long-lived User Access Token** (~60 days) \u2192 resolves app-scoped User ID \u2192 retrieves all **Page Access Tokens** linked to this user account."
},
"typeVersion": 1
},
{
"id": "11ed6a39-495b-4899-9c9b-555df9b08723",
"name": "Section 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
1840,
96
],
"parameters": {
"color": 7,
"width": 976,
"height": 496,
"content": "## Section 2: Per-Page Webhook Field Subscription\nSplits pages \u2192 loops one by one \u2192 **GET** currently subscribed fields \u2192 **merges** with new fields from config \u2192 **POST** combined field list to Graph API. A 1-second Wait between iterations prevents rate limiting."
},
"typeVersion": 1
},
{
"id": "bc60732f-c7fe-4875-98bc-8fe1b481a6d0",
"name": "Author Message",
"type": "n8n-nodes-base.stickyNote",
"position": [
2832,
96
],
"parameters": {
"color": 4,
"width": 560,
"height": 492,
"content": "## Author Message\n\nHi! I am **Nguyen Thieu Toan (Jay Nguyen)** \u2014 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, saves you time, or helps your automation projects, you can buy me a coffee here: **[My Donate Website](https://nguyenthieutoan.com/payment/)** *(PayPal, Momo, Bank Transfer)*\n\n**Related workflows:**\n- [Smart human takeover for Messenger chatbot](https://n8n.io/workflows/11920)\n- [AI Facebook Messenger chatbot with Gemini](https://n8n.io/workflows/13080)\n- [Smart message batching Messenger chatbot](https://n8n.io/workflows/9192)\n\n* Website: [nguyenthieutoan.com](https://nguyenthieutoan.com)\n* Email: me@nguyenthieutoan.com\n* Company: GenStaff ([genstaff.net](https://genstaff.net))\n* Socials: @nguyenthieutoan\n\n*More templates:* **[n8n.io/creators/nguyenthieutoan](https://n8n.io/creators/nguyenthieutoan)**"
},
"typeVersion": 1
},
{
"id": "4517d2f7-0fe1-4dc9-b5bb-5ce46a9b7226",
"name": "When clicking 'Execute workflow'",
"type": "n8n-nodes-base.manualTrigger",
"position": [
544,
368
],
"parameters": {},
"typeVersion": 1
},
{
"id": "f4a52d2a-6186-4455-82c6-3426deae5d23",
"name": "Needed Value",
"type": "n8n-nodes-base.set",
"position": [
768,
368
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "62c906fd-b796-4c22-b111-4d3172e67c93",
"name": "app_id",
"type": "string",
"value": "[YOUR_APP_ID]"
},
{
"id": "48ad86f0-ec99-4b49-8976-4f50f1cea64c",
"name": "app_secret",
"type": "string",
"value": "[YOUR_APP_SECRET]"
},
{
"id": "0479be3c-5928-4bd6-90d7-90266a942fdd",
"name": "short_user_access_token",
"type": "string",
"value": "[YOUR_SHORT_USER_ACCESS_TOKEN]"
},
{
"id": "333e5c5f-2c76-41dc-9564-e9096758b041",
"name": "field_to_add",
"type": "string",
"value": "messages,messaging_postbacks,feed"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "7905085e-a83f-48ed-8a93-363672fdb42d",
"name": "Get long-lived user access token",
"type": "n8n-nodes-base.httpRequest",
"position": [
992,
368
],
"parameters": {
"url": "https://graph.facebook.com/v25.0/oauth/access_token",
"options": {
"response": {
"response": {
"fullResponse": true
}
}
},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "grant_type",
"value": "fb_exchange_token"
},
{
"name": "client_id",
"value": "={{ $json.app_id }}"
},
{
"name": "client_secret",
"value": "={{ $json.app_secret }}"
},
{
"name": "fb_exchange_token",
"value": "={{ $json.short_user_access_token }}"
}
]
}
},
"typeVersion": 4.4
},
{
"id": "745b52a8-487a-4a1f-aa97-d8b0dab755c3",
"name": "Get app scoped user id",
"type": "n8n-nodes-base.httpRequest",
"position": [
1216,
368
],
"parameters": {
"url": "=https://graph.facebook.com/me?access_token={{ $json.body.access_token }}",
"options": {}
},
"typeVersion": 4.4
},
{
"id": "132db33f-e67b-4a0d-8b9c-b70480bf02e0",
"name": "Get long-lived page access token",
"type": "n8n-nodes-base.httpRequest",
"position": [
1440,
368
],
"parameters": {
"url": "=https://graph.facebook.com/v25.0/{{ $json.id }}/accounts",
"options": {
"response": {
"response": {
"fullResponse": true
}
}
},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "access_token",
"value": "={{ $('Get long-lived user access token').item.json.body.access_token }}"
}
]
}
},
"typeVersion": 4.4
},
{
"id": "2a36e297-a0e9-4122-b936-e16487025df6",
"name": "Split Out Pages",
"type": "n8n-nodes-base.splitOut",
"position": [
1664,
368
],
"parameters": {
"options": {},
"fieldToSplitOut": "body.data"
},
"typeVersion": 1
},
{
"id": "31a81107-c901-46eb-afc3-cdc039cb0be8",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"position": [
1888,
368
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "159a536c-e616-4409-81af-e6309facb131",
"name": "GET Current Fields",
"type": "n8n-nodes-base.httpRequest",
"position": [
2112,
368
],
"parameters": {
"url": "=https://graph.facebook.com/v25.0/{{ $('Loop Over Items').item.json.id }}/subscribed_apps",
"options": {},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "access_token",
"value": "={{ $('Loop Over Items').item.json.access_token }}"
}
]
}
},
"typeVersion": 4.4
},
{
"id": "677c30cd-2d1c-4ae6-a1fd-7f913e85aa3f",
"name": "Merge Fields",
"type": "n8n-nodes-base.code",
"position": [
2336,
368
],
"parameters": {
"jsCode": "// Build merged subscribed_fields list for this page\nconst dataArray = $input.first().json.data;\nconst results = dataArray.map(item => {\n const subscribed_fields = item.subscribed_fields || [];\n return subscribed_fields.join(\",\");\n});\nreturn results.map(r => ({ json: { result: r } }));\n"
},
"typeVersion": 2
},
{
"id": "3fa4bffd-ea33-4a46-887e-e0f2233cc135",
"name": "POST Merged Fields",
"type": "n8n-nodes-base.httpRequest",
"position": [
2560,
368
],
"parameters": {
"url": "=https://graph.facebook.com/v25.0/{{ $('Loop Over Items').item.json.id }}/subscribed_apps",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "form-urlencoded",
"bodyParameters": {
"parameters": [
{
"name": "subscribed_fields",
"value": "={{ $json.result }},{{ $('Needed Value').item.json.field_to_add }}"
},
{
"name": "access_token",
"value": "={{ $('Loop Over Items').item.json.access_token }}"
}
]
}
},
"typeVersion": 4.4
},
{
"id": "e7e53f65-979a-4e93-b57f-9945dd49fa56",
"name": "Wait 1s (rate limit)",
"type": "n8n-nodes-base.wait",
"position": [
2336,
176
],
"parameters": {
"amount": 1
},
"typeVersion": 1.1
},
{
"id": "f570cd62-aa67-48c5-a037-fb641c35f980",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
992
],
"parameters": {
"color": 5,
"width": 608,
"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 Google Gemini](https://n8n.io/workflows/13080)\n- [Smart message batching AI-powered Facebook Messenger chatbot use Data Table](https://n8n.io/workflows/9192)"
},
"typeVersion": 1
}
],
"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
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This n8n template automates two critical one-time setup steps required before any Facebook automation can go live: it exchanges a short-lived User Access Token for a long-lived one (~60 days), retrieves Page Access Tokens for all connected Facebook Pages, and subscribes each…
Source: https://n8n.io/workflows/14027/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Notion__DriveDropbox_Sync. Uses notionTrigger, googleDrive, dropbox, notion. Event-driven trigger; 47 nodes.
This n8n workflow automates the process of uploading video and image advertisements to Meta Ads Manager via the Meta Graph API (Facebook Ads) directly from Google Sheets and Google Drive. The workflow
This workflow provides an end-to-end automation for discovering, evaluating, and optionally downloading high-quality educational YouTube videos.
Template Description WDF Top Keywords: This workflow is designed to streamline keyword research by automating the process of generating, filtering, and analyzing Google and YouTube keyword data. Ensur
Youtube-Metric-Colletor. Uses httpRequest, nocoDb, baserow. Event-driven trigger; 33 nodes.