JSON manipulation for Mailchimp Groups

Hello everyone, this is my first post here and also I am very new to the use of n8n and really love it!

Currently I’m trying to push a contact from one mailchimp audience (Audience A) into another mailchimp audience (Audience B). This works quite well so far.

But my challenge is that if a contact registers for a specific group (group AA) then he should also be automatically registered in the audience B in a specific group (group BA). As far as I can see, this can’t be done via the mailchimp node fields, because the group membership is not displayed / customizable.

My other consideration was to customize the “Interest” section in JSON and add the value I want to have added to subscribe to the mailchimp group (BA). Is it somehow possible to rewrite the following lines of a JSON using n8n

    },
"interests": {
    "eae4bf1d1e": true,
    "bae6b78eac": false,
    "fd67ae933a": false
 },

to →

},
"interests": {
        "8b51df2dfb": true
 },

I am currently trying it over an IF and a SET.
If interest " eae4bf1d1e" = true then define interest “8b51df2dfb” = true

Can you help me with this problem? The best way would be to define the groups (interests) in the mailchimp node for sure.

Thanks for your help.

Hey, @Hueseyin welcome to the community. Yes, this is sadly not possible for the UI and just checked the Mailchimp API and they make it everything but easy to add. Either way, there must be a walkaround.

Question for you, where is the interest object coming from? is that coming from a trigger?

1 Like

Many thanks for the quick response. Yes, unfortunately I did not find anything in the mailchimp integration…

The interest object comes from a get all query. (the Mailchimp Trigger didn’t worked somehow)

Ok, @Hueseyin took me more time than expected but figured it out. I tested the workflow with the trigger and worked fine for me. The only thing that comes to mind is that you are not selecting the right source when creating the trigger. Just choose the 3 available options, and you should be able to test it by just adding a member manually to a list/audience and when the member is added from a form, for example.

I added the interest group field, it will automatically populate all the groups from a particular list, but it won’t populate the group category field. However, added the resource List Group which will allow you to get the group category id quickly.

The workflow below covers the use case you are interested in. Of course, you are not going to be able to use it until the new changes are released. We will keep you posted.

The workflow has two lists/audiences: testing and testing2. The testing audience has a group called ‘interest’ and two fields ‘interest1’ and ‘interest2’. The second audience testing2 has a group called ‘interest’ and a field called ‘interest3’.

When someone is added to the list/audience testing, the trigger fires then the if function checks if the person has an interest1 if so, then add that person on the list/audience testing2 and add the interest3.

If something it’s not clear please let me know.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        230,
        300
      ]
    },
    {
      "parameters": {
        "list": "49d9db79b3",
        "events": [
          "subscribe"
        ],
        "sources": [
          "user",
          "admin",
          "api"
        ]
      },
      "name": "Mailchimp Trigger",
      "type": "n8n-nodes-base.mailchimpTrigger",
      "typeVersion": 1,
      "position": [
        510,
        300
      ],
      "credentials": {
        "mailchimpApi": "asasas"
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Mailchimp Trigger\"].json[\"data[merges][INTERESTS]\"]}}",
              "operation": "contains",
              "value2": "interest1"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        760,
        300
      ]
    },
    {
      "parameters": {
        "list": "49d9db79b3",
        "email": "[email protected]",
        "status": "subscribed",
        "options": {},
        "groupsUi": {
          "groupsValues": [
            {
              "categoryId": "6734ffa700",
              "categoryFieldId": "theinterestgroup"
            }
          ]
        }
      },
      "name": "Mailchimp",
      "type": "n8n-nodes-base.mailchimp",
      "typeVersion": 1,
      "position": [
        1050,
        180
      ],
      "credentials": {
        "mailchimpApi": "asasas"
      }
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1050,
        460
      ]
    }
  ],
  "connections": {
    "Mailchimp Trigger": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Mailchimp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
2 Likes

Hey @RicardoE105, thank you very much for your engagement and your answer. I’m looking forward to the next update and am happy to use this feature. At the moment the mailchimp trigger works and I guess it might have something to do with the firewall we have.
Thanks again!

1 Like

Got released with [email protected]

2 Likes

Hello, thanks again for the fast development.

is it also possible with the realease to go to a deeper level (level 3)? I see the possibility to select the interest group (level 2), but not the interest itself in the one deeper level (level 3). (I have divided the different levels into levels for easier understanding).

@Hueseyin yeah, this is already posible. The field list it’s the level one, category id is the level 2 and category field id is the level 3.

2 Likes