32 — Email/SMS Operational Detail (Blueprint §4)
Cursor-ready operational runbook for the testimonial request messaging lifecycle: scheduling, sending, event tracking, reminder policy, and stop conditions.
32 — Email/SMS Operational Detail (Blueprint §4)
Section titled “32 — Email/SMS Operational Detail (Blueprint §4)”Source: 02-Implementation-Blueprint.md — §4) Email/SMS Workflow (Operational Detail).
Note: 07-email-sms-request-delivery-pipeline.md focuses on implementation architecture.
This file is the operational behavior contract for runtime execution and support.
This document is a build spec only. No code changes are implied until a task references this file.
0) Goal (one sentence)
Section titled “0) Goal (one sentence)”Define exact operational behavior for request messaging so every request moves through a predictable lifecycle from schedule to send to reminders to completion.
1) Canonical lifecycle (from blueprint)
Section titled “1) Canonical lifecycle (from blueprint)”- Order event webhook received.
- Eligibility evaluated against campaign rules.
- Split eligible delivered order items into product-level request jobs.
- Create one request row per delivered product with token and scheduled send time.
- Worker/cron sends one message per request row.
- Track delivery/open/click events.
- If no submission by reminder window, send reminder.
- Stop reminders when submission is completed.
Treat these 8 steps as the source of truth for runtime operations.
2) Operational states and timing
Section titled “2) Operational states and timing”2.1 Request state lifecycle
Section titled “2.1 Request state lifecycle”Recommended status path:
scheduledqueuedsentclickedsubmitted- terminal alternatives:
failed,expired
2.2 Timing controls
Section titled “2.2 Timing controls”- Initial send time = trigger event time + campaign
delayDays - Reminder send time = first
sentAt+reminderDelayDays(+ repeated windows up tomaxReminders) - All scheduling in UTC
3) Message dispatch contract
Section titled “3) Message dispatch contract”Each TestimonialRequest should attempt to send exactly once per planned send slot.
3.1 Required inputs per send attempt
Section titled “3.1 Required inputs per send attempt”- destination channel (email/sms/both)
- rendered template content
- submission link token URL
- campaign and request IDs for traceability
3.2 Required outputs
Section titled “3.2 Required outputs”- status update on request row
- event row in
TestimonialRequestEvent - provider reference (if available)
4) Event taxonomy and semantics
Section titled “4) Event taxonomy and semantics”For operational consistency, map events:
queued— request ready for worker processingsent— provider accepted send requestdelivered— provider delivery confirmation (if available)opened— open tracking fired (email only; optional)clicked— customer opened submission linkfailed— send attempt failed
If provider lacks delivered/open support, keep those events optional and document as such in logs and UI.
5) Reminder policy contract
Section titled “5) Reminder policy contract”Reminder is allowed only when all are true:
- campaign
reminderEnabled=true reminderCount < maxReminders- request not
submitted - required reminder window elapsed
5.1 Stop conditions (hard)
Section titled “5.1 Stop conditions (hard)”Stop future reminders when:
- request status is
submitted - request status is
expired - campaign is paused/archived before reminder execution
6) Failure handling operations
Section titled “6) Failure handling operations”6.1 Send failure
Section titled “6.1 Send failure”- set request
lastError - write
failedevent - retry by policy (bounded attempts)
6.2 Retry policy (recommended)
Section titled “6.2 Retry policy (recommended)”- exponential backoff with max attempts (e.g. 3)
- after max attempts, mark terminal failed
6.3 Dead-letter visibility
Section titled “6.3 Dead-letter visibility”Failed rows must be visible in Requests Log screen with clear reason.
7) Idempotency and replay behavior
Section titled “7) Idempotency and replay behavior”7.1 Webhook replay
Section titled “7.1 Webhook replay”- duplicate webhook deliveries must not create duplicate request rows
7.2 Worker replay
Section titled “7.2 Worker replay”- re-running send worker must not re-send already-sent slots unless explicit resend action exists
7.3 Event replay safety
Section titled “7.3 Event replay safety”- avoid duplicate event records with identical
(requestId, eventType, providerMessageId, eventAt-window)where practical
8) Operational monitoring expectations
Section titled “8) Operational monitoring expectations”Track at minimum:
- requests scheduled per day
- send success rate
- failure rate by provider/channel
- click-through rate
- reminder send volume
Use these for on-call/support diagnostics and merchant-facing status confidence.
9) Runbook actions (support/ops)
Section titled “9) Runbook actions (support/ops)”When issues occur:
- Check request row status and
lastError - Inspect event stream for missing
sentorclicked - Confirm campaign status and reminder settings
- Verify provider credentials and quotas
- Retry failed sends if still actionable and not submitted
10) SLA-style expectations (internal)
Section titled “10) SLA-style expectations (internal)”- request creation from webhook: near-real-time (seconds)
- due-send worker latency: within scheduler interval (e.g. <= 5 minutes)
- event persistence: same transaction/window as send acknowledgement
If SLOs breach, raise operational alert.
11) Acceptance checklist
Section titled “11) Acceptance checklist”- All 8 blueprint workflow steps are represented in code paths and logs.
- Reminder stop conditions work correctly.
- Failed sends are visible and diagnosable.
- Duplicate webhook replay is safe.
- Channel support differences (email vs sms) are documented and handled gracefully.
12) Suggested implementation linkage
Section titled “12) Suggested implementation linkage”Use this doc as operational reference while implementing:
07-email-sms-request-delivery-pipeline.md(system design)13-requests-log-blueprint-screen-10.md(visibility UI)16-templates-screen-4.md(template rendering)22-integration-and-processing-plan-blueprint-section-7.md(cross-module flow)
13) References
Section titled “13) References”02-Implementation-Blueprint.md— Section 401-Post-Purchase-Video-Testimonial-Collector-Plan.md— messaging + reminder scope
14) Note on numbering
Section titled “14) Note on numbering”This folder already includes 05 through 31 plans. This file is 32-....