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 →
{
"name": "facebook-leads-to-crm",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "facebook-leads",
"responseMode": "responseNode",
"options": {}
},
"id": "webhook-trigger",
"name": "Facebook Lead Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"jsCode": "// Facebook Lead Ads sends data in this format\nconst body = $input.first().json;\n\n// Handle verification challenge (Facebook sends GET for verification)\nif (body['hub.challenge']) {\n return [{ json: { challenge: body['hub.challenge'] } }];\n}\n\n// Process lead gen data\nconst entry = body.entry?.[0];\nconst changes = entry?.changes?.[0];\nconst value = changes?.value;\n\nif (!value?.leads_retrieved) {\n return [{ json: { skip: true } }];\n}\n\n// Map Facebook lead fields to CRM schema\nconst fieldData = {};\n(value.field_data || []).forEach(f => {\n fieldData[f.name.toLowerCase().replace(/_/g, '')] = f.values?.[0] || '';\n});\n\nconst lead = {\n name: fieldData.fullname || fieldData.name || `${fieldData.firstname || ''} ${fieldData.lastname || ''}`.trim(),\n email: fieldData.email || '',\n phone: fieldData.phonenumber || fieldData.phone || '',\n whatsapp: fieldData.whatsappnumber || fieldData.whatsapp || fieldData.phonenumber || '',\n country: fieldData.country || 'Egypt',\n city: fieldData.city || '',\n source: 'Facebook Lead Ad',\n sourceUrl: `https://facebook.com/ads/manager`,\n campaign: value.ad_name || value.campaign_name || '',\n budget: fieldData.budget || fieldData.maxbudget || '',\n propertyType: fieldData.propertytype || fieldData.property || '',\n notes: `FB Ad: ${value.ad_name || ''} | Form: ${value.form_id || ''}`,\n externalId: `fb_${value.leadgen_id || Date.now()}`,\n};\n\nreturn [{ json: lead }];"
},
"id": "transform-lead",
"name": "Transform FB Lead",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
460,
300
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": false
},
"conditions": [
{
"leftValue": "={{ $json.skip }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "notEquals"
}
}
]
}
},
"id": "filter-valid",
"name": "Skip if Invalid",
"type": "n8n-nodes-base.filter",
"typeVersion": 2,
"position": [
680,
300
]
},
{
"parameters": {
"method": "POST",
"url": "={{ $env.CRM_URL }}/api/webhooks/leads",
"sendBody": true,
"contentType": "json",
"body": {
"values": [
{
"name": "name",
"value": "={{ $json.name }}"
},
{
"name": "email",
"value": "={{ $json.email }}"
},
{
"name": "phone",
"value": "={{ $json.phone }}"
},
{
"name": "whatsapp",
"value": "={{ $json.whatsapp }}"
},
{
"name": "country",
"value": "={{ $json.country }}"
},
{
"name": "city",
"value": "={{ $json.city }}"
},
{
"name": "source",
"value": "={{ $json.source }}"
},
{
"name": "campaign",
"value": "={{ $json.campaign }}"
},
{
"name": "budget",
"value": "={{ $json.budget }}"
},
{
"name": "propertyType",
"value": "={{ $json.propertyType }}"
},
{
"name": "notes",
"value": "={{ $json.notes }}"
},
{
"name": "externalId",
"value": "={{ $json.externalId }}"
}
]
},
"options": {}
},
"id": "push-to-crm",
"name": "Push to CRM",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
900,
300
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ JSON.stringify({ received: true }) }}"
},
"id": "respond",
"name": "Respond to Facebook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1120,
300
]
}
],
"connections": {
"Facebook Lead Webhook": {
"main": [
[
{
"node": "Transform FB Lead",
"type": "main",
"index": 0
}
]
]
},
"Transform FB Lead": {
"main": [
[
{
"node": "Skip if Invalid",
"type": "main",
"index": 0
}
]
]
},
"Skip if Invalid": {
"main": [
[
{
"node": "Push to CRM",
"type": "main",
"index": 0
}
]
]
},
"Push to CRM": {
"main": [
[
{
"node": "Respond to Facebook",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"tags": [
{
"name": "leads-egypt"
}
]
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
facebook-leads-to-crm. Uses httpRequest. Webhook trigger; 5 nodes.
Source: https://github.com/khaled-bit/Realstate/blob/9c3390c0143c912787ac6ee42ab0c6bb5c59b2d9/n8n-workflows/facebook-leads.json — 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.
Automatically qualify, score, and route inbound B2B leads using GPT-4o-mini — no manual review needed.
This workflow receives Bitrix24 deal updates via a webhook, fetches the deal and contact details, and uploads an offline Purchase conversion to the Google Ads Click Conversion API using the deal’s GCL
This workflow triggers on Bitrix24 deal updates, checks whether a deal is qualified and has a GCLID, then uploads an offline click conversion to the Google Ads API with hashed first-party customer ide
PostStack: Leady z DM → Google Sheets. Uses httpRequest, googleSheets. Webhook trigger; 18 nodes.
This workflow receives Zivvy CRM lead creation webhooks, verifies the HMAC signature, fetches lead details from the Zivvy API, and posts a formatted notification to Slack via an incoming webhook. Rece