Struggling with IF Node

I have used the HTTP node to search access a Mautic database and search for contacts by email address and return all data on the contacts.

Then I am using an IF node to check if the 1st name of a source record from another data base matches the 1st name of the record from Mautic. But I am having hassles mapping the the IF node to look at the correct firstname in Mautic. Each Mautic contact has a unique contact ID and the mapping of the expression using the node tree, includes that unique contact ID, the absolute number. eg

{{$json["contacts"]["11060"]["fields"]["all"]["firstname"]}}

I need to query the firstname for ALL the contacts returned with the HTTP query, and having that contact ID no. in the expression means only that particular contact is being search.

This is how the Mautic contact record is returned with the HTTP query. It’s a lot of data! (I only need the “firstname” returned if there is way to limit data returned?)

[
{
"total": "1",
"contacts": {
"11060": {
"isPublished": true,
"dateAdded": "2022-01-21T06:25:53+00:00",
"dateModified": "2022-01-23T12:03:09+00:00",
"createdBy": 4,
"createdByUser": "Robin Tindall",
"modifiedBy": 4,
"modifiedByUser": "Robin Tindall",
"id": 11060,
"points": 0,
"color": null,
"fields": {
"core": {
"last_active": {
"id": "60",
"label": "Date Last Active",
"alias": "last_active",
"type": "datetime",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"firstname": {
"id": "2",
"label": "First Name",
"alias": "firstname",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": "Luke",
"normalizedValue": "Luke"
},
"lastname": {
"id": "3",
"label": "Last Name",
"alias": "lastname",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": "Johnson",
"normalizedValue": "Johnson"
},
"email": {
"id": "6",
"label": "Email",
"alias": "email",
"type": "email",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": "[email protected]",
"normalizedValue": "[email protected]"
},
"phone": {
"id": "8",
"label": "Phone",
"alias": "phone",
"type": "tel",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"mobile": {
"id": "7",
"label": "Mobile",
"alias": "mobile",
"type": "tel",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": "073 2569477",
"normalizedValue": "redacted"
},
"address1": {
"id": "11",
"label": "Address Line 1",
"alias": "address1",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"address2": {
"id": "12",
"label": "Address Line 2",
"alias": "address2",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"city": {
"id": "13",
"label": "City",
"alias": "city",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"state": {
"id": "14",
"label": "State",
"alias": "state",
"type": "region",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"zipcode": {
"id": "15",
"label": "Zip Code",
"alias": "zipcode",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"country": {
"id": "16",
"label": "Country",
"alias": "country",
"type": "country",
"group": "core",
"object": "lead",
"is_fixed": "1",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"dob": {
"id": "44",
"label": "DOB",
"alias": "dob",
"type": "date",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"club": {
"id": "45",
"label": "Club",
"alias": "club",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"gender": {
"id": "46",
"label": "Gender",
"alias": "gender",
"type": "select",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:1:{s:4:"list";a:2:{i:0;a:2:{s:5:"label";s:6:"Female";s:5:"value";s:1:"F";}i:1;a:2:{s:5:"label";s:4:"Male";s:5:"value";s:1:"M";}}}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"emergency_contact_person": {
"id": "47",
"label": "Emergency Contact Person",
"alias": "emergency_contact_person",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"emergency_contact_person1": {
"id": "48",
"label": "Emergency Contact Person Contact No.",
"alias": "emergency_contact_person1",
"type": "tel",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"qualification_cv": {
"id": "49",
"label": "Qualification CV",
"alias": "qualification_cv",
"type": "textarea",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"id_number": {
"id": "53",
"label": "ID Number",
"alias": "id_number",
"type": "number",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:2:{s:9:"roundmode";s:1:"3";s:9:"precision";s:0:"";}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"your_t_shirt_size": {
"id": "54",
"label": "Your T shirt Size",
"alias": "your_t_shirt_size",
"type": "select",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:1:{s:4:"list";a:6:{i:0;a:2:{s:5:"label";s:7:"X small";s:5:"value";s:7:"X small";}i:1;a:2:{s:5:"label";s:5:"Small";s:5:"value";s:5:"Small";}i:2;a:2:{s:5:"label";s:6:"Medium";s:5:"value";s:6:"Medium";}i:3;a:2:{s:5:"label";s:5:"Large";s:5:"value";s:5:"Large";}i:4;a:2:{s:5:"label";s:7:"X large";s:5:"value";s:7:"X large";}i:5;a:2:{s:5:"label";s:8:"XX large";s:5:"value";s:8:"XX large";}}}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"membership_date": {
"id": "61",
"label": "Membership date",
"alias": "membership_date",
"type": "date",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"date_of_joining": {
"id": "62",
"label": "date of joining",
"alias": "date_of_joining",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"f_union": {
"id": "67",
"label": "Union",
"alias": "f_union",
"type": "text",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"person_transferring_in_em": {
"id": "78",
"label": "Person Transferring In Email Address",
"alias": "person_transferring_in_em",
"type": "email",
"group": "core",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
}
},
"social": {
"csa_no": {
"id": "43",
"label": "CSA No",
"alias": "csa_no",
"type": "number",
"group": "social",
"object": "lead",
"is_fixed": "0",
"properties": "a:2:{s:9:"roundmode";s:1:"3";s:9:"precision";s:0:"";}",
"default_value": null,
"value": 4810,
"normalizedValue": 4810
},
"csa_proficiency_rating": {
"id": "68",
"label": "CSA Proficiency Rating",
"alias": "csa_proficiency_rating",
"type": "text",
"group": "social",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"csa_license_type": {
"id": "69",
"label": "CSA LIcense Type",
"alias": "csa_license_type",
"type": "text",
"group": "social",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"csa_license_expiry_date": {
"id": "70",
"label": "CSA License Expiry Date",
"alias": "csa_license_expiry_date",
"type": "date",
"group": "social",
"object": "lead",
"is_fixed": "0",
"properties": "a:0:{}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"csa_race_eligible": {
"id": "71",
"label": "CSA Race Eligible?",
"alias": "csa_race_eligible",
"type": "select",
"group": "social",
"object": "lead",
"is_fixed": "0",
"properties": "a:1:{s:4:"list";a:2:{i:0;a:2:{s:5:"label";s:3:"Yes";s:5:"value";s:3:"Yes";}i:1;a:2:{s:5:"label";s:2:"No";s:5:"value";s:2:"No";}}}",
"default_value": null,
"value": null,
"normalizedValue": null
},
"if_not_eligible_why": {
"id": "72",
"label": "If not eligible, why",
"alias": "if_not_eligible_why",
"type": "textarea",
"group": "social",
"object": "lead",
"is_fixed": "0",
"properties": "a:1:{s:9:"allowHtml";s:0:"";}",
"default_value": null,
"value": null,
"normalizedValue": null
}
},
"professional": {
"discipline": {
"id": "63",
"label": "Discipline",
"alias": "discipline",
"type": "select",
"group": "professional",
"object": "lead",
"is_fixed": "0",
"properties": "a:1:{s:4:"list";a:5:{i:0;a:2:{s:5:"label";s:7:"Surfski";s:5:"value";s:7:"Surfski";}i:1;a:2:{s:5:"label";s:3:"SUP";s:5:"value";s:3:"SUP";}i:2;a:2:{s:5:"label";s:5:"Kayak";s:5:"value";s:5:"Kayak";}i:3;a:2:{s:5:"label";s:5:"Prone";s:5:"value";s:5:"Prone";}i:4;a:2:{s:5:"label";s:16:"Coastal Row boat";s:5:"value";s:16:"Coastal Row boat";}}}",
"default_value": null,
"value": null,
"normalizedValue": null
}
},
"personal": {
"which_course": {
"id": "65",
"label": "Which Course?",
"alias": "which_course",
"type": "select",
"group": "personal",
"object": "lead",
"is_fixed": "0",
"properties": "a:1:{s:4:"list";a:3:{i:0;a:2:{s:5:"label";s:16:"Full 27km Course";s:5:"value";s:16:"Full 27km Course";}i:1;a:2:{s:5:"label";s:18:"Medium 15km Course";s:5:"value";s:18:"Medium 15km Course";}i:2;a:2:{s:5:"label";s:24:"Short 8km Inshore Course";s:5:"value";s:24:"Short 8km Inshore Course";}}}",
"default_value": null,
"value": null,
"normalizedValue": null
}
},
"all": {
"id": "11060",
"last_active": null,
"firstname": "Luke",
"lastname": "Johnson",
"email": "[email protected]",
"phone": null,
"mobile": "redacted",
"address1": null,
"address2": null,
"city": null,
"state": null,
"zipcode": null,
"country": null,
"dob": null,
"club": null,
"gender": null,
"emergency_contact_person": null,
"emergency_contact_person1": null,
"qualification_cv": null,
"id_number": null,
"your_t_shirt_size": null,
"membership_date": null,
"date_of_joining": null,
"f_union": null,
"person_transferring_in_em": null,
"csa_no": 4810,
"csa_proficiency_rating": null,
"csa_license_type": null,
"csa_license_expiry_date": null,
"csa_race_eligible": null,
"if_not_eligible_why": null,
"discipline": null,
"which_course": null
}
},
"lastActive": null,
"owner": null,
"ipAddresses": [
],
"tags": [
{
"id": 94,
"tag": "n8nNew"
}
],
"utmtags": [
],
"stage": null,
"dateIdentified": "2022-01-21T06:25:53+00:00",
"preferredProfileImage": "gravatar",
"doNotContact": [
],
"frequencyRules": [
]
}
}
},

here is the tail end of a long and complex automation.

Why can’t you use the Mautic node for this?
I ask since depending on how you have your mautic search setup you might get more than one record per email searched…and it can open up a hose of other mapping issues for the IF node and more.

The idea is to control your data and the variables of how your data is presented as much as possible to make sure you are getting the result you want from the n8n flow you are creating.

1 Like

Thanks @David_Go , that worked!

I used the HTTP node as I was getting no love from the Mautic Node. I tried again and it worked! I guess I could not see the forest for the trees and needed to step away from the computer for a while.

Thanks for your continued help!

3 Likes

My pleasure @Robm !
Always remember the KISS formula. - Keep It Short & Simple … Then you can grow :slight_smile:
Trust me, I have the same challenge each and every day, overcomplicating things then taking a break and seeing the solution right before my very eyes :slight_smile:

2 Likes