Hi,
I’m looking to use n8n to automate some work with Hubspot. I’m struggling at the moment with the find contacts nodes.
If I have an array of items as an output => I only get results for items that actually exists in Hubspot so it breaks all others nodes… Is it something intended? Am I missing something?
{
"name": "Leads",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
60,
310
]
},
{
"parameters": {
"resource": "message",
"operation": "getAll",
"limit": "=10",
"additionalFields": {
"format": "resolved",
"q": "=from:([email protected]) AND NOT label:n8nDone"
}
},
"name": "retrieve Formation emails",
"type": "n8n-nodes-base.gmail",
"typeVersion": 1,
"position": [
360,
310
],
"credentials": {
"gmailOAuth2": "gmail"
}
},
{
"parameters": {
"conditions": {
"boolean": [],
"number": [
{
"value1": "={{Object.keys($json).length}}",
"operation": "larger"
}
],
"string": []
}
},
"name": "IF",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1060,
310
]
},
{
"parameters": {
"resource": "contact",
"operation": "search",
"limit": 1,
"filterGroupsUi": {
"filterGroupsValues": [
{
"filtersUi": {
"filterValues": [
{
"propertyName": "email",
"value": "={{$json[\"email\"]}}"
}
]
}
}
]
},
"additionalFields": {}
},
"name": "Find contact",
"type": "n8n-nodes-base.hubspot",
"typeVersion": 1,
"position": [
820,
310
],
"alwaysOutputData": false,
"credentials": {
"hubspotApi": "Hubspot"
}
},
{
"parameters": {
"functionCode": "var data = [];\nitems.forEach(function(item){\n var text = item.json.textAsHtml;\n var place = (text.split('Votre établissement : ')[1]).split('<br/>')[0];\n var zipCode = place.split(' ')[1];\n var name = (text.split('Demandeur : ')[1]).split('<br/>')[0]; \n var lastName = name.split(\" \")[0];\n data.push({\n json:{\n emailId: item.json.id,\n place:place,\n zipCode: zipCode,\n city: (place.split(zipCode)[1]),\n name:name,\n lastName:lastName,\n firstName:name.split(lastName+\" \")[1],\n trainingName:(text.split('souhaitée : ')[1]).split('<br/>')[0],\n education: (text.split('Niveau de formation : ')[1]).split('<br/>')[0],\n phone: (text.split('Tél : ')[1]).split('<br/>')[0],\n message: (text.split('Message du candidat :')[1]).split('Adresse :')[0],\n email: (text.split(\"mailto:\")[1]).split(\"\\\"\")[0]\n }\n });\n});\nreturn data;"
},
"name": "Parse data (formation)",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
580,
310
]
},
{
"parameters": {
"resource": "contact",
"email": "={{$node[\"Parse data (formation)\"].json[\"email\"]}}",
"additionalFields": {
"customPropertiesUi": {
"customPropertiesValues": [
{
"property": "contact_wensei",
"value": "true"
}
]
},
"firstName": "={{$node[\"Parse data (formation)\"].json[\"firstName\"]}}",
"lastName": "={{$node[\"Parse data (formation)\"].json[\"lastName\"]}}",
"phoneNumber": "={{$node[\"Parse data (formation)\"].json[\"phone\"]}}"
}
},
"name": "Hubspot",
"type": "n8n-nodes-base.hubspot",
"typeVersion": 1,
"position": [
1070,
640
],
"credentials": {
"hubspotApi": "Hubspot"
}
},
{
"parameters": {
"stage": "=appointmentscheduled",
"additionalFields": {
"dealName": "={{$node[\"Parse data (formation)\"].json[\"name\"]}}",
"amount": "0",
"associatedVids": "={{$node[\"IF\"].json[\"id\"]}}"
}
},
"name": "Hubspot1",
"type": "n8n-nodes-base.hubspot",
"typeVersion": 1,
"position": [
1260,
290
],
"credentials": {
"hubspotApi": "Hubspot"
}
},
{
"parameters": {
"resource": "messageLabel",
"messageId": "={{$node[\"Parse data (formation)\"].json[\"emailId\"]}}",
"labelIds": [
"Label_2575473674857323163"
]
},
"name": "Gmail",
"type": "n8n-nodes-base.gmail",
"typeVersion": 1,
"position": [
1490,
290
],
"credentials": {
"gmailOAuth2": "gmail"
}
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "retrieve Formation emails",
"type": "main",
"index": 0
}
]
]
},
"retrieve Formation emails": {
"main": [
[
{
"node": "Parse data (formation)",
"type": "main",
"index": 0
}
]
]
},
"Find contact": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"IF": {
"main": [
[
{
"node": "Hubspot1",
"type": "main",
"index": 0
}
],
[
{
"node": "Hubspot",
"type": "main",
"index": 0
}
]
]
},
"Parse data (formation)": {
"main": [
[
{
"node": "Find contact",
"type": "main",
"index": 0
}
]
]
},
"Hubspot": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"Hubspot1": {
"main": [
[]
]
}
},
"active": false,
"settings": {},
"id": "1"
}

