Lookup and Convert in n8n

Hi Community!

I am creating a workflow where data comes in via a Google Sheet to my workflow. This data is in the format of text strings. I then do a HTTP request which calls an API and gives me a series of ID codes related to a series of text strings. The text strings from my Google Sheet correspond to the ID’s which have been called from the API.

My issue is that I want a way to lookup the text string from the output data given in the HTTP request, and match it to the unique ID outputted from the same node. I then want to convert the string using a SET node to the ID value, rather than the raw string value.

Is there anyway to do this within n8n? I think i need to use loops however my experience with this is limited. Any help would be really appreciated as its quite an important use case.

Thanks

Hey @aziadlourad,

You can use the Merge node and select the relevant mode (in your case it can be either Merge By Key, Keep Key Matches, or Remove Key Matches).

I am not sure what exactly you mean by converting the string to the ID value. What is the data type of the ID that you want to use? Also, are you trying to append this to a database?

Hi @harshil1712

Thanks for the response.

I want to essentially change the string value to a different string value depending on certain conditions. The issue is that when the initial string comes through, I need to check if it matches the other data source’s possible 10 values, and return the corresponding ID (which is also a string). Does that make sense?

Can you share the output of both the nodes? I think I have understood your use case, but having an output from the nodes will help me provide a solution faster :slight_smile:

(Please replace any sensitive data with dummy data)

An update for anyone who may face the similar issue:

The HTTP Request node returns an object that contains an array of attributes. If an attribute is of the type multi-select, it displays the list of all the possible options. We want to search through the value returned by the Google Sheets node in this options array.

A possible solution: