{
  "name": "LEVRYO - Facebook Lead Ads to HubSpot",
  "nodes": [
    {
      "parameters": {
        "page": { "__rl": true, "mode": "list", "value": "" },
        "form": { "__rl": true, "mode": "list", "value": "" },
        "options": {}
      },
      "id": "fb-trigger",
      "name": "Facebook Lead Ads Trigger",
      "type": "n8n-nodes-base.facebookLeadAdsTrigger",
      "typeVersion": 1,
      "position": [0, 0],
      "notes": "Select your Facebook Page and the lead form. Requires a Facebook Lead Ads credential with leads_retrieval permission."
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "f1", "name": "email", "value": "={{ $json.email || $json.field_data?.email || '' }}", "type": "string" },
            { "id": "f2", "name": "first_name", "value": "={{ $json.first_name || $json.full_name || '' }}", "type": "string" },
            { "id": "f3", "name": "phone", "value": "={{ $json.phone_number || $json.phone || '' }}", "type": "string" },
            { "id": "f4", "name": "source", "value": "Facebook Lead Ad", "type": "string" },
            { "id": "f5", "name": "received_at", "value": "={{ $now.toISO() }}", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "map-fields",
      "name": "Map Lead Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [240, 0],
      "notes": "Field names on the left must match your HubSpot properties. Change the expressions on the right to match the question names in your Meta lead form."
    },
    {
      "parameters": {
        "resource": "contact",
        "operation": "upsert",
        "email": "={{ $json.email }}",
        "additionalFields": {
          "firstName": "={{ $json.first_name }}",
          "phoneNumber": "={{ $json.phone }}",
          "leadStatus": "NEW"
        }
      },
      "id": "hubspot-upsert",
      "name": "HubSpot Create or Update Contact",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2,
      "position": [480, 0],
      "notes": "Uses a HubSpot private app token. The app needs crm.objects.contacts.read and crm.objects.contacts.write scopes."
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": { "__rl": true, "mode": "name", "value": "#leads" },
        "text": "=New Facebook lead\nName: {{ $('Map Lead Fields').item.json.first_name }}\nEmail: {{ $('Map Lead Fields').item.json.email }}\nPhone: {{ $('Map Lead Fields').item.json.phone }}",
        "otherOptions": {}
      },
      "id": "slack-alert",
      "name": "Slack Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [720, 0],
      "notes": "Change #leads to the channel your sales team watches."
    }
  ],
  "connections": {
    "Facebook Lead Ads Trigger": { "main": [[{ "node": "Map Lead Fields", "type": "main", "index": 0 }]] },
    "Map Lead Fields": { "main": [[{ "node": "HubSpot Create or Update Contact", "type": "main", "index": 0 }]] },
    "HubSpot Create or Update Contact": { "main": [[{ "node": "Slack Alert", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "meta": { "templateCredsSetupCompleted": false },
  "tags": []
}
