Lead Routing Logic
This document outlines the lead routing logic of the Statamic website. Statamic calls SuperPortal public APIs to route leads to FUB.
One Tap and Registration Form
BP one tap or Registration form
The system receives user details from website:
- Phone
- First name
- Last name
- Assigned agent ID (optional)
- Team ID (Hardcoded to Bramlett team)
- FUB Domain ID (Hardcoded to Bramlett)
- Source (ex: BP One Tap, Webform, Property Registration)
- Lock Time (optional)
- Guest User ID (optional, used to backfill anonymous view tracking records before login)
If the email is missing, the request is rejected.
Source Mapping
The incoming source value is converted to one of these internal types:
- public_api → BP Miscellaneous
- webform_entry → BP Webform
- one_tap → BP One Tap
- property_registration → BP Property Registration
If the source is BP One Tap, only leads created by One Tap are considered when checking duplicates. For other sources, we consider the sources BP Miscellaneous, BP Webform, and BP Property Registration.
Note: While registering the source will be property_registration by default. For non-register forms it will be webform_entry
Determine Assigned Agent
If no assigned_user_id is provided for FUB record:
- The system checks Company Settings for default_agent.
- If not found, it falls back to the global config default agent (Eric as per the config).
Duplicate Lead Settings
The system checks whether this company allows duplicate leads.
If the setting duplicate_lead is:
- yes → duplicates can be created
- no → duplicates are prevented using lock time logic
Lock time decides how long a previously created person should be “protected” from duplicates. By default it is 24 hours
Check if the Person Already Exists
The system searches the Follow Up Boss people table for:
- Same email OR same phone within the same team
This returns one or more matching people.
Next, the system filters this list using allowed sources.
Example:
- If the new request is NOT from One Tap, the system can use multiple previous sources (BP Miscellaneous, BP Webform, and BP Property Registration).
- If the request is from BP One Tap, it ONLY checks previous One Tap users.
Duplicate Protection with Lock Time
This only applies when:
- A matching person exists
- The person’s previous source is allowed
- Duplicate creation is turned on
- The new request is not from One Tap
The system then checks:
- The latest person created with the same email/phone (excluding One Tap).
- If this person was created within the lock time:
- The system will update the existing person.
- If the person was created after lock time:
- The system will treat it as a brand new record and create a new person + lead.
When the System Creates a New Person
The system creates a new person when ANY of the following are true:
- No matching person exists
- No matching person from allowed sources exists
- Lock time expired → new record allowed
When creating a new person:
- A new event is sent to Follow Up Boss
- The system updates the person with email/phone
- A new FUBPeople record is created locally
- A new Lead is created
- The user is marked as is_new_user = true
- Any untracked property views get assigned
Finally, the “Person created successfully.”
When the System Updates an Existing Person
If a matching person is found AND duplicate-prevention rules say to use them:
The system updates:
- Phone number
- First/Last name
Then it updates:
- FUBPeople record in DB
- Leads record in DB
Finally, property views are linked to this person, and a response is sent: “Person created successfully.”
How Property Views Are Connected
If a visitor browsed properties before signing up/login:
- They have a temporary guest_user_id.
- After they register/login, the system finds all of their untracked views.
- These views are updated with:
- fub_person_id
- person_id
- For each view, the system triggers an event in FUB (like “Viewed Property”).
This ensures property views show up in Follow Up Boss even if they happened before registration.
Other Forms
Form Submit
A visitor fills out a form in the website (like contact form, agent contact form, agent sign-up form, request more information).
Our backend receives:
- Name
- Phone
- FUB Domain ID
- FUB Person ID
- Team ID
- Form type (what form it is)
- All question/answer data (if any)
- Tags (if the form asks for tags)
- Landing page URL
- IP address
- Whether the form should allow duplicates or not (By default false)
- Lock Time (Either client passes / from config (24 Hours))
Spam Lock
It checks the user’s:
- Phone number
- IP address
- Message
If the same person (same IP address) submits the form more than 3 times within 24 hours, the system blocks it and returns:
“Too many requests.”
Nothing else happens. No lead is created.
Duplicate Leads
The system checks:
- Does this email or phone already exist in Follow Up Boss?
- Is this form type allowed to create duplicates?
- Has this person already submitted a form recently?
Lead Lock Protection
If a lead was already created recently (based on form type + email + phone), the system prevents creating a new one again.
This solves accidental double-submissions.
Follow Up Boss Update
This includes:
- Name
- Phone
- Tags
- Form type (converted into a Follow Up Boss event)
- Description (what they filled in)
- Landing page URL (if sent)
- Assigned Agent ID (if the form type chooses a specific agent else we keep the existing agent)
Create/Update Person in Follow Up Boss
If this form is allowed to create duplicates / no existing person:
A brand-new person is created in FUB.
If duplicates are NOT allowed:
The system looks for an existing contact:
- If found → updates the existing person
- If not found → creates a new person
Create a Lead if Needed
After the Follow Up Boss person is created or updated in the leads table:
Create a new lead when:
- No matching person existed
- No matching lead existed
- Or when duplicate creation is allowed
No new lead when:
- Person already exists
- Lead already exists
- Duplicate creation is not allowed
Email Notification - From Statamic
After the form is successfully processed (and before lead creation logic):
The system sends email notifications based on form type:
- Agent contact form
- Agent sign up form
No email is sent when:
- Submission is rate-limited by spam lock
- Duplicate submission is blocked
- Required fields are missing
Add or update phone number if needed
If the existing person in Follow Up Boss has no phone number, but the form has one, then the system will add the new phone number.
Everything is saved in the database
Every form submission is recorded in the public_forms table:
- Who submitted
- What form type they used
- Their IP
- Raw data
- Status (Success / Rate-limited)