Triggering the first time you see a lead domain using FlowBoost

There are so many cool things you can do with FlowBoost’s FBCounter that go beyond the obvious case of counting program members/event registrants.

(As always, mea culpa because the rather meager documentation of FBCounter doesn’t mention these. They mostly come up when a user responds to the onboarding email with a question and I go, “Of course!” ☺)

When you call FBCounter.add(counterName, value) the response has a different shape if the counterName already existed vs. if it’s brand new.

If it’s brand new, it looks like this:

{
  "response": {
    "body": {
      "action": "set",
      "node": {
        "key": "/pub:omuryeoqwuk5vqpw6zpaxtdr/knownDomains/example.com",
        "value": "248832",
        "modifiedIndex": 4453898,
        "createdIndex": 4453898
      }
    }
}

While if the counterName already existed, it looks like this — note the prevNode (“previous node”) object:

{
  "response": {
    "body": {
      "action": "set",
      "node": {
        "key": "/pub:omuryeoqwuk5vqpw6zpaxtdr/knownDomains/example.com",
        "value": "248836",
        "modifiedIndex": 4453902,
        "createdIndex": 4453902
      },
      "prevNode": {
        "key": "/pub:omuryeoqwuk5vqpw6zpaxtdr/knownDomains/example.com",
        "value": "248832",
        "modifiedIndex": 4453901,
        "createdIndex": 4453901
      }
    }
  }
}

Therefore, you can use the presence of prevNode to flag a domain that’s new to your database. Here’s that FlowBoost webhook payload:

let emailParts = FBUtil.string.partsFromEmail({{Lead.Email Address}});
let emailDomain = emailParts.domain;

FBCounter.add(`/knownDomains/${emailDomain}`, {{Lead.Id}})
.then( upserted => {
  success({
    isNetNewDomain : upserted.body.prevNode ? false : true
  });
});

And the response, suitable for mapping to a Person field or just scanning in a Webhook is Called trigger:

{
  "response" {
    "netNewDomain" : true
}

Pretty cool, eh? This is one part of a “poor man’s ABM” solution you can build using FlowBoost’s ability to combine data across multiple leads.