Conditional statements on multiple different arrays

I would like to output only when the conditions are met in multiple arrays with different numbers, and output a different message if they are not met, but I am not sure how to do this.

For example, you need something like this:

  1. Retrieve dozens of pieces of information from specific data. This is a random quantity
  2. Obtain user information from other data.
  3. If the user name is included in the list obtained in (1), the content in (1) is included when sending a Slack DM.
  4. If the username is not in (1), just send a simple Slack DM.
  5. Ultimately, DMs equal to the number of users acquired in (2) must be sent.

The maximum I can think of is attached. However, this doesn’t work correctly.
Because it is difficult to provide exact samples, they were made as similar as possible.

Other sample data is also fine. Please advise if there is a more efficient (faster, more sophisticated) method than the above method.
I hope you understand my English is lacking.

Thanks

In summary, in two arrays with different numbers
I want to find cases where the username word in B data is included in the A data list.
If found, Slack DM including the body of the A data
If you can’t find it, send Slack DM just once without body (in the example, if the if statement is false, 10 DMs are sent, which is the problem)

hi @Supka

For the simplicity, add Split in batches node instead of Item Lists node, set Split to 1 item and proceed it one by one. Don’t forget to link you workflow ending to the split node so it could be processed in a loop

hello, @barn4k

Thank you for your comment.
I’ll actually test it out.
However, in my opinion, if there is no item list(concatenateItems) to return 100 items as 1 in the beginning, wouldn’t the http request in the latter part be attempted 100 times instead of 1?

Still, it seems like it can work. I’ll try more first

If I were to implement my situation with python code, I think it would probably look like this:

import json

data1 = ["apple", "banana", "google", "test", "note"]
data2 = ["waffle", "duck", "goo"]

# Function to check if data2 is included in data1
def check_inclusion(data1, data2):
    inclusion = {}
    for item2 in data2:
        for item1 in data1:
            if item2 in item1:
                inclusion[item2] = item1
                break
        else:
            inclusion[item2] = None  # Include the key with None value if not found in data1
    return inclusion

# Check for inclusion and construct the final dictionary
inclusion_dict = check_inclusion(data1, data2)

# Convert to JSON format
result_json = json.dumps(inclusion_dict, indent=4)

# Print the result
print(result_json)

And its result is as follows.

{
     "waffle": null,
     "duck": null,
     "goo": "google"
}

This is the same as my purpose of sending a normal DM to an object with a null value and a DM including the body to an object with a google value.
Everything must be completed in just one session.

Of course, there are ways to use Python or JavaScript code, but I prefer non-code as much as possible.
love u n8n