Search Lessons, Code Snippets, and Videos
search by algolia
X
#native_cta# #native_desc# Sponsored by #native_company#

Airtable Firestore Customer Relationship Management

Episode 110 written by Jeff Delaney
full courses and content on fireship.io

Health Check: This lesson was last reviewed on and tested with these packages:

  • CloudFunctions v1.x

Find an issue? Let's fix it

Source code for Airtable Firestore Customer Relationship Management on Github

Firebase is a great platform for building apps, but it does not provide much in the way of Customer Relationship Management (CRM). Most businesses need to integrate their data with additional software for analytics, email, SMS, customer service, time-tracking, etc. Employees can become much more productive when you give them a suite of interactive tools to visualize and manage raw data.

In this episode, we will use Airtable to transform our data into a fully-fledged CRM tool.

Exporting Data from Firestore to Airtable

You should only export the data needed for CRM to Firestore. Keep in mind the free tier is limited to 1,200 records. You have two main options for transferring your data from Firestore to Airtable - manual and automatic.

Export Manually via CSV

I wrote a CLI tool that can exports data from Firebase in CSV format called Firestore Migrator. If you want to load an existing dataset to Airtable, this would be the ideal approach.

Export Automatically via Cloud Functions

Airtable provides a interactive API for NodeJS, which makes the backend code a matter of copy-and-paste for basic use cases.

Use the interactive API docs for Airtable

The cloud function code is as simple as it gets. Start by initializing cloud functions and adding your Airtable API key to the environment.

firebase init functions
npm install airtable -s

firebase functions:config:set airtable.key="your-api-key"

Then setup a function that will add a record to your base.

Make sure to define a column in Airtable for your data prior to transferring data. The SDK will throw an error if any column is not present.

import * as functions from 'firebase-functions';
const env = functions.config();

import * as Airtable from 'airtable';

const base = new Airtable({apiKey: env.airtable.key }).base('your-base-ID');


exports.addToAirtable = functions.firestore
.document('customers/{customerId}')
.onCreate((snap, context) => {
const data = snap.data();

// Add the data to the Airtable Base
return base('CustomerData').create(data)
});

Deploy the function and start adding some data to Firestore. You should see the records updated in realtime on the Airtable dashboard.

firebase deploy --only functions

The Fun Part

Now that our data is connected to Airtable, it’s time to have some fun with Blocks. You can think of a blocks as mini-apps that you can mix and match to build workflow on top of your data. And there’s a suite of built in blocks that range from content rich reporting, SMS texting with Twilio, data vis, translation, Google maps, video calls, you name it. Let’s try a few…

Visualize Firestore Data

Use the chart block to visualize firestore data

Pin User Locations on Google Maps

Use the Google maps block to visualize firestore data

Generate a PDF Report

A firestore PDF generated by Airtable

And Much More

There are 27 different blocks in Airtable at the time of this article, so we just barly scratched the surface. Overall, it provides an easy and intuitive way to build a project management suite on top of Firebase.