Campaign Contact Delay Utility (shared/campaignDelay.ts)

deplao-builder · src/shared/campaignDelay.ts · typescript · MIT
crm, automation, lang:typescript, tag:utils

Calculates effective contact delay ranges for CRM campaigns while enforcing anti-spam minimum thresholds. Reuse when managing communication intervals and scheduling in marketing automation.

// Source: https://github.com/babyvibe/deplao-builder | License: MIT | Copyright 2026 babyvibe
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Giãn cách giữa hai liên hệ của chiến dịch CRM.
 *
 * CRMQueueService không bao giờ gửi hai liên hệ cách nhau dưới `CAMPAIGN_MIN_CONTACT_DELAY_SECONDS` (chống spam).
 * Màn tạo / sửa chiến dịch và màn chi tiết dùng cùng hằng số: trước đây ô "Tùy chỉnh khoảng" cho chọn từ 5 giây
 * trong khi queue vẫn chờ 30 giây.
 */
export const CAMPAIGN_MIN_CONTACT_DELAY_SECONDS = 30;

/** Khoảng [min, max] giây queue thực sự dùng: min ≥ mức tối thiểu, max ≥ min. */
export function effectiveContactDelayRange(minSeconds: number, maxSeconds: number): [number, number] {
  const min = Math.max(CAMPAIGN_MIN_CONTACT_DELAY_SECONDS, Number(minSecond

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key