Slack Message by Mailchimp unsubscriptions

Hello everyone,

i am currently trying to create an event-based node that will fire through a mailchimp trigger and post a slack message in a channel.

What exactly should happen?

If a user unsubscribes from the mailchimp list then a message should be posted in a slack-channel which shows the first and last name, the email address, the date and time and the list e.g. name, email address and list.

Something like:

“[Hüseyin] [D.] with the email address [[email protected]] has unsubscribed from the list [Newsletter] on [28.07.2020] at [14:34] o’clock.”

Currently I get all users in the second step instead of the person who unsubscribed. Is there an intelligent way to create the flow described above?

Very strange. If I use the Mailchimp Node and do Member -> Get it just returns the data of the one user I entered the email address of.

Does that happen for you with all users? I wonder if it has to do with the fact that the user which unsubscribed is not a member anymore and so the Mailchimp API somehow decides to return all users instead (as the requested one does not “exist” anymore)?

@Hueseyin just tested it and it worked fine for me with the same workflow. Can you share the workflow?

Hey @jan, hello @RicardoE105,

Many thanks for the quick answer!
After your answer I built the flow again from the front and it works now - even simpler. Thanks!

The only thing I haven’t figured out yet is the output of the email address of the user who has unsubscribed. I still have trouble figuring out where to get the parameters for the slack message in the last step.

{
  "nodes": [
    {
      "parameters": {
        "channel": "n8ntestchat",
        "text": "=The User [    ] unsubscribed from the List [   ] \n\n// test by Hüseyin",
        "attachments": [],
        "otherOptions": {},
        "blocksUi": {
          "blocksValues": []
        }
      },
      "name": "Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        900,
        300
      ],
      "credentials": {
        "slackApi": "billwerk"
      }
    },
    {
      "parameters": {
        "operation": "get",
        "list": "97bcdb1e43",
        "email": "=",
        "options": {}
      },
      "name": "Mailchimp",
      "type": "n8n-nodes-base.mailchimp",
      "typeVersion": 1,
      "position": [
        680,
        300
      ],
      "credentials": {
        "mailchimpApi": "Mailchimp API Key"
      }
    },
    {
      "parameters": {
        "list": "97bcdb1e43",
        "events": [
          "unsubscribe"
        ],
        "sources": [
          "user",
          "admin",
          "api"
        ]
      },
      "name": "Mailchimp Trigger",
      "type": "n8n-nodes-base.mailchimpTrigger",
      "typeVersion": 1,
      "position": [
        440,
        300
      ],
      "webhookId": "634fd24e-49d1-4c80-a0a5-b50cda791a5d",
      "credentials": {
        "mailchimpApi": "Mailchimp API Key"
      }
    }
  ],
  "connections": {
    "Mailchimp": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mailchimp Trigger": {
      "main": [
        [
          {
            "node": "Mailchimp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

You have to use expressions to use the output of other nodes. I did it in the example below. Info about expressions can be found here: https://docs.n8n.io/nodes/node-basics.html#expressions.

Let me know if something it’s not clear.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "channel": "ricardo",
        "text": "=The User [{{$node[\"Mailchimp\"].json[\"email_address\"]}}] unsubscribed from the List [{{$node[\"Mailchimp\"].json[\"list_id\"]}}] \n\n// test by Hüseyin",
        "attachments": [],
        "otherOptions": {},
        "blocksUi": {
          "blocksValues": []
        }
      },
      "name": "Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        950,
        290
      ],
      "credentials": {
        "slackApi": "asasas"
      }
    },
    {
      "parameters": {
        "operation": "get",
        "list": "49d9db79b3",
        "email": "={{$node[\"Mailchimp Trigger\"].json[\"data[email]\"]}}",
        "options": {}
      },
      "name": "Mailchimp",
      "type": "n8n-nodes-base.mailchimp",
      "typeVersion": 1,
      "position": [
        730,
        290
      ],
      "credentials": {
        "mailchimpApi": "asasas"
      }
    },
    {
      "parameters": {
        "list": "49d9db79b3",
        "events": [
          "unsubscribe"
        ],
        "sources": [
          "user",
          "admin",
          "api"
        ]
      },
      "name": "Mailchimp Trigger",
      "type": "n8n-nodes-base.mailchimpTrigger",
      "typeVersion": 1,
      "position": [
        490,
        290
      ],
      "webhookId": "634fd24e-49d1-4c80-a0a5-b50cda791a5d",
      "credentials": {
        "mailchimpApi": "asasas"
      }
    }
  ],
  "connections": {
    "Mailchimp": {
      "main": [
        [
          {
            "node": "Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mailchimp Trigger": {
      "main": [
        [
          {
            "node": "Mailchimp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
2 Likes

Hello @jan and @RicardoE105 ,

now the workflow works as wanted and without any trouble. I am discovering more and more possibilities to use n8n - thank you very much for your time and for such a great tool!

3 Likes