К содержанию
Статья ещё не опубликована на языке Russian. Показана версия на English.

Engineering Reply-Aware Follow-Up Sequences and Conversational State Machines

2 мин на чтение

Nothing ruins a customer relationship faster than a blind automated reminder saying "Hey, still thinking about your order?" ten minutes after the customer already replied or paid. Reply-aware sequences connect live inbox events, payment confirmations, and opt-outs directly into the follow-up state machine so automations immediately adapt or step aside.

Core Cancellation & Branching Signals

SignalExpected Sequence Behavior
Customer replies in threadCancel pending nudge timer; branch to AI answer or human inbox
Payment / conversion recordedMark funnel converted; cancel all remaining reminders
Customer sends opt-out / STOPImmediately suppress contact globally; terminate active sequences
Human teammate messages threadPause automated follow-ups to prevent colliding with live agent
Delivery permanently failedStop downstream nudges for unreachable recipient

Preventing Overlapping Campaigns (Contact Cooldown Policy)

When a workspace runs multiple automations (welcome flow, abandoned-cart reminder, promotional broadcast), a single customer could qualify for three workflows in the same afternoon. Enforce a per-contact cooldown ledger before dispatching any proactive message:

ts
export interface ContactPolicyDecision {
  allowed: boolean;
  skipReason?: "opted_out" | "recent_proactive_contact" | "active_human_thread" | "quiet_hours";
}

export function evaluateProactiveContactPolicy(context: {
  optedOut: boolean;
  hasActiveHumanSession: boolean;
  lastProactiveSentAtMs: number | null;
  cooldownWindowMs: number;
  nowMs: number;
}): ContactPolicyDecision {
  if (context.optedOut) return { allowed: false, skipReason: "opted_out" };
  if (context.hasActiveHumanSession) return { allowed: false, skipReason: "active_human_thread" };
  if (
    context.lastProactiveSentAtMs !== null &&
    context.nowMs - context.lastProactiveSentAtMs < context.cooldownWindowMs
  ) {
    return { allowed: false, skipReason: "recent_proactive_contact" };
  }
  return { allowed: true };
}

Debouncing Rapid Multi-Message User Bursts

Real messaging users often split one thought across four quick bubbles ("Hi", "quick question", "about the large lamp", "does it come in black?"). Debouncing inbound triggers by a short 2 to 5 second sliding window lets you assemble all four bubbles into one coherent turn before running RAG or workflow transitions.

Continue to the next pillar: Multi-Tenant SaaS, Real-Time Messaging, and Modern Web Engineering Guide.

Было ли это полезно?