IF Filter does not work with Hubspot Trigger node

I use Hubspot Trigger to 1) get all contacts from google and 2) filter google contacts by contactId I get from Trigger. But the IF node does not find the match. In a “manual” test automation without Hubspot Trigger Node it works fine, but not in combination with the trigger. Any ideas whats wrong here?

{
  "nodes": [
    {
      "parameters": {
        "appId": "236187",
        "event": "contact.propertyChange",
        "property": "nei",
        "additionalFields": {}
      },
      "name": "Hubspot Trigger",
      "type": "n8n-nodes-base.hubspotTrigger",
      "typeVersion": 1,
      "position": [
        550,
        330
      ],
      "webhookId": "d8b2dcec-c72f-4fd7-83dd-cde55e496124",
      "credentials": {
        "hubspotDeveloperApi": "HubSpot Test Trigger Google Contacts"
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "returnAll": true,
        "fields": [
          "*"
        ],
        "options": {}
      },
      "name": "Google Contacts",
      "type": "n8n-nodes-base.googleContacts",
      "typeVersion": 1,
      "position": [
        830,
        340
      ],
      "credentials": {
        "googleContactsOAuth2Api": "Google Contacts "
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Hubspot Trigger\"].json[\"contactId\"]}}",
              "value2": "={{$node[\"Google Contacts\"].json[\"userDefined\"][0][\"value\"]}}"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1100,
        350
      ]
    }
  ],
  "connections": {
    "Hubspot Trigger": {
      "main": [
        [
          {
            "node": "Google Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Contacts": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

This is the Hubspot Id I receive from the trigger
{{$node["Hubspot Trigger"].json["contactId"]}}

These are the Hubspot Ids from in Google contacts custom field
{{$node["Google Contacts"].json["userDefined"][0]["value"]}}

Can you change {{$node["Hubspot Trigger"].json["contactId"]}} for {{$item(0).$node["Hubspot Trigger"].json["contactId"]}} and try again.

no, same. no matches in IF node…

{
  "nodes": [
    {
      "parameters": {
        "appId": "236187",
        "event": "contact.propertyChange",
        "property": "nei",
        "additionalFields": {}
      },
      "name": "Hubspot Trigger",
      "type": "n8n-nodes-base.hubspotTrigger",
      "typeVersion": 1,
      "position": [
        550,
        330
      ],
      "webhookId": "d8b2dcec-c72f-4fd7-83dd-cde55e496124",
      "credentials": {
        "hubspotDeveloperApi": "HubSpot Test Trigger Google Contacts"
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "returnAll": true,
        "fields": [
          "*"
        ],
        "options": {}
      },
      "name": "Google Contacts",
      "type": "n8n-nodes-base.googleContacts",
      "typeVersion": 1,
      "position": [
        830,
        340
      ],
      "credentials": {
        "googleContactsOAuth2Api": "Google Contacts "
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$item(0).$node[\"Hubspot Trigger\"].json[\"contactId\"]}}",
              "value2": "={{$node[\"Google Contacts\"].json[\"userDefined\"][0][\"value\"]}}"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1100,
        350
      ]
    }
  ],
  "connections": {
    "Hubspot Trigger": {
      "main": [
        [
          {
            "node": "Google Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Contacts": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

ok, it seems like the contactId that comes in the trigger is a number and the contactId in google contacts is a string. So when comparing for example 123 = ‘123’ it will give always false.

change this {{$node[\"Google Contacts\"].json[\"userDefined\"][0][\"value\"]}} to {{parseInt($node["Google Contacts"].json["userDefined"][0]["value"])}}

2 Likes

Aah. I understand! Now it works! Thank you so much @RicardoE105! You are the best…

1 Like