Facebook Lead Ads → Lead Enrichment (Webhook + Graph API)
Facebook Lead Ads Configuration (Webhook)
To make this template work correctly, you must configure the Facebook Webhook on the Facebook Page associated with your ads.
Important: the leadgen subscription cannot be selected immediately.
It becomes available only after the webhook has been successfully verified by Facebook.
1. Create and configure a Facebook App
-
Go to Meta for Developers
-
Create a new Business-type App
-
Add the Webhooks product
-
Add Facebook Login (required for permissions and token management)
2. Verify the Webhook (required before subscribing to leadgen)
Inside the Webhooks product:
-
Select the Page object
-
Enter:
-
Click Verify and Save
This template automatically handles the hub.challenge response, so the verification will succeed without any additional code.
At this stage, the leadgen event is NOT selectable.
Facebook unlocks Lead Ads subscriptions only after the webhook verification succeeds.
3. Subscribe to the Lead Ads event (leadgen)
After the webhook has been successfully verified:
-
Go back to Webhooks → Page
-
The leadgen event will now be visible
-
Subscribe to leadgen
From this moment, Facebook will start sending Lead Ads events to the webhook.
4. Connect the app to the Facebook Page
-
Open Business Settings
-
Go to Accounts → Pages
-
Add the Facebook Page used for Lead Ads
-
Assign the app and grant access to the page
5. Required permissions
The app must have both Page and Ads permissions.
Without Ads permissions, requests related to campaigns, ad sets, or ads will fail.
Minimum required permissions:
-
leads_retrieval
-
pages_manage_metadata
-
pages_read_engagement
-
pages_show_list
-
ads_read
-
ads_management
For production environments, the app must be submitted for Meta App Review with these permissions.
6. System User and Access Token (Recommended)
Instead of using a personal user token, it is strongly recommended to use a System User from Meta Business Manager.
This approach is more secure, stable, and production-ready, especially for server-to-server workflows like n8n.
Steps:
-
Open Business Settings → Users → System Users
-
Create a new System User
-
Assign the System User to the Facebook App
-
Grant the required permissions:
-
Page permissions
-
Lead Ads permissions
-
Ads permissions
-
Generate a long-lived access token with the selected scopes
7. n8n Credentials Setup
In n8n:
-
Create new credentials of type Facebook Graph API
-
Paste the generated System User access token
-
Use these credentials in all HTTP Request nodes that call the Facebook Graph API
No OAuth redirect or login flow is required when using a System User token.
8. Generate test leads
-
Publish a Facebook Lead Ads Form
-
Use one of the following tools:
-
When the form is submitted:
9. Graph API version
This template uses Graph API v22.0.
If Meta introduces breaking changes, simply update the version number in the HTTP Request nodes.
Technical notes
-
The n8n Webhook node is configured in multipleMethods mode:
-
No additional nodes, scripts, or custom code are required
-
The workflow outputs a single aggregated object containing:
-
lead contact data
-
form, campaign, ad set, and ad names
-
metadata ready for CRM, databases, or marketing automations
EDIT: in the code node you need to change the field you need from the form
Customizing Lead Fields (Code Node)
Facebook Lead Ads forms can contain custom fields, and their structure may vary depending on the form configuration.
For this reason, the Code node in this template is intentionally designed to be editable.
Inside the Code node, you can:
-
Define which lead fields should be extracted
-
Control the field order in the final output
-
Map Facebook field names to your internal naming conventions
How it works
The Code node reads the field_data array returned by the Lead Ads endpoint and selectively extracts only the fields you need.
To customize the output:
-
Open the Code node in the workflow
-
Modify the list of field names to match your Lead Ads form fields
-
Adjust the output object structure as needed for your CRM or downstream automations
This step is required if:
-
Your Lead Ads form uses custom fields
-
You want to exclude unnecessary fields
-
You need a specific output schema
Once updated, the rest of the workflow will automatically adapt, without requiring any additional changes.