Skip to main content

Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API

Workflow preview

Workflow preview
100%
Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API preview
Open on n8n.io

1. Workflow Overview

Get Long Lived Facebook Page Access Token and Subscribe Messenger Webhook Fields This n8n template automates two critical one time setup steps required before any Facebook automation can go live: i...

Best for

  • Support Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.manualtrigger, n8n-nodes-base.set, n8n-nodes-base.httprequest, n8n-nodes-base.splitout, n8n-nodes-base.splitinbatches, n8n-nodes-base.code, n8n-nodes-base.wait

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Nguyễn Thiệu Toàn (Jay Nguyen).

Original n8n.io source

1.1 Workflow description

Title
Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API
Workflow name
Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API

Get Long-Lived Facebook Page Access Token and Subscribe Messenger Webhook Fields

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 Page to the webhook fields your app needs — all in a single manual run.

If you're building a Messenger chatbot or automating comment replies on Facebook Pages, run this utility workflow once as part of your initial setup.

How it works

  • Needed Value node: Set your app_id, app_secret, short-lived short_user_access_token, and field_to_add (the webhook subscription fields) in one place — no other node needs editing.
  • Token Exchange: Calls the Facebook Graph API to exchange the short-lived token for a long-lived User Access Token, then resolves the app-scoped User ID.
  • Page Token Retrieval: Fetches long-lived Page Access Tokens for all Pages connected to this user.
  • Per-Page Webhook Subscription: Loops through each Page — fetches its existing subscribed fields, merges them with your new fields, and POSTs the combined list back to the Graph API.
  • Rate Limiting: A 1-second Wait node between each Page prevents hitting Facebook's API rate limits.

How to use

  1. Get credentials: Retrieve your App ID and App Secret from Meta for Developers.
  2. Generate a short-lived token: Use Graph API Explorer with pages_manage_metadata and pages_show_list permissions.
  3. Fill in Needed Value: Enter all four config fields. Set field_to_add based on your use case (e.g., messages,messaging_postbacks for Messenger chatbots, or add feed for comment automation).
  4. Run manually: Click "Execute Workflow". The output of Get long-lived page access token contains the Page Access Token — copy it into your chatbot workflows.

Requirements

  • n8n Version: Built and tested on n8n 2.9.4+. (It is highly recommended to update to the latest n8n version.)
  • A Facebook App with Messenger product enabled and pages_manage_metadata permission approved.
  • No external credentials needed inside n8n — all API calls use the token from the Needed Value node.

Customizing this workflow

  • Different webhook fields: Update field_to_add — common values: messages, messaging_postbacks, messaging_optins, message_deliveries, feed.
  • Auto-refresh tokens: Swap the Manual Trigger for a Schedule Trigger every 50 days so your long-lived tokens never expire unexpectedly.
  • Notify on completion: Add a Telegram or Gmail node after the loop to confirm successful subscription for each Page.

Related workflows by the same author:


About the Author

Created by: Nguyễn Thiệu Toàn (Jay Nguyen) - n8n Verified Creator Email: [email protected] Website: nguyenthieutoan.com Company: GenStaff (CEO/Founder) (genstaff.net) Socials (Facebook / X / LinkedIn): @nguyenthieutoan More templates: n8n.io/creators/nguyenthieutoan

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Main Overview

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Warning Edit

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Section 1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Section 2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Author Message

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - When clicking 'Execute workflow'

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 7 - Needed Value

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 8 - Get long-lived user access token

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 9 - Get app scoped user id

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 10 - Get long-lived page access token

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 11 - Split Out Pages

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 12 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 13 - GET Current Fields

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 14 - Merge Fields

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - POST Merged Fields

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 16 - Wait 1s (rate limit)

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 17 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API
Complexity advanced
Nodes 17
Categories Support Chatbot
Author Nguyễn Thiệu Toàn (Jay Nguyen)
Published 13 Mar 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/14027/14027.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API do?

Get Long Lived Facebook Page Access Token and Subscribe Messenger Webhook Fields This n8n template automates two critical one time setup steps required before any Facebook automation can go live: i...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot use case.