Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Intercom = require('intercom.io');
- var options = {
- apiKey: "intercomapikey",
- appId: "intercomappid"
- };
- var intercom = new Intercom(options);
- var MailChimpAPI = require('./node_modules/mailchimp-api/mailchimp');
- var apiKey = 'mailchimpkey';
- var mc = new MailChimpAPI.Mailchimp(apiKey);
- var list_id = 'mailchimplistid';
- // you have to manually increment start page 0++ until memberData results are null
- // also you should import status: "cleaned" and start at page 0
- mc.lists.members({id: list_id, status: "unsubscribed", opts: {limit: 100, start:0}}, function(memberData) {
- memberData.data.forEach(function(member) {
- if (member.status != "subscribed") {
- intercom.updateUser({
- email: member.email,
- unsubscribed_from_emails: true
- }, function (err, res) {
- if (err) {
- console.log(err);
- } else {
- console.log(res.email, 'unsubscribed');
- }
- });
- }
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement