Set node and data correspondance in Airtable

Hello n8n folks - I’m trying to understand the way n8n is attributing data in the set node and more precisely how to attribute data correctly.

  1. This WF begins with an Airtable contact list where I have the following columns:
    ID, first_name, last_name, job_title, email, and deliverability.
    → The deliverability remains empty at this stage.
  2. Then I simulated a GET request from an API that return the email deliverability. (Yes OR No)
  3. I have a set node to attribute an ID to the contact, to prepare the matching for the next update node
  4. Airtable update - Update the deliverability status according to the ID
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "application": "app50gSeeN39EmTFf",
        "table": "Contacts",
        "id": "={{$json[\"id\"]}}",
        "options": {}
      },
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        960,
        300
      ],
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "deliverability",
              "value": "={{$json[\"deliverability\"]}}"
            },
            {
              "name": "id",
              "value": "={{$node[\"Airtable1\"].json[\"id\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        760,
        300
      ]
    },
    {
      "parameters": {
        "operation": "list",
        "application": "app50gSeeN39EmTFf",
        "table": "Contacts",
        "additionalOptions": {}
      },
      "name": "Airtable1",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        400,
        300
      ],
      }
    },
    {
      "parameters": {
        "functionCode": "return [{\n\n\t\t\"email\": \"[email protected]\",\n\t\t\"deliverability\" :\"NO\"\n},\n{\n\t\t\"email\": \"[email protected]\",\n\t\t\"deliverability\" :\"YES\"\n}\n]\n\n"
      },
      "name": "Email_Deliverability",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        580,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Airtable1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable1": {
      "main": [
        [
          {
            "node": "Email_Deliverability",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email_Deliverability": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Results:
A mismatch between contact and ID.
Screenshot from Airtable:


Screenshot from the set node:

In fact, Mario was supposed to have the following “id”: “recvpdoOS5rikqyLa” - but after the set node, Mario has the following: “id”: "recOuSNTLUGTWqxXo and that results in a wrong Deliverability attribution.

Do you have any idea how to attribute the ID correctly?
Many thanks

Hi @fischera

I think you are looking for the merge node.
You need to merge the input from the 2 sources together first. (merge by Key)
I am guessing your Simulated request is giving data in the wrong order.
The set node only sees what items are available and loops through those items to do its thing. It will not do the merging of data automatically for you.

1 Like

Exactly! Well received, I’ll try this way and keep you updated.

2 Likes

@BramKn - I can observe exactly the same phenomena.
I’ve used the merge node to bring

  1. As a first input the ID
  2. As second input: The deliverability: Yes or No
    But still, the expected values are not matching.
    In fact, it should be YES for Batman and NO for Mario.

Any idea?

Hi @fischera

I see there is still a connection between the two nodes directly. Can you remove that and see what happens? Not behind pc so cannot look in detail.

No problem !
You mean like this ?


Unfortunalty, same results

Hi @fischera

Fired up my laptop to have a look.
Your merge node is not set up correctly.
You have:
image
image

Should be something like:
image
You have to fill in the name of the field you want to use as the key. Do this for both input and it will merge the data on that key field. Of course you would need values in those columns that are the same for it to merge correctly.

OK, thanks @BramKn !
I’ve just tried but the results are the same as previously:
Node configuration:


Results
Same as previous.

But, at least I get the logic.
As far as I understand the node attribute the first ID found in the table:


rec…La
And then attribute the first value of the node running in parallel :
In this case
NO

Do you know if there is another way I can get a robust/suitable match between those 2 fields?

HI @fischera

I think you are not matching the correct keys.
You need to have some kind of key field to match both inputs. Otherwise you cannot match the two together. I guessed it would be the email, but apparently, it wasn’t?
Can you show the data from the first airtable node? the one that gets the data? At the moment I am not sure what data you are combining.

Hi @BramKn - OK then I need a common key, understood.
Here is the first nood
[
{
“id”: “recOuSNTLUGTWqxXo”,
“createdTime”: “2022-08-01T14:55:25.000Z”,
“fields”: {
“last_name”: “sega”,
“job_title”: “CEO”,
“company_name”: “B”,
“check”: true,
“first_name”: “batman”,
“email”: “[email protected]”,
“Lead_id”: “recOuSNTLUGTWqxXo”,
“checkbox”: “A”,
“createdTime”: “2022-08-02T21:06:46.000Z”,
“last”: “2022-08-02T21:06:46.000Z”
}
},
{
“id”: “recvpdoOS5rikqyLa”,
“createdTime”: “2022-08-01T14:54:57.000Z”,
“fields”: {
“last_name”: “nintendo”,
“job_title”: “CEO”,
“company_name”: “A”,
“check”: true,
“first_name”: “mario”,
“email”: “[email protected]”,
“Lead_id”: “recvpdoOS5rikqyLa”,
“checkbox”: “A”,
“createdTime”: “2022-08-02T21:06:46.000Z”,
“last”: “2022-08-02T21:06:46.000Z”
}
}
]
In this node - I have everything expect the deliverability
And in the node in parallel, I have : return [{

	"first_name": "mario",
	"email": "[email protected]",
	"deliverability" :"NO"

},
{
“first_name”: “batman”,
“email”: “[email protected]”,
“deliverability” :“YES”
}
]
So you are right, email seems to be the right key to match all fields.
Is that what you had in mind?

Yes almost there. In your screenshot you see that the email field is nested within the field called “fields”
So for that input you need to set the key on fields.email

3 Likes

Yes indeed - It’s working, thanks a lot for your patience and help @BramKn

2 Likes