Drips
Logic

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:

  1. Retrieve the BlastContact record by ID and validate its status.
  2. Validate the BlastContact data, 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 OutlookLogin is signed in with valid credentials)
    • Script details (check that the script is properly filled in)
    • Do Not Contact (DNC) list
  3. Build the email subject and body from the associated script and script variants.
  4. Generate the email signature.
  5. 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-To email headers to try and match the correct email
    • The second uses the Microsoft Graph API message search endpoint, using the Property's address and the Contact's email as search parameters
    • In both methods, if the Contact (or someone with a similar email, such as in the same company) responds, the BlastContact is completed.
  6. Reply to the previously found email using the Outlook login credentials.
  7. Update the BlastContact record:
    • Set the LastContacted timestamp.
    • If the NextScript is not set, and the status is not "failed", mark the record as completed.
    • Otherwise, find the next script based on the NextScriptID field and associate ID.
    • Update the BlastContact record with the new script details and status.
  8. Handle any errors that occur during the process:
    • Update the BlastContact status 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.

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.