What I Learned Building an App on the Drift Platform

A long time ago in a galaxy far, far away — I was a Computer Science major at the University of Illinois. I grew up programming in BASIC on a variety of hardware, including my beloved TI 99/4A and then later a Commodore Amiga. My parents came up with a brilliant strategy to get me to learn to program — you want to play games on the computer? Build them.

But after graduating college I realized I was pretty awful programmer. I was working in QA at a software company, and I found out pretty quickly that I better find something other way to make a living. Since I was better at talking about technology than building it, I ended up becoming a sales engineer and then later, a marketer.

I’ve always felt that my tech background has helped my marketing career, a phenominon Scott Brinker wrote about way back in 2008. Marketing as a discipline sits at the center of science and humanity, and I’ve tried to balance the two in my career.

But sometimes you just feel the need to build.

Building a App on the Drift Platform

The Drift platform is a new set of APIs to allow developers to create and publish apps on Drift. I wanted to find a way to make it easier for our team at RapidMiner to learn more about the people we’re having conversations with.

I’ve been wanting to get back into coding as a #sidehustle thing, so I took at look at at one of the sample applications that launched with the Drift platform and decided to give it a try.

Every time we start talking to someone with Drift, we try and look them up in Salesforce to learn about them so we can make the converation more relavant. Salesforce has all of the usual information, but more importantly for us, it has all of the information about how people are using our products.

Our process with Drift at RapidMiner was to cut+paste the email address into Salesforce to look up a user. Sounds easy, but it takes time, and disrupts the flow of the conversation especially when we are juggling lots of simultaneous conversions.

So, I decided I’d try and build an app called salesforce-lookup that would make it easier to pull data from Salesforce into Drift. It takes the email address of the current user and returns a bunch of useful information from Salesforce directly into the Drift conversation. It looks like this inside Drift:

The app will automatically generates a direct link to the user in Salesforce, and returns information about the user, including the number of times and the last time they used RapidMiner. Simple for sure, but it saves a bunch of time for the team and lets us have more relevant conversions.

Here’s how I did it, and what I learned in the process.

Creating a GitHub Account

Okay, I already had a GitHub account, but had never used it before. Wow, GitHub is simple and useful. I can’t compare it to the all the old ways to manage code because I never used them, but it sure beats vi and a filesystem.

Apparently people still do use vi (and emacs). And there’s even a Wikipedia on editor wars. (I’m team vi, for the record).

Setting up Heroku

Heroku is an obvious place to run nodeJS apps, so I gave it a try. It was super easy to setup, and connects right to GitHub. Every time I pushed my code to GitHub it would automatically redeploy the app.

Learning nodeJS and Asynchronous JavaScript

Okay, now the hard part — building the app in nodeJS.

I’ve used client side Javascript extensively during my time as a sales engineer, but I never really appreciated how much its has evolved for server-side applications.

My breakthrough was learning that Javascript can be asynchronous, and that means it requires a bit more planning when building the app.

I had to string a serious of function calls together to make sure that I had all the information I needed at each step. That meant I had to learn all about callback functions (shoutout to Joel on the Drift team for explaining this to me).

For example, here’s a function that finds the Drift Contact Id for the user in the current converation.

In an asynchronous Javascript world, you don’t really have the Drift Contact Id variable until you execute the callback function GetContactId. Once I figured this out, I was able to chain together a series of API calls to Drift and Salesforce.

The Drift APIs were easy to use, but Salesforce was a bit harder. One of the best parts of nodeJS is the ecosystem, and I found a robust library called JSforce to help with the Salesforce query.

The hardest part was logging into Salesforce using OAuth. I had never looked at OAuth before, so I had to learn enough about it to access both the Salesforce and Drift APIs. Authentication to Salesforce is a little bit more difficult as you have to handle tokens that can expire.

Once I was able to authenticate, it’s just a simple SQL-like query to return what I needed for my app — the users name, company, and some details about their RapidMiner product usage. I can query any field we have inside Salesforce.

conn.query("SELECT Id, Email, FirstName, LastName, Company, Academics__c, Total_RM_Studio_starts__c, Last_RM_Studio_usage__c FROM Lead where Email = '" + emailAddress + "'", function(err, result) {

Then I put together the message…

// Build the Drift reply body
body = "<a target='_blank' href=https://na52.salesforce.com/" + Id + ">" + firstName + " " + lastName + "</a><br/>" + "Company: " + Company + "<br/>Total RM Studio Starts: " + totalStudioStarts + "<br/>Last RM Studio Usage: " + lastStudioUsage + "<br/>Academic: " + Academic

And lastly send the message back to the Drift conversion.

// Send the message
return request.post(CONVERSATION_API_BASE + `/${conversationId}/messages`)
.set('Content-Type', 'application/json')
.set(`Authorization`, `bearer ${DRIFT_TOKEN}`)
.catch(err => console.log(err))

I was glad to learn that the best way to debug things is still to output stuff to the console. That hasn’t changed since my days of debugging BASIC. At one point, I basically had a console.log every other line.

All marketers should learn to program

When I finally made this work (at 2am last night, just like in college!) it felt really great. There’s nothing like building something and seeing it actually work. Heck, someone has even forked my code already (looking at you Brian Whalley, good luck!). I’m sure my code is awful, but it does something useful, and it was really fun to build.

Steve Jobs once said everyone should learn to program a computer, and I agree. It helps you develop logical thinking (hey asyncronous Javascript), and many of the same concepts you learn in programming apply to lots of things we see as marketers. For example, your Marketo, Pardot, or HubSpot segmentation lists are just a complex boolean expression.

The advent of applications like GitHub and Heroku plus the availability of a massive variety of training resources make getting started with programming today easier than ever. Seriously, imagine getting a CS degree today without StackOverflow — yeah, that’s what my generation had to do.

function getContactId(conversationId, callbackFn, orgId) {
// Get the contact from Drift
.get(CONVERSATION_API_BASE + `${conversationId}`)
.set('Content-Type', 'application/json')
.set(`Authorization`, `bearer ${DRIFT_TOKEN}`)
.end(function(err, res){
callbackFn(res.body.data.contactId, conversationId, orgId)
// call back function
function GetContactId(contactId, conversationId, orgId) {
return getContactEmail(contactId, GetContactEmail, conversationId, orgId);

%d bloggers like this: