Follow-Ups
Queueing

Initial Outreach Queueing Logic

Our system handles the queueing of initial outreach emails in a structured and efficient manner. Let's dive into the details of how this process works.

Cron (Timed) Jobs

We have one cron job set up to trigger the queueing of drips. More details can be found here.

These cron jobs ensure that the queueing process is triggered at the appropriate times.

Queueing Process

The main queueing process is handled by the Queue function in the followup package. Here's a breakdown of the steps involved:

  1. Retrieve the associate based on the provided associateId.
  2. Fetch the pending follow-ups for the associate that meet the following criteria:
    • Associated with the specified associateId.
    • Have a status of "pending".
    • Have a follow_up_date less than or equal to the current time.
  3. Sort the follow-ups based on their CreatedAt timestamp, with the oldest ones first.
  4. Iterate over the sorted follow-ups:
    • If the count of queued follow-ups reaches the specified limit, break the loop.
    • If the follow-up script is not set or the script keyword is not "Long Term" or "Follow Up", skip to the next follow-up.
    • Update the status of the follow-up to "queued" and save the changes.
    • Generate a unique task ID based on the follow-up ID.
    • Calculate a random delay variance based on the associate's SendDelayVariability setting.
    • Create a new ProcessFollowUpTask with the follow-up ID, calculated delay, and task ID.
    • Enqueue the task using the provided Queuer.
    • Increment the count of queued follow-ups.
    • Increment the delay by 60 seconds.

That covers the main logic behind how we queue follow-up emails. The process is designed to handle rate limiting, sort follow-ups based on creation time, and ensure that the emails are sent with appropriate delays.

Rate Limiting and Delay The Queue function handles the rate limiting and delay calculation for each follow-up. It performs the following steps:

  1. Calculate a random delay variance based on the associate's SendDelayVariability setting.
  2. Add the delay variance to the base delay to determine the actual delay for the follow-up.
  3. Increment the base delay by 60 seconds for each queued follow-up.

The delays help distribute the email sending over time to avoid hitting rate limits and maintain a steady flow of outgoing emails.