Schedule a drip sequence

Schedule every step of an onboarding or trial drip up front. Each handler checks current state when it fires.

Use this to
  • Send a 5-email onboarding sequence over a new user's first two weeks
  • Remind a trial user at day 1, day 7, and day 13 that their trial is ending
  • Run a 3-step re-engagement series for users who signed up but never activated
  • Schedule welcome, tips, and case-study emails that each skip if the user already converted
Code
Queue every step at signup
// at signup, schedule the whole drip — one job per step,
// each independently cancellable
await dk.schedule("drip-day-1", { key: user.id, delay: "1d" });
await dk.schedule("drip-day-3", { key: user.id, delay: "3d" });
await dk.schedule("drip-day-7", { key: user.id, delay: "7d" });
When the time comes, each step checks state independently
dk.handle("drip-day-1", async ({ key }) => {
  const user = await db.users.find(key);
  if (user.churned || user.activated) return;
  await sendEmail(user, "welcome-day-1");
});

dk.handle("drip-day-3", async ({ key }) => {
  const user = await db.users.find(key);
  if (user.churned || user.activated) return;
  await sendEmail(user, "tips-day-3");
});

dk.handle("drip-day-7", async ({ key }) => {
  const user = await db.users.find(key);
  if (user.churned || user.activated) return;
  await sendEmail(user, "case-study-day-7");
});
npm install delaykit