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:
- Retrieve the associate based on the provided
associateId. - 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_dateless than or equal to the current time.
- Associated with the specified
- Sort the follow-ups based on their
CreatedAttimestamp, with the oldest ones first. - 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
SendDelayVariabilitysetting. - Create a new
ProcessFollowUpTaskwith 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.
- If the count of queued follow-ups reaches the specified
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:
- Calculate a random delay variance based on the associate's
SendDelayVariabilitysetting. - Add the delay variance to the base delay to determine the actual delay for the follow-up.
- 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.