{
  "name": "Tag new GoHighLevel contacts using 1Lookup phone and email checks",
  "nodes": [
    {
      "parameters": {
        "content": "## Tag new GoHighLevel contacts using 1Lookup phone and email checks\n\n## Who it's for\nAgencies and sales teams on GoHighLevel who call and text new leads, and want dead numbers, landlines and fake emails tagged before a campaign reaches them.\n\n## How it works\n1. A GoHighLevel workflow sends each new contact to this workflow's webhook.\n2. 1Lookup checks the phone number: active or not, mobile or landline, and do-not-call status.\n3. If the contact has an email, a second 1Lookup check says whether it will deliver.\n4. The contact gets tags in GoHighLevel: `1lookup-approve`, `1lookup-review` or `1lookup-block`, plus `1lookup-landline`, `1lookup-dnc` and `1lookup-bad-email` when they apply. Its existing tags stay.\n\n## How to set up\n1. Copy your API key from the **API Keys** page of your 1Lookup dashboard.\n2. In n8n, add a **1Lookup API** credential with that key. The 1Lookup node is verified by n8n: on n8n Cloud, search for 1Lookup in the nodes panel. On a self-hosted instance, install `@momentum-labs/n8n-nodes-1lookup` once from **Settings > Community Nodes**.\n3. Add a **HighLevel OAuth2** credential to **Add tags in GoHighLevel** (it needs the contacts.write scope).\n4. Copy the **Production URL** from **New contact from GoHighLevel**, then activate this workflow.\n5. In GoHighLevel, create a workflow with the trigger **Contact Created** and the action **Webhook** (method POST, the URL from step 4).\n\n## How to customize\n- Use the tags in GoHighLevel: for example, keep `1lookup-block` and `1lookup-landline` contacts out of SMS campaigns.\n- Rename the tags in **Build tags**.\n- If your webhook sends other field names, change them in **Contact fields**.",
        "height": 840,
        "width": 560
      },
      "id": "21814e64-e6f3-4529-8051-61581ab03754",
      "name": "Template overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -680,
        -300
      ]
    },
    {
      "parameters": {
        "content": "## 1. Receive the new contact\nGoHighLevel posts each new contact here. Contacts with neither a phone nor an email are skipped.",
        "height": 380,
        "width": 680,
        "color": 7
      },
      "id": "793fdb0f-ea9c-4440-95c2-c3ab058152bf",
      "name": "Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -200
      ]
    },
    {
      "parameters": {
        "content": "## 2. Check the phone, then the email\nEach check only runs when the contact has that field.",
        "height": 440,
        "width": 900,
        "color": 7
      },
      "id": "e05eecfd-d884-468e-b7f6-200dd85400c5",
      "name": "Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        640,
        -260
      ]
    },
    {
      "parameters": {
        "content": "## 3. Tag the contact\nAdds the tags without removing any the contact already has.",
        "height": 380,
        "width": 480,
        "color": 7
      },
      "id": "1ebe7f93-d30e-45f7-b115-9cbdffb208ba",
      "name": "Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1560,
        -200
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "e09c1aed-efaf-4380-bf95-4ed6d214de5a",
        "options": {}
      },
      "id": "00449466-1c33-4970-954a-b388185aeb2a",
      "name": "New contact from GoHighLevel",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "e09c1aed-efaf-4380-bf95-4ed6d214de5a"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "56e873fe-ef35-4f12-a551-f19eb9b09a0b",
              "name": "contact_id",
              "value": "={{ $json.body.contact_id }}",
              "type": "string"
            },
            {
              "id": "b68a6b7c-bba7-410f-917e-2c4d259e6bef",
              "name": "phone",
              "value": "={{ $json.body.phone ?? '' }}",
              "type": "string"
            },
            {
              "id": "1f646a10-a565-4c39-91c8-dbca709fa502",
              "name": "email",
              "value": "={{ $json.body.email ?? '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "8c8571b8-d276-4b87-a4b9-d283f6494609",
      "name": "Contact fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "f0ae57d3-1bf8-4470-ae04-15db440425cb",
              "leftValue": "={{ $json.phone }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            },
            {
              "id": "8f7ffd16-4633-4db6-be41-80acb59d4a5c",
              "leftValue": "={{ $json.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "or"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "id": "b3b76b2d-ac09-4fdc-b427-e7953309d94c",
      "name": "Has a phone or an email",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "4ea58a45-f9e9-40ca-8478-25646c3cc9d9",
              "leftValue": "={{ $('Contact fields').item.json.phone }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "id": "225f95c0-e534-400e-9d81-4f54d5590200",
      "name": "Has a phone",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        680,
        0
      ]
    },
    {
      "parameters": {
        "resource": "phone",
        "operation": "validate",
        "phoneNumber": "={{ $('Contact fields').item.json.phone }}",
        "simplify": true
      },
      "id": "58421507-5502-4a69-ba83-b121deedec28",
      "name": "Validate phone number",
      "type": "@momentum-labs/n8n-nodes-1lookup.oneLookup",
      "typeVersion": 1,
      "position": [
        900,
        -100
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "1d46338e-306d-4fb2-8494-c92f7d76082b",
              "leftValue": "={{ $('Contact fields').item.json.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "id": "93fd9ee2-3e0e-436a-abfc-d68a873c03eb",
      "name": "Has an email",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1120,
        0
      ]
    },
    {
      "parameters": {
        "resource": "email",
        "operation": "validate",
        "email": "={{ $('Contact fields').item.json.email }}",
        "simplify": true
      },
      "id": "4fcd7edb-7b2d-4b0d-a4ab-da9b5e9533ce",
      "name": "Validate email",
      "type": "@momentum-labs/n8n-nodes-1lookup.oneLookup",
      "typeVersion": 1,
      "position": [
        1340,
        -100
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Turn the phone check and the optional email check into GoHighLevel tags for this contact.\nconst contact = $('Contact fields').item.json;\nconst phone = $('Validate phone number').isExecuted ? $('Validate phone number').item.json : null;\nconst email = $('Validate email').isExecuted ? $('Validate email').item.json : null;\nconst actions = [phone?.recommendations?.primary_action, email?.recommendations?.primary_action].filter(Boolean);\nconst action = actions.includes('BLOCK') ? 'block' : actions.includes('REVIEW') ? 'review' : actions.length ? 'approve' : null;\nconst tags = [action ? `1lookup-${action}` : '1lookup-error'];\nif (String(phone?.classification?.line_type ?? '').toUpperCase() === 'LANDLINE') tags.push('1lookup-landline');\nif (/^(true|yes)$/i.test(String(phone?.insights?.compliance?.dnc_listed ?? ''))) tags.push('1lookup-dnc');\nif (String(email?.classification?.deliverability_status ?? '').toUpperCase() === 'UNDELIVERABLE') tags.push('1lookup-bad-email');\nreturn { contact_id: contact.contact_id, tags };"
      },
      "id": "aa6cbb65-0e14-4347-845d-b3215783e4ba",
      "name": "Build tags",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1600,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://services.leadconnectorhq.com/contacts/{{ $json.contact_id }}/tags",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "highLevelOAuth2Api",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Version",
              "value": "2021-07-28"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ tags: $json.tags }) }}",
        "options": {}
      },
      "id": "6c733f13-27da-4226-83be-ace4cc21b6f2",
      "name": "Add tags in GoHighLevel",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1820,
        0
      ]
    }
  ],
  "connections": {
    "New contact from GoHighLevel": {
      "main": [
        [
          {
            "node": "Contact fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contact fields": {
      "main": [
        [
          {
            "node": "Has a phone or an email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has a phone or an email": {
      "main": [
        [
          {
            "node": "Has a phone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has a phone": {
      "main": [
        [
          {
            "node": "Validate phone number",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Has an email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate phone number": {
      "main": [
        [
          {
            "node": "Has an email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has an email": {
      "main": [
        [
          {
            "node": "Validate email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate email": {
      "main": [
        [
          {
            "node": "Build tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build tags": {
      "main": [
        [
          {
            "node": "Add tags in GoHighLevel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}