Intercom to BigQuery

This page provides you with instructions on how to extract data from Intercom and load it into Google BigQuery. (If this manual process sounds onerous, check out Stitch, which can do all the heavy lifting for you in just a few clicks.)

About Intercom

Intercom is a powerful platform for communicating with customers and leads. From targeted messaging to customer support it solves a great number pain points for companies that use it. What makes Intercom even more powerful is the treasure trove of data that it collects. Tracking, filtering, and segmentation functionality allows users to analyze interactions for powerful business insights.

What is Google BigQuery?

Google BigQuery is a data warehouse that delivers super-fast results from SQL queries, which it accomplishes using a powerful engine dubbed Dremel. With BigQuery, there's no spinning up (and down) clusters of machines as you work with your data. With all of that said, it's clear why some claim that BigQuery prioritizes querying over administration. It's super fast, and that's the reason why most folks use it.

Getting data out of Intercom

First, let's get the data out of intercom. To do this, access the Intercom API, which is available to all users of the service. The API documentation is available here. Intercom’s API offers access to lots of endpoints that can provide information on users, tags, segments, conversations, and more. Use the API documentation to retrieve the data you’d like to get into your data warehouse.

Sample Intercom data

The Intercom API will give you JSON data. This is an example of the kind of response you might see when querying for the details of a Conversation:

{
  "type": "conversation",
  "id": "147",
  "created_at": 1400850973,
  "updated_at": 1400857494,
  "conversation_message": {
    "type": "conversation_message",
    "subject": "",
    "body": "

Hi Alice,

\n\n

We noticed you using our Product, do you have any questions?

\n

- Jane

", "author": { "type": "admin", "id": "25" }, "attachments": [ { "name": "signature", "url": "http://example.org/signature.jpg" } ] }, "user": { "type": "user", "id": "536e564f316c83104c000020" }, "assignee": { "type": "admin", "id": "25" }, "open": true, "read": true, "conversation_parts": { "type": "conversation_part.list", "conversation_parts": [ //... List of conversation parts ] }, "tags": { "type": 'tag.list', "tags": [] } } }

Preparing Intercom data

Now the real fun starts. Once you’ve figured out what you want to pull down and how to pull it, you need to map the data that comes out of each Intercom API endpoint into a schema that can be inserted into your database.

This means that for each value in the response, you need to identify a predefined datatype (i.e. INTEGER, DATETIME, etc.) and build a table that can receive them. The Intercom API documentation can give you a good sense of what fields will be provided by each endpoint, along with their corresponding datatypes.

Complicating things is the fact that these records are not always “flat” — in other words, there may be values that are actually lists. This complicates things because it means you’ll most likely to create additional tables to be able to capture the unpredictable cardinality in each record. (The “tags” value in the data above is an example of this.)

Loading data into Google BigQuery

Google Cloud Platform offers a helpful guide for loading data into BigQuery. You can use the bq command-line tool to upload the files to your awaiting datasets, adding the correct schema and data type information along the way. The bq load command is your friend here. You can find the syntax in the bq command-line tool quickstart guide. Iterate through this process as many times as it takes to load all of your tables into BigQuery.

Keeping Intercom data up to date

So, now what? You’ve built a script that pulls data from Intercom and loads it into your data warehouse, but what happens tomorrow when you have dozens of new conversations and related data?

The key is to build your script in such a way that it can also identify incremental updates to your data. Thankfully, Intercom’s API results updated_at fields that allow you to quickly identify records that are new since your last update (or since the newest record you’ve copied into the destination). You can set your script up as a cron job or continuous loop to keep pulling down new data as it appears.

Other data warehouse options

BigQuery is really great, but sometimes you need to optimize for different things when you're choosing a data warehouse. Some folks choose to go with Postgres or Redshift, which are two RDBMSes that use similar SQL syntax. If you're interested in seeing the relevant steps for loading this data into Postgres or Redshift, check out To Redshift and To Postgres.

Easier and faster alternatives

If all this sounds a bit overwhelming, don’t be alarmed. If you have all the skills necessary to go through this process, chances are building and maintaining a script like this isn’t a very high-leverage use of your time.

Thankfully, products like Stitch were built to solve this problem automatically. With just a few clicks, Stitch starts extracting your Intercom data via the API, structuring it in a way that is optimized for analysis, and inserting that data into your Google BigQuery data warehouse.