Update Contact List
Shared 12/10/2025
10 views
Visual Workflow
JSON Code
{
"id": "J1SHuLVXUJw6cbFL",
"meta": {
"instanceId": "9f52db56bfb81303a4da8a94cd0a08e29ea243c73d8e2a83954d588aca1e0b03",
"templateCredsSetupCompleted": true
},
"name": "Update Contact List",
"tags": [],
"nodes": [
{
"id": "26fe8789-ed83-4b1b-8081-c1fbf9f4a270",
"name": "When clicking ‘Execute workflow’",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-880,
-16
],
"parameters": {},
"typeVersion": 1
},
{
"id": "e19687e5-4b83-4336-971c-b3970adccb04",
"name": "Delete Contacts",
"type": "n8n-nodes-base.httpRequest",
"position": [
-176,
-16
],
"parameters": {
"url": "=https://people.googleapis.com/v1/{{ $json.resourceName }}:deleteContact",
"method": "DELETE",
"options": {},
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleContactsOAuth2Api"
},
"credentials": {
"googleContactsOAuth2Api": {
"id": "nIaYkSXmtNkNdTGL",
"name": "Google Contacts account (Muhsin)"
}
},
"typeVersion": 4.2
},
{
"id": "4bbfd48b-5cf2-427f-a5b4-ec6e153dfc72",
"name": "Get many contacts",
"type": "n8n-nodes-base.googleContacts",
"position": [
-656,
-16
],
"parameters": {
"fields": [
"names",
"phoneNumbers"
],
"options": {},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"googleContactsOAuth2Api": {
"id": "nIaYkSXmtNkNdTGL",
"name": "Google Contacts account (Muhsin)"
}
},
"typeVersion": 1
},
{
"id": "a4d9e3e5-754f-4182-bb08-017fad460c64",
"name": "Code1",
"type": "n8n-nodes-base.code",
"position": [
-432,
-16
],
"parameters": {
"jsCode": "// 1. Prepare the data\n// If the input came in as one big list inside one item, we flatten it.\n// If it came in as separate items, we keep them.\nlet contactList = [];\n\nif (items.length === 1 && Array.isArray(items[0].json)) {\n // Case A: Input is one item containing a list (common in HTTP nodes)\n contactList = items[0].json;\n} else {\n // Case B: Input is already split into items\n contactList = items.map(item => item.json);\n}\n\n// 2. Define the Regex for \"Nessovo\", \"Nessovo 1\", \"nessovo 99\"\n// ^ = Start of name, \\s* = optional space, \\d* = optional numbers, $ = end of name, i = case insensitive\nconst regex = /^nessovo\\s*(\\d*|admin\\s*\\d*)$/i;\n\n// 3. Filter the list\nconst filteredContacts = contactList.filter(person => {\n \n const displayName = person.names?.displayName || \"\";\n const isTargetName = regex.test(displayName.trim());\n\n // Assuming you still require a mobile number to be present\n const hasMobile = person.phoneNumbers?.mobile?.length > 0;\n \n return isTargetName && hasMobile; \n});\n\n// 4. Return to n8n in the correct format\n// n8n requires the output to be wrapped in { json: ... }\nreturn filteredContacts.map(contact => {\n return { json: contact };\n});"
},
"typeVersion": 2,
"alwaysOutputData": true
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "3872455a-4202-430e-a03c-92451b5ecf7b",
"connections": {
"Code1": {
"main": [
[
{
"node": "Delete Contacts",
"type": "main",
"index": 0
}
]
]
},
"Get many contacts": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Get many contacts",
"type": "main",
"index": 0
}
]
]
}
}
}