Splitting data and dealing with looping

Describe the issue/error/question

Hi. I am trying to understand the data coming in the example below and how to split it into separate items so that i can import it into mautic.

What I would like to do is split the high level sports into two items so that i can insert these in the coming nodes, and then do the same for teams. The other issue is that I would like to take the sports values and team values and insert them into mautic, however each time i receive a webhook there could be a different number of sports and a different number of teams so i would need to loop over them.

What is the error message (if any)?

Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • **n8n version:**0.193.5
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker

Hi just bumping this up as I am stil stumped here and would really appreciate some direction

Hey @Surge.Media,

Can you share some samples of the data you are getting?

Hi @Jon thanks for jumping in here. In the workflow above I have put in example data.

Hi, so this is an example of the data I am dealing with:

[
{
"body":
{
"0":
"[email protected]",
"1":
"97254324555",
"2":
"Alaska",
"3":
{
"nfl":
"nfl",
"nba":
"nba"
},
"Teams":
{
"nfl":
{
"0":
"Denver Broncos",
"1":
"Los Angeles Chargers",
"2":
"Kansas City Chiefs"
},
"nba":
{
"0":
"Boston Celtics",
"1":
"Brooklyn Nets"
}
}
}
}
]

Data that can change is in body.3, this could sometimes just be nfl, sometimes just nba and sometimes both nfl and nbd.
Inside Teams this is also variable data, and can sometimes be either nba or nfl or both and the number of teams might differ each time, sometimes there might be only 1 team, sometimes there might be 7 for example.

What I am trying to accomplish is to take the data from teams regardless of how many teams there are and get them into a string that i can then input into a custom field inside Mautic. So in the example above I would like to get nfl teams as: “Denver Broncos,Los Angeles Chargers,Kansas City Chiefs”. I would then take this and use this when adding to a field inside my mautic node.

So far this is what I have tried to do with n8n:

Does this make sense ?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.