AutomationFlowsSlack & Telegram › Qualify Facebook Lead Ads and Send Follow-ups with Gemini, Gmail, and Sheets

Qualify Facebook Lead Ads and Send Follow-ups with Gemini, Gmail, and Sheets

ByHassan @hassans on n8n.io

Turn every Facebook ad lead into a qualified, followed-up prospect within seconds. AI scores their intent, sends a personalized email tailored to their score, logs campaign intelligence to Google Sheets, and alerts you instantly to hot leads before they consider a competitor.…

Webhook trigger★★★★☆ complexityAI-powered22 nodesFacebook Lead Ads TriggerGoogle GeminiGoogle SheetsGmailWhatsAppSlack
Slack & Telegram Trigger: Webhook Nodes: 22 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #17258 — we link there as the canonical source.

This workflow follows the Gmail → Googlegemini recipe pattern — see all workflows that pair these two integrations.

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 →

Download .json
{
  "id": "n3PwH73s0iyQiwYY",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Facebook Lead Ads to AI-Qualified Follow-Up-n8nSubmission",
  "tags": [],
  "nodes": [
    {
      "id": "5b6f8118-751a-4493-b18d-1da009764793",
      "name": "Facebook Lead Ad Received",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1024,
        -192
      ],
      "parameters": {
        "path": "1731b816-3790-4709-8b69-a43380306f1a",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "7906484b-7bd1-4b23-a62f-a9d770448e8b",
      "name": "Extract & Normalize Lead Details",
      "type": "n8n-nodes-base.code",
      "position": [
        -704,
        -48
      ],
      "parameters": {
        "jsCode": "const body = $input.first().json.body || $input.first().json;\n\n// Handle two formats:\n// 1. Facebook field_data array (forwarded via Zapier/Make)\n// 2. Flat JSON (direct POST from website form or test)\nlet fields = {};\n\nif (body.field_data && Array.isArray(body.field_data)) {\n  for (const field of body.field_data) {\n    fields[field.name] = field.values?.[0] || null;\n  }\n} else {\n  fields = body;\n}\n\n// Generate a unique recordId\nconst recordId = body.id\n  || body.lead_id\n  || `webhook-${Date.now()}`;\n\nreturn [{\n  json: {\n    // Lead contact details\n    leadName:  fields['full_name']    || fields['name']          || null,\n    leadEmail: fields['email']        || fields['email_address'] || null,\n    leadPhone: fields['phone_number'] || fields['phone']         || null,\n\n    // Qualification fields\n    intent:    fields['are_you_looking_to_buy_sell_or_rent']\n               || fields['intent']    || null,\n    budget:    fields['what_is_your_budget_range']\n               || fields['budget']    || null,\n    timeline:  fields['what_is_your_buying_selling_timeline']\n               || fields['timeline']  || null,\n    situation: fields['what_best_describes_your_situation']\n               || fields['situation'] || null,\n\n    // Campaign metadata\n    leadId:     body.id          || body.lead_id     || recordId,\n    formId:     body.form_id     || null,\n    adId:       body.ad_id       || null,\n    adsetId:    body.adset_id    || null,\n    campaignId: body.campaign_id || null,\n    createdTime: new Date().toISOString(),\n\n    // Stable unique identifier\n    recordId:  recordId,\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "2ddb696c-7e19-4254-8816-1a7d262e8792",
      "name": "Facebook Lead Ads Trigger",
      "type": "n8n-nodes-base.facebookLeadAdsTrigger",
      "disabled": true,
      "position": [
        -1024,
        96
      ],
      "parameters": {
        "form": {
          "__rl": true,
          "mode": "list",
          "value": "17+1234567890",
          "cachedResultName": "Buyer Qualification Form"
        },
        "page": {
          "__rl": true,
          "mode": "list",
          "value": "1152070337998874",
          "cachedResultUrl": "https://facebook.com/1152070337998874",
          "cachedResultName": "QualMatic Real Estate Test"
        },
        "options": {}
      },
      "credentials": {
        "facebookLeadAdsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "70eef969-7ad5-4547-b35d-37a380eacc32",
      "name": "Qualify & Draft Follow-Up",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -496,
        -48
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-3-flash-preview"
        },
        "options": {
          "systemMessage": "You are a real estate lead qualification assistant.\nYou MUST output ONLY a raw JSON object.\nDo NOT include markdown, headers, bullet points, or backticks.\nYour entire response must start with { and end with }\n\nScore this Facebook lead ad submission and draft a \npersonalized follow-up email.\n\nSCORING RULES:\n- Hot: Pre-approved buyer OR seller with a timeline within \n  3 months OR motivated by life event (upsizing, relocating)\n- Warm: Active searcher with a budget, but financing is unclear \n  OR 3\u20136-month timeline\n- Cold: Early research, just browsing, no clear timeline \n  or budget\n\nEMAIL TONE BY SCORE:\n- Hot: Enthusiastic and action-oriented. Acknowledge their \n  specific situation. Invite them to book a consultation.\n- Warm: Friendly and helpful. Offer to answer questions \n  and share relevant listings or market info.\n- Cold: Light-touch, zero pressure. Position yourself as \n  a helpful resource for when they are ready.\n\nFormat email_body as two parts separated by \\n\\n:\n  Part 1: Greeting line only e.g., \"Hi {name},\"\n  Part 2: Message body 2\u20133 sentences maximum\n\nOUTPUT \u2014 your entire response must be exactly this structure:\n{\"score\":\"Hot or Warm or Cold\",\"reasoning\":\"one sentence\",\"email_subject\":\"short subject line\",\"email_body\":\"Hi {name},\\n\\nBody here.\"}"
        },
        "messages": {
          "values": [
            {
              "content": "=Lead name: {{ $json.leadName }}\nIntent (buy/sell/rent): {{ $json.intent }}\nBudget: {{ $json.budget }}\nTimeline: {{ $json.timeline }}\nSituation: {{ $json.situation }}"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3db05def-b3a1-404c-ad32-286c979cd06b",
      "name": "Parse AI Output",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        -48
      ],
      "parameters": {
        "jsCode": "// ============================================================\n// UPDATE THESE NODE NAMES IF YOU RENAME THEM ON THE CANVAS\nconst EXTRACT_NODE = 'Extract & Normalize Lead Details';\n// ============================================================\n\nconst leadData = $(EXTRACT_NODE).first().json;\nconst inputJson = $input.first().json;\n\n// Handle all possible Gemini response formats\nlet rawText = '';\n\nif (inputJson.score && inputJson.email_body) {\n  // Built-in Gemini node \u2014 already a parsed object\n  rawText = JSON.stringify(inputJson);\n} else if (typeof inputJson.output === 'string') {\n  // Built-in Gemini node \u2014 string output field\n  rawText = inputJson.output;\n} else if (inputJson.candidates?.[0]?.content?.parts?.[0]?.text) {\n  // HTTP Request node calling Gemini API directly\n  rawText = inputJson.candidates[0].content.parts[0].text;\n} else if (inputJson.content?.parts?.[0]?.text) {\n  rawText = inputJson.content.parts[0].text;\n}\n\n// Strip markdown fences\nconst cleaned = rawText\n  .replace(/```json\\s*/gi, '')\n  .replace(/```\\s*/gi, '')\n  .trim();\n\n// Parse with fallback\nlet parsed;\ntry {\n  parsed = JSON.parse(cleaned);\n} catch (e) {\n  parsed = {\n    score: 'Warm',\n    reasoning: 'AI parsing failed \u2014 manual review recommended.',\n    email_subject: `Thanks for your enquiry, ${leadData.leadName || 'there'}!`,\n    email_body: `Hi ${leadData.leadName || 'there'},\\n\\nThank you for reaching out. We received your enquiry and will be in touch shortly.`\n  };\n}\n\n// HTML formatter \u2014 same pattern as all previous templates\nfunction escapeHtml(text) {\n  if (!text) return '';\n  return text\n    .replace(/&/g, '&amp;')\n    .replace(/</g, '&lt;')\n    .replace(/>/g, '&gt;');\n}\n\nfunction formatEmailHtml(text) {\n  if (!text) return '';\n  const paragraphs = text\n    .split(/\\n\\s*\\n/)\n    .map(p => p.replace(/\\s+/g, ' ').trim())\n    .filter(Boolean);\n  return paragraphs.map(p => `<p>${escapeHtml(p)}</p>`).join('');\n}\n\n// Build agent notification HTML \u2014 includes campaign intelligence\nconst agentNotificationHtml = `\n  <p><strong>${parsed.score === 'Hot' ? '\ud83d\udd25 Hot Lead' : '\ud83d\udccb New Lead'} \u2014 Facebook Ad</strong></p>\n  <p>\n    <strong>Name:</strong> ${escapeHtml(leadData.leadName || 'Unknown')}<br>\n    <strong>Email:</strong> ${escapeHtml(leadData.leadEmail || 'Not provided')}<br>\n    <strong>Phone:</strong> ${escapeHtml(leadData.leadPhone || 'Not provided')}<br>\n    <strong>Intent:</strong> ${escapeHtml(leadData.intent || 'Not specified')}<br>\n    <strong>Budget:</strong> ${escapeHtml(leadData.budget || 'Not specified')}<br>\n    <strong>Timeline:</strong> ${escapeHtml(leadData.timeline || 'Not specified')}<br>\n    <strong>Situation:</strong> ${escapeHtml(leadData.situation || 'Not specified')}\n  </p>\n  <p>\n    <strong>AI Score:</strong> ${escapeHtml(parsed.score)}<br>\n    <strong>Reasoning:</strong> ${escapeHtml(parsed.reasoning)}\n  </p>\n  <hr>\n  <p><strong>\ud83d\udcca Campaign Intelligence</strong></p>\n  <p>\n    <strong>Facebook Lead ID:</strong> ${escapeHtml(leadData.leadId || 'N/A')}<br>\n    <strong>Form ID:</strong> ${escapeHtml(leadData.formId || 'N/A')}<br>\n    <strong>Ad ID:</strong> ${escapeHtml(leadData.adId || 'N/A (organic/test)')}<br>\n    <strong>Campaign ID:</strong> ${escapeHtml(leadData.campaignId || 'N/A (organic/test)')}<br>\n    <strong>Submitted:</strong> ${escapeHtml(leadData.createdTime || leadData.timestamp)}\n  </p>\n`;\n\nreturn [{\n  json: {\n    // Lead details \u2014 from Extract node\n    leadName:    leadData.leadName,\n    leadEmail:   leadData.leadEmail,\n    leadPhone:   leadData.leadPhone,\n    intent:      leadData.intent,\n    budget:      leadData.budget,\n    timeline:    leadData.timeline,\n    situation:   leadData.situation,\n    // Facebook metadata\n    leadId:      leadData.leadId,\n    formId:      leadData.formId,\n    adId:        leadData.adId,\n    adsetId:     leadData.adsetId,\n    campaignId:  leadData.campaignId,\n    createdTime: leadData.createdTime,\n    // AI qualification\n    score:       parsed.score,\n    reasoning:   parsed.reasoning,\n    // Email content\n    email_subject: parsed.email_subject,\n    email_body:    formatEmailHtml(parsed.email_body),\n    // Agent notification\n    agentNotificationHtml,\n    // Metadata\n    recordId:  leadData.recordId,\n    timestamp: leadData.timestamp\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "bb14627f-d245-450f-85e4-98521b3c4dbc",
      "name": "Has Email?",
      "type": "n8n-nodes-base.if",
      "position": [
        64,
        -208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cac6900a-c1e5-4fab-9a96-f0e5ffcd0475",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.leadEmail }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "d6f5718c-f402-478a-9893-eb10de18729f",
      "name": "Log to Facebook Leads Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        496,
        -192
      ],
      "parameters": {
        "columns": {
          "value": {
            "Ad ID": "={{ $('Parse AI Output').item.json.adId }}",
            "Email": "={{ $('Parse AI Output').item.json.leadEmail }}",
            "Phone": "={{ $('Parse AI Output').item.json.leadPhone }}",
            "Budget": "={{ $('Parse AI Output').item.json.budget }}",
            "Intent": "={{ $('Parse AI Output').item.json.intent }}",
            "Form ID": "={{ $('Parse AI Output').item.json.formId }}",
            "Timeline": "={{ $('Parse AI Output').item.json.timeline }}",
            "recordId": "={{ $('Parse AI Output').item.json.recordId }}",
            "Lead Name": "={{ $('Parse AI Output').item.json.leadName }}",
            "Situation": "={{ $('Parse AI Output').item.json.situation }}",
            "Timestamp": "={{ $('Parse AI Output').item.json.timestamp }}",
            "Lead Score": "={{ $('Parse AI Output').item.json.score }}",
            "Campaign ID": "={{ $('Parse AI Output').item.json.campaignId }}",
            "Email Subject": "={{ $('Parse AI Output').item.json.email_subject }}",
            "Agent Notified": "false",
            "Score Reasoning": "={{ $('Parse AI Output').item.json.reasoning }}",
            "Facebook Lead ID": "={{ $('Parse AI Output').item.json.leadId }}"
          },
          "schema": [
            {
              "id": "recordId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "recordId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lead Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Intent",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Intent",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Budget",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Budget",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Timeline",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timeline",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Situation",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Situation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Score",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lead Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Score Reasoning",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Score Reasoning",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Subject",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Notified",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Notified",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Facebook Lead ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Facebook Lead ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Form ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Form ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Ad ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Ad ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Campaign ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Campaign ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ucXKURObb5b_R7rLmWFqH9DafyHGngd6CnmdvHn5F-g/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "877c2f21-a95f-4773-b7ef-f11cca8366c9",
      "name": "Is Lead Hot?",
      "type": "n8n-nodes-base.if",
      "position": [
        704,
        -192
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "86d544e4-31d8-4e0e-94af-dfafd3a6cf29",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Parse AI Output').first().json.score.toLowerCase() }}",
              "rightValue": "hot"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "253c9fce-ef63-462f-aa96-73bddf1197d2",
      "name": "Notify Agent \u2014 Hot Lead",
      "type": "n8n-nodes-base.gmail",
      "position": [
        976,
        -368
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $('Parse AI Output').first().json.agentNotificationHtml }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "=\ud83d\udd25 Hot Facebook Lead \u2014 {{ $('Parse AI Output').first().json.leadName }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8b4f292f-e28f-4d57-bc50-a6455be5d85a",
      "name": "Send Follow-Up Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        272,
        -368
      ],
      "parameters": {
        "sendTo": "={{ $json.leadEmail }}",
        "message": "={{ $json.email_body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.email_subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4ebfa3af-efe1-40e7-ad8f-ca47c73cdf08",
      "name": "Has Phone?",
      "type": "n8n-nodes-base.if",
      "position": [
        80,
        160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ad5c61b6-8573-45ec-8d9d-a72a022abbb2",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.leadPhone }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "3cf32c0e-09b6-43a5-b275-445f9501ae2c",
      "name": "Send WhatsApp Follow-Up",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        336,
        144
      ],
      "parameters": {
        "textBody": "=Hi {{ $('Parse AI Output').first().json.leadName }}! Thanks for your enquiry. We received your details and will be in touch shortly.",
        "operation": "send",
        "phoneNumberId": "=YOUR_PHONE_NUMBER_ID",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('Parse AI Output').first().json.leadPhone }}"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b5663179-da14-48d9-b183-668a6bb07b9c",
      "name": "Notify Agent via Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        992,
        -32
      ],
      "parameters": {
        "text": "=\ud83d\udd25 *Hot Facebook Lead* \n*Name:* {{ $('Parse AI Output').first().json.leadName }} \n*Email:* {{ $('Parse AI Output').first().json.leadEmail }} \n*Phone:* {{ $('Parse AI Output').first().json.leadPhone }} \n*Intent:* {{ $('Parse AI Output').first().json.intent }} \n*Budget:* {{ $('Parse AI Output').first().json.budget }} \n*Score:* {{ $('Parse AI Output').first().json.score }} \n*Reasoning:* {{ $('Parse AI Output').first().json.reasoning }} \n\ud83d\udcca *Campaign:* {{ $('Parse AI Output').first().json.campaignId || 'Organic/Test' }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#hot-leads"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "7859e23f-30b6-4d3d-b721-a5f4a4d56ddc",
      "name": "Update Row: Agent Notified",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1232,
        -176
      ],
      "parameters": {
        "columns": {
          "value": {
            "recordId": "={{ $('Parse AI Output').first().json.recordId }}",
            "Agent Notified": "true"
          },
          "schema": [
            {
              "id": "recordId",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "recordId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lead Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Intent",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Intent",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Budget",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Budget",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Timeline",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timeline",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Situation",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Situation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Score",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lead Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Score Reasoning",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Score Reasoning",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Subject",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Notified",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Notified",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Facebook Lead ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Facebook Lead ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Form ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Form ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Ad ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Ad ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Campaign ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Campaign ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "recordId"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ucXKURObb5b_R7rLmWFqH9DafyHGngd6CnmdvHn5F-g/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "21d4885b-a343-430b-8b1a-2e818cd8411f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2016,
        -672
      ],
      "parameters": {
        "width": 688,
        "height": 1104,
        "content": "## Facebook Lead Ads to AI-Qualified Follow-Up\n\nWhen someone submits your Facebook Lead Ad form, this workflow qualifies their intent instantly using AI, sends a personalized follow-up email within seconds, and alerts you immediately for hot leads \u2014 before they've even put their phone down.\n\n### How it works\nA lead submits your Facebook ad form. Their details arrive via webhook instantly. AI (Gemini) reads their budget, timeline, and situation, then scores them as **Hot**, **Warm**, or **Cold** and drafts a personalized follow-up email tailored to their score. The email sends immediately via Gmail. Every lead logs to Google Sheets with full qualification data and campaign intelligence \u2014 so you can see which ads produce the best leads. Hot leads trigger an instant agent notification by email and Slack, so you follow up while the lead is still engaged.\n\n### Requirements\n- **Gmail** OAuth2 credential\n- **Google Sheets** OAuth2 credential\n- **Gemini** API key\n- **Google Sheets** \u2014 copy the *Facebook Leads Database* sheet template and link it to the Sheets nodes\n- **Slack** OAuth2 credential \u2014 optional, for Hot lead Slack notifications\n- **WhatsApp Business Cloud** credential + Phone Number ID \u2014 optional, for WhatsApp follow-up messages\n\n### Setup\n1. Connect **Gmail**, **Google Sheets**, and **Gemini API** credentials \u2014 all reused from other QualMatic templates.\n2. Copy the *Facebook Leads Database* sheet template and link it to the Sheets nodes.\n3. Update the agent email address in the \"Notify Agent \u2014 Hot Lead\" node.\n4. Choose your trigger (see trigger section below).\n5. **Slack is optional** \u2014 connect your Slack credential to the Slack node for a second Hot lead alert channel, or leave it disconnected.\n6. **WhatsApp is optional** \u2014 connect your WhatsApp Business Cloud credential and set your Phone Number ID in the \"Send WhatsApp Follow-Up\" node.\n\n### Customization\n- Edit the AI prompt to adjust scoring criteria or tone.\n- Add Warm lead agent notifications by duplicating the Hot lead branch.\n- Extend with additional form fields by mapping them in the Extract node."
      },
      "typeVersion": 1
    },
    {
      "id": "efc89687-6e42-4113-bf21-386672210c56",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1248,
        -672
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 416,
        "height": 1024,
        "content": "##  Choose Your Trigger\n\n**Option A \u2014 Webhook (active, default)** \nWorks immediately with any lead source, Facebook Lead Ads via Zapier or Make, website forms, or landing pages. No Facebook app setup needed.\n\n**Option B \u2014 Facebook Lead Ads (disabled)**\nConnects directly to Facebook Lead Ads without a forwarder. Requires a permanent public n8n URL and Meta Developer app configuration. Enable this node and disable the Webhook node to use it. "
      },
      "typeVersion": 1
    },
    {
      "id": "2cbdad9d-28c6-4ffe-9bab-69d27b47ba2d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -672
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 272,
        "height": 1024,
        "content": "## Extract & Normalize Lead Details\nTransforms Facebook's field_data array format into clean, named fields used by all downstream nodes. Also handles flat JSON from direct webhook POST requests. Campaign metadata (Ad ID, Campaign ID) is captured here\nfor business intelligence logging."
      },
      "typeVersion": 1
    },
    {
      "id": "1134e5ea-0fe2-4267-80c2-f3fb7d462b7d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -672
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 544,
        "height": 1024,
        "content": "## Qualify & Draft Follow-Up\nOne Gemini AI call scores the lead as Hot, Warm, or Cold based on budget, timeline, and situation, then drafts a personalized follow-up email tailored to their score.\nHot leads get an action-oriented email.\nWarm leads get a friendly, helpful email.\nCold leads get a light-touch, zero-pressure email.\nIf AI fails, a fallback email still sends automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "6d4363e6-af98-4d04-b677-91dcd3a4514e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -672
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 1376,
        "height": 1024,
        "content": "## Email, Log & Agent Alert\nA follow-up email sends immediately if an email address was provided. Every lead logs to Google Sheets with full qualification data and campaign intelligence columns showing which ad and campaign generated the lead.\nHot leads trigger an instant agent notification by email and optionally Slack, so you follow up while the lead is still engaged. WhatsApp follow-up is optional and works when configured."
      },
      "typeVersion": 1
    },
    {
      "id": "06c108f3-50c2-4fd8-b7a4-b2ac4e48f974",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -96
      ],
      "parameters": {
        "color": 3,
        "width": 272,
        "height": 624,
        "content": "\n\n\n\n\n\n\n\n\n\n\n## Form Field Names Must Match\nThis node maps Facebook form field names to clean variables.\nIf you rename any question in your Facebook Lead Ad form,\nupdate the matching field name in this Code node or data\nwill not extract correctly.\nField names use lowercase with underscores \u2014 check the\nexact names in your webhook test payload."
      },
      "typeVersion": 1
    },
    {
      "id": "892081a9-6747-4829-8883-2649d3a12fd6",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        -512
      ],
      "parameters": {
        "color": 3,
        "width": 464,
        "height": 304,
        "content": "## Update Agent Email Address\nReplace the placeholder email in this node with the agent's real email address before going live."
      },
      "typeVersion": 1
    },
    {
      "id": "799540a6-1bbd-40f2-b77f-ca52cb4bb505",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        112
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 512,
        "content": "\n\n\n\n\n\n\n\n\n## WhatsApp Setup Required Before Using\n1. Add your WhatsApp Business Cloud credential in n8n. Settings \u2192 Credentials.\n2. Replace YOUR_PHONE_NUMBER_ID in the Sender Phone Number field with your actual numeric Phone Number ID from Meta Developer App \u2192 WhatsApp \u2192 API Setup.\n3. Ensure your recipient numbers are added to your WhatsApp test recipient list in Meta Developer App.\n4. Connect this node from the Parse AI Output node output once configured."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "64e037eb-b207-4a8f-b059-a8c8ecd8559c",
  "nodeGroups": [],
  "connections": {
    "Has Email?": {
      "main": [
        [
          {
            "node": "Send Follow-Up Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log to Facebook Leads Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Phone?": {
      "main": [
        [
          {
            "node": "Send WhatsApp Follow-Up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Lead Hot?": {
      "main": [
        [
          {
            "node": "Notify Agent \u2014 Hot Lead",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notify Agent via Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Output": {
      "main": [
        [
          {
            "node": "Has Email?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Has Phone?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Follow-Up Email": {
      "main": [
        [
          {
            "node": "Log to Facebook Leads Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Agent via Slack": {
      "main": [
        []
      ]
    },
    "Facebook Lead Ad Received": {
      "main": [
        [
          {
            "node": "Extract & Normalize Lead Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Facebook Lead Ads Trigger": {
      "main": [
        [
          {
            "node": "Extract & Normalize Lead Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Agent \u2014 Hot Lead": {
      "main": [
        [
          {
            "node": "Update Row: Agent Notified",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Qualify & Draft Follow-Up": {
      "main": [
        [
          {
            "node": "Parse AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Facebook Leads Sheet": {
      "main": [
        [
          {
            "node": "Is Lead Hot?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract & Normalize Lead Details": {
      "main": [
        [
          {
            "node": "Qualify & Draft Follow-Up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Turn every Facebook ad lead into a qualified, followed-up prospect within seconds. AI scores their intent, sends a personalized email tailored to their score, logs campaign intelligence to Google Sheets, and alerts you instantly to hot leads before they consider a competitor.…

Source: https://n8n.io/workflows/17258/ — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Slack & Telegram

Stop starting your day by drowning in unread emails. This workflow runs every morning and turns your Gmail inbox into a clean, prioritized briefing — automatically organized into what needs your atten

Gmail, Google Gemini, Google Docs +3
Slack & Telegram

This workflow is a complete, production-ready solution for recovering abandoned carts in Shopify stores using a multi-channel, multi-touch approach. It automates personalized follow-ups via Email, SMS

HTTP Request, Shopify, SendGrid +5
Slack & Telegram

This workflow lets customers order and refill prescriptions via Telegram by extracting medicines from prescription images with Google Gemini, checking and updating inventory in Google Sheets, and send

Telegram Trigger, Telegram, Google Gemini +3
Slack & Telegram

This workflow runs weekly to pull HR datasets from Google Sheets, calculate rule-based attrition risk signals, and enrich them with an OpenAI (GPT-4o-mini) risk assessment. It logs results back to Goo

Error Trigger, Slack, Google Sheets +3
Slack & Telegram

This workflow runs daily, pulls birthdays from Google Contacts, generates personalized birthday copy with OpenAI, sends greetings via Gmail, WhatsApp Business Cloud, and Telegram when available, and p

Google Contacts, OpenAI, Gmail +3