Close

February 7, 2012

Mailchimp Integration…nom nom (Geeks Only)

After connecting three CRMs to Ecquire, we started looking for another integration that could prove to investors and potential partners how flexible the Ecquire system is. And it really is – adding new systems to push data to is as simple as writing an API wrapper with a few required functions and throwing it in the source tree.  I wrote the MailChimp wrapper, and thought I’d share my experience working with MailChimp’s web-based API.

So why MailChimp? For many small business’ their MailChimp list is actually their customer list, and entering new customers can be a long and menial task. For the small business owner, Ecquire can be the perfect solution to manage customers without ever leaving their workflow. However, MailChimp is not a typical CRM like the other services we push to, and there were a few challenges to overcome.

First off, no JavaScript wrapper exists for MailChimp. There are a bunch of wrappers in every other language, but given Ecquire sits directly in our users’ the browser, we needed to access the web-based API entirely in JavaScript. I’ve written JavaScript wrappers for a variety of APIs, and so it naturally fell to me to develop the MailChimp wrapper. (Side note: I actually use CoffeeScript, “a little language that compiles into JavaScript.” It helps reduce verbosity and enforces correct coding practices. I highly recommend it.)

Unlike the other systems we had integrated with were straight CRMs, rather than having obvious objects like “Contact” and “Company” to store data in, MailChimp is an email service that deals only with long lists of subscribers. The hardest challenge was thus to adapt MailChimp to perform like a typical CRM. Thankfully, MailChimp allows for what they call “merge variables” – custom fields that you can create and fill in for each contact. We create a whole bunch of these, such as “Employer” and “Position”, and (with a little magic) even allow the user to add their own straight from Ecquire! So we can store almost any information we want for each contact, just like all the other CRM systems.

By far and away the best part of the MailChimp API is built-in support for JSON. Some other APIs (I’m looking at you Google…) require all data submitted to be in SOAP/XML format. This can be a massive headache to parse and edit. Having JSON support in the MailChimp API likely cut the integration time in half, leaving more time to work on cool new features for Ecquire (automagically parsing PDF invoices attached to emails anyone?).

Although it is web-based, MailChimp’s API is not RESTful. Any request that reaches the MailChimp server receives an HTTP 200 response – even if an error occurred. This threw me for a quick loop, but it was easy to adapt to and was actually a blessing in disguise. Rather than relying on cryptic HTTP status codes for error reporting, MailChimp sends very detailed errors in the 200 response when anything goes wrong.

MailChimp also provides a fast and easy support system for any issues that do arise. Questions on their “MailChimp API Discuss” Google Group typically receives answers within hours, which is refreshing and necessary with time-sensitive integrations.

We plan on open-sourcing our JavaScript/CoffeeScript MailChimp wrapper in the future – if you have interest in it, shoot me an email at ben@ecquire.com and I’ll let you know when it’s released!

Leave a Reply

Your email address will not be published. Required fields are marked *