Drip Logic
Our Drip logic is very similar to that of our Initial Outreach Logic.
Sending is based on the configuration of the associated BlastContact record. Here's a high-level overview of the logic:
- Retrieve the
BlastContactrecord by ID and validate its status. - Validate the
BlastContactdata, including:- Follow-up date (must be within the past 30 calendar days)
- Property details (checking against blocked properties, cities, and states, as well as properties we own)
- Contact details (ensure email and first name are present)
- Outlook login credentials (confirm the sending
OutlookLoginis signed in with valid credentials) - Script details (check that the script is properly filled in)
- Do Not Contact (DNC) list
- Build the email subject and body from the associated script and script variants.
- Generate the email signature.
- Find the email to respond to:
- This process is particularly critical to ensuring accurate emails
- Currently we have two different flows to try and identify which email should be responded to
- The first uses the
In-Reply-Toemail headers to try and match the correct email - The second uses the Microsoft Graph API message search endpoint, using the
Property's address and theContact's email as search parameters - In both methods, if the
Contact(or someone with a similar email, such as in the same company) responds, theBlastContactiscompleted.
- Reply to the previously found email using the Outlook login credentials.
- Update the
BlastContactrecord:- Set the
LastContactedtimestamp. - If the
NextScriptis not set, and the status is not "failed", mark the record as completed. - Otherwise, find the next script based on the
NextScriptIDfield and associate ID. - Update the
BlastContactrecord with the new script details and status.
- Set the
- Handle any errors that occur during the process:
- Update the
BlastContactstatus and failure reason based on the error type. - If the error is related to an invalid sender or expired follow-up, handle it accordingly.
- If the error is related to a failed token refresh, update the Outlook login credentials.
- Update the
The process relies on several helper functions to validate data, fill email templates, and handle errors. The sendNewEmail and sendReply functions are responsible for constructing and sending the actual emails using the Microsoft Graph API.
By following this logic, our system ensures that initial outreach emails are sent according to the configured scripts and contact details, while handling various error scenarios and updating the relevant records in our database.