Mailchimp Meteor Integration

Hey guys,

I’ve been looking for and testing solutions to integrate the Mailchimp API (latest version) with Meteor, but couldn’t find one that works.

Any recommendations?

Thanks!

Hey @patrickcneuhaus,

I actually worked on this the past couple days!

I didn’t find any pre-built packages that seemed lightweight/maintained, so I ended up just using Meteor’s HTTP API to handle all the requests to Mailchimp. I didn’t need a ton of functionality, just building and maintaining Lists based on the users in my system. If you’re still looking for a package/wrapper, I’d say mailchimp-api-v3 is your best bet though.

Let me know if you could use any examples and I’d be happy to help.

2 Likes

Hey!

Thanks for the reply! You gave me some real hopes here :smiley:
Can you give me an explanation (or maybe an example) about how you did it through HTTP?

Thanks!

I’m using mailgun API right now, it’s pretty good I haven’t looked into MailChimp.

Just use the http package( or however you do api requests) and you will be able to get a uri from either MailChimp or mailgun to make an http post to send the emails you want to send.

I made a whole mailing list with scheduling this way, been working like a charm. I’m using the Steve jobs package for scheduling.

Sure thing, works just like any other RESTful API. Here is a method that creates a member for a specific mailing list.

createMailchimpMember : function( ){

    // You probably want to do some permissions checking
    
    const apiKey = <YOUR-API-KEY> // Store this securely, like in your Meteor.settings
    const listId = <YOUR-LIST-ID> // Get this from Mailchimp
    const url    = `https://us8.api.mailchimp.com/3.0/lists/${listId}/members`;

    // Create the httpOpts with the auth (using your apiKey) and data
    const httpOpts = {
      auth : `Authorization:${apiKey}`,
      data :  {
        email_address : <EMAIL-ADDRESS>
        status        : 'subscribed',
        merge_fields  : {
          FNAME  : <FIRST-NAME>,
          LNAME  : <LAST-NAME>
        }
    };

    // Send the HTTP Post out to Mailchimp
    try {
      const response = HTTP.post( url, httpOpts );

      // Do whatever you want with the response
      clog( `MailChimp Member Created - ${response}` );
    } 
    catch( err ){
      const errMsg = err.response.content;
      console.error( errMsg );
    }
},
1 Like