To connect n8n to Facebook/Meta APIs, such as for managing Facebook Pages, Instagram, or running ads via the Graph API, follow these steps:
β
Prerequisites
Facebook Developer Account: https://developers.facebook.com/
Create a Facebook App:
Go to My Apps β Create App
Choose an app type (typically "Business" or "None" for automation)
Configure your app name, email, etc.
Add the Needed Products (e.g., Facebook Login, Instagram Basic Display, Pages API)
Get App Credentials:
Create Access Token (User/Page token with proper permissions)
Use Graph API Explorer or generate manually
Select permissions like pages_show_list, pages_read_engagement, pages_manage_posts, instagram_basic, etc.
Use a long-lived token for stability in automation
π Step-by-Step: Connect Facebook API in n8n
1. Open n8n
Go to your n8n dashboard (e.g., http://localhost:5678 or your hosted version).
2. Set Up Credentials
π‘ If you donβt see "Facebook Graph API", enable community nodes or install it via npm in your n8n instance.
3. Create a New Workflow
Example: Automatically post to a Facebook Page.
Use a Facebook Node:
- Type:
Facebook Graph API
- Resource:
Post
- Operation:
Create
- Page ID: Paste the Page ID
- Message: Your post content
π‘ You can use an HTTP Request node if you want full control over Graph API endpoints.
π‘ Example: Using HTTP Request Node
Node: HTTP Request
π Permissions and Review
If your app is not in Live Mode, you can only access data for users who have authorized the app.
For production:
- Go to App Review in the Developer portal
- Request needed permissions
π§ͺ Test & Automate
Once the credential works:
- Use Cron or Webhook trigger
- Post scheduled content
- Pull insights
- Manage comments/messages
β
Bonus Tips
- Use
Set or Function nodes to customize message content
- Add
IF nodes to branch logic (e.g., only post if new content exists)
- Combine with Google Sheets, RSS, or CMS integrations
Great! Since you confirmed "yes", letβs walk through a concrete example of using n8n to auto-post to a Facebook Page via the Graph API using the HTTP Request node.
π Use Case: Auto-Post to Facebook Page from n8n
Weβll set up a workflow to post a message to your Facebook Page using a simple HTTP request.
π§ Step 1: Generate Facebook Page Access Token
Go to the Graph API Explorer
Select your app and a user (with admin access to the Page)
Add these permissions:
pages_manage_posts
pages_read_engagement
Get a User Access Token, then:
Use the Page Access Token in your workflow (preferably long-lived).
π§ Step 2: n8n Workflow Setup
πΉ Node 1: Start (or any Trigger β Cron/Webhook)
πΉ Node 2: HTTP Request
Example Configuration:
{
"method": "POST",
"url": "https://graph.facebook.com/v19.0/123456789/feed",
"qs": {
"message": "Hello, this is a test post from n8n!",
"access_token": "EAA...your_page_token..."
}
}
β
Final Tips
You can replace the message dynamically from a previous node (e.g., Google Sheets, webhook payload).
Add error handling (try/catch with IF node).
Schedule it with a Cron node (e.g., post daily at 9 AM).
To auto-post with images, use endpoint:
POST /{page-id}/photos
β οΈ Caution
- If your app is not in Live Mode, the API works only for users/testers added to the app.
- You need to submit for App Review to access wider audiences with required permissions.
Here is a ready-to-import n8n workflow JSON that auto-posts a message to your Facebook Page using the HTTP Request node and Facebook Graph API.
π€ Example n8n Workflow: Auto Post to Facebook Page
π Facebook Graph API (via HTTP Request)
{
"nodes": [
{
"parameters": {},
"id": "1",
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [250, 300]
},
{
"parameters": {
"url": "https://graph.facebook.com/v19.0/YOUR_PAGE_ID/feed",
"method": "POST",
"queryParametersUi": {
"parameter": [
{
"name": "message",
"value": "Hello from n8n! This is an automated post using Facebook Graph API."
},
{
"name": "access_token",
"value": "YOUR_PAGE_ACCESS_TOKEN"
}
]
},
"options": {}
},
"id": "2",
"name": "Post to Facebook",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [550, 300]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Post to Facebook",
"type": "main",
"index": 0
}
]
]
}
},
"name": "Post to Facebook Page",
"active": false,
"settings": {},
"id": "facebook-post-example"
}
π οΈ What to Replace:
YOUR_PAGE_ID β Your actual Facebook Page ID (e.g., 123456789)
YOUR_PAGE_ACCESS_TOKEN β Your Page Access Token with pages_manage_posts permission
β
How to Use:
- Go to your n8n instance
- Click Import Workflow
- Paste the JSON above
- Replace placeholders
- Click Execute Node to test it