The company I currently work for recently asked me to develop an integration application (in Rails) with BatchBook, an excellent cloud-based CRM service. The purpose of this integration was to adapt the CRM to our specific business needs, which require a bit more functionality than the CRM alone can offer. Fortunately they provide a mature API and an easy to use Ruby library, so it’s quite simple to get started.

After getting used to their API and the Rails way of dealing with external objects via ActiveResource, we decided to share our achievements by open-sourcing the project, which can be found on GitHub.

The project is an entire Rails 2.3.5 application: just download the source, configure it to integrate with your BatchBook account and you have an entire application fully integrated to BatchBook. All of the installation and configuration are explained in the project’s wiki, along with other project technical details.

We split the integration process into three steps:

  1. Our first goal was to create some simple custom reporting tools. Doing so led to some overlapping functionality with the ‘stock’ BatchBook service. Our goal here was not to recreate the features that are available in the ‘stock’ version of BatchBook, but simply to learn the BatchBook API and extend it based on our needs.
  2. The second was to automate and combine a sequence of the tasks that simplifies the processes of our sales team. For example, converting a lead (prospect) to a customer, assigning ownership, updating tags/supertags and creating to-do’s. We are currently running a basic version of this.
  3. The third and most involved task will be integrating BatchBook CRM with our custom quoting web application. Currently, BatchBook has no built-in functionality for creating traditional quotes using an inventory list of our products.
    We don’t want to add too many features and make it overly complex (SalesForce anyone?). Instead, we plan on building a suite of custom tools, integrated just the way we need them.

On a more technical note, our application features some great performance improvements on top of Rails’ ActiveResource to ease the burden of making external requests. Some of these enhancements include:

  • Object caching: the number of contacts can quickly grow, even for smaller companies. The constant stream of requests to many objects leads to awful delays. We overcame this by writing a caching system that reduces page loading time from minutes to milliseconds.
  • Request limitation: a request which asks for thousands of objects is a recipe for trouble, as often it will time out. We limited the maximum number of objects per request and combined all of these in the end, preventing error pages for the end user and still getting the job done.
  • Pagination: pagination is usually an easy feature to implement in a database-oriented application, but things get a bit more complicated with a service-oriented application like ours. We solved this by developing a simple pagination feature that works much like the widely-used Rails will_paginate plugin.
  • Integration testing: with the help of the Dupe gem, we wrote a test suite for our entire application to guarantee consistency and expected behavior using Cucumber.

Although we developed quite a bit already, the application is still evolving as we learn more, BatchBlue extends the API and our business requirements change. This is just the start – stay tuned for upcoming features and please give us your feedback.

Reach us via email at or Twitter at @usedciscodotcom with any issues you run into or extensions you create.