Closed daisycrego closed 3 years ago
These are the webbook events supported in the FUB API (https://docs.followupboss.com/reference#webhooks-2):
peopleCreated, peopleUpdated, peopleDeleted, peopleTagsCreated, peopleStageUpdated,peopleRelationshipCreated,peopleRelationshipUpdated,peopleRelationshipDeleted
Looking at peopleUpdated
, which seems the closest:
One or more of the following fields are updated in a person:
Name name firstName lastName Emails emails Phone Numbers phones Address addresses Price price Background background Assigned Agent assignedTo assignedUserId Assigned Lender assignedLenderName assignedLenderId Contacted contacted Stage stage stageId Lead Source source sourceUrl Tags tags Custom Fields Relationship is created, updated, or deleted
It's really not clear to me what these events, "Zillow inquiry"s, look like, where they appear, in the FUB API.
I need to figure out where a Zillow inquiry is going to appear in the data. Is it going to appear as an event? It doesn't seem like the webhook is going to work, because we can't expect the peopleUpdated
webhook to encapsulate the zillow inquiries, and that was the closest one. So , hopefully, a zillow inquiry is an event in the API, let's see.
There actually might be a good webhook: eventsCreated
(under the People Events
section here:
eventsCreated
: People perform an action on your IDX website, e.g. view a property.
We can register a webhook for a peopleEvent
, and then we can filter all of those events to get only the zillow events, and then send out the emails accordingly. This way we might not have to use a scheduled process approach, we can take advantage of the webhook. But we should probably have the ability to do a manual sync run as well. To make sure the data is up to date.
Setup your system to de-couple receiving webhook events from fetching the resource specified in the event. For example--the web service that receives events could record the event in a local database table. A separate backend process could be created to monitor this table for new rows and fetch the resource specified in the event. By separating these, the web service that handles receiving webhooks is doing less and is, therefore less likely to fail. The process that processes the events can contain all the complex logic to fetch the resource from Follow Up Boss, reconcile with your local system and mark the event as processed in the table. If this process fails or breaks it can be debugged independently of the web service. The table that stores events is the source of truth as to what webhook events have been received and processed.
Since webhooks require a publicly accessible URL to function they can be hard to test from your local machine. It is recommended that you use a service like Request Bin when you are developing your webhook endpoints.
So from what I understand, the webhooks are going to alert the system that there is new events data, but the system still has to check whether the event is relevant (Zillow, related to an existing lead), and then decide whether or not to send out an email with the alert.
We will just create a webhook endpoint for eventsCreated
, so that whenever an event is created, we will get a POST to that endpoint. The endpoint is responsible for filtering the event and, if the event is a Zillow inquiry, it will send an email and also create some kind of record in the system (we're not going to be storing all events, just the ones that we send emails about?)
How can we tell from the FUB API if an event is related to a new lead or an existing lead? We need to also be capturing all of the new lead created events, so we have our own DB to refer to for when a lead came into our system. This way, when a person comes in with an event, we can know whether this is a new person (from the POV of FUB) or an existing lead being updated.
So we need to set up a web hook to track all new leads as they come in AND we need to pull all of the existing leads (as of some 0 day) so that we have our own internal lead database which is also synced with the live database through (1) WebHook and (2) manual sync option. That way, we can compare all of the incoming leads to the new leads to understand if this is a new lead or not.
Lead
schema for the database so we can keep track of basic contact details, internal FUB ID for the user (important! we possibly don't need to store full details just the FUB IDs!), and the created date. This way, we can always know when leads were created and if they already existed in the database. POST
endpoint for sending in new leads. Pass this to a WebHook for personCreated
. Whenever a person is created, add a new Lead
object to the database. Event
object to store a new status: newLead
(boolean). If this is NOT a new lead AND this is a Zillow or Zillow Flex source event, then we send out an email alert to get this lead as a possible Zillow exemption. Otherwise we just store the data for the event as usual. POST
endpoint for new events. Pass this to a WebHook for eventCreated
/personEvent
/whatever. Whenever an event is created, see if a person already exists in the database before the last 10 minutes, for example.
Event
object created in the databaseIt may not be necessary to store all of this information in another database. Could actually make everything worse. Keep looking at the API. The /person
endpoint might actually be sufficient.
created
: This is going to be good enough for us, actually. We can also do a simple check if created
exists AND created
===updated
AND created
!= today (not sure if the last check is really necessary but I would have some concerns about never actually checking the day). We need to get a better understanding of the format of the date information - how much of an exact timestamp am I getting? We could go down an a "within the last hour" comparison even, but only if that's the kind of time data FUB is storing. I do really like the elegance of created
exists AND created===updated
, this is a new lead. Otherwise it's not a new lead. Simple as that. Never need to actually see what the time is. Don't need to worry about narrowing things down to the minute/hour/day, etc. We just have to rely on FUB correctly updating that updated
field. I do like that final check though, created
=== today. Probably a smart move just to add that final check.
Event
object to store a new status: isNewLead
(boolean). If this is NOT a new lead AND this is a Zillow or Zillow Flex source event, then we send out an email alert to get this lead as a possible Zillow exemption. Otherwise we just store the data for the event as usual.POST
endpoint for new events. Pass this to a WebHook for eventCreated
/personEvent
/whatever. Whenever an event is created, see if a person already exists in the database before the last 10 minutes, for example.
Event
object created in the databasepersonId
from the event. Parse the created
time and compare it to updated
as well as today's date to see if this is a new lead or not.
Dan: