Output from Array Aggregator becomes null in any subsequent node

:bullseye: What is your goal?

My goal is to get a file from Google Drive, extract the name, look over a list of folders, get the closest match and move the file over there.

:thinking: What is the problem & what have you tried?

Ive been able to retrieve a single file from Google Drive. Then, get the list of folder names from there as well. Now im trying to use the Categorize Text node from the AI Toolkit to compare the filename to that list and find the closest match folder.

The AI node requires a ‘categories’ field that would be an Array.

So, after the Google Drive node that retrieves the list of folders, im using an Array Aggregator to obtain an array with the folder names. However, once i map it into the AI node, it fails.

When checking the details, the ‘input’ of the AI node (That means, the folder names array outputed from the Aggregator) is empty.

Im using {{map(30.array; “Name”)}} in order to get a clean Array (cause the Aggregator actually delivery an array of collections)

Ive tried to parse it via the Transform to JSON node to test the map function, however i see the same behavior: the input (the aggregator output) is empty, therefore the output from this operation is empty as well.

Ive tried different ways but im unable to reach to a solution.

  1. What exactly does that AI node need for the ‘categories’ field?
  2. Why when manipulating the Array Aggregator node, it becomes an empty input for any other node?

:clipboard: Error messages or input/output bundles

TypeError
Cannot convert undefined or null to object

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Actual Flow:

Here, desired output shows:

AI node config:

Error msg and input shows empty Array

Hi @JuanDiego_CA

Click on the field where you’re using the map() function, then place the mouse pointer over the green pill of the Name property, inside the Array.

The raw value is probably name. Use that one and drop the quotes “”.

{{map(30.array; name)}}

@damato

Hi! Didn’t know i had to look for the ‘raw’ value there!

So now at least it is not retrieving an empty array. I can confirm it is correctly applying the map function (I tested with another Transform to JSON that was initially also giving me empty, and now works correctly)

However the AI node is still not working, this is the new error. Any idea why?

This is not very well documented indeed. The Categories field is not a simple array of strings like ["A", "B", "C"]. It expects an array of objects where the Collections are the values and the keys are… spaces! :face_with_open_eyes_and_hand_over_mouth:

Something like this:

{
  "categories": [
    {
      " ": "A"
    },
    {
      " ": "B"
    }
  ]
}

When you map() the array, it returns only the names as entries of a simple array.

Here’s an easy fix:

Set your aggregator’s Target structure to tbe the AI Toolkit’s Categories. Then, map the value you’re aggregating on to the Category name.

Then map the resulting array (already in the format the module wants) to the Categories inside AI Toolkit:

Hope it makes sense.

@damato

2 Likes

Amazing! That did the trick! Thank you very much!

Had to reorder my nodes as in order to select the AI Toolkit as Target structure it needs to be directly connected to the node. Good to know as well.

2 Likes