WhatsApp commerce: MVP, template manager, cart recovery + strategy and audit docs - #3
Draft
bpalmer77fluid wants to merge 7 commits into
Draft
WhatsApp commerce: MVP, template manager, cart recovery + strategy and audit docs#3bpalmer77fluid wants to merge 7 commits into
bpalmer77fluid wants to merge 7 commits into
Conversation
- Raw-body capture in Fastify config + enforced X-Hub-Signature-256 verification on the WhatsApp webhook (when app secret is configured) - Meta Commerce Manager catalog sync (items_batch upsert) triggered from the existing Fluid product webhook - Fluid platform order integration: create rep-attributed orders on cart submission and mark them paid on M-Pesa settlement via the installation's DIT token (FluidService) - Multi-tenant routing: whatsapp_configs table maps the receiving phone_number_id to an installation, with env-var single-tenant fallback - Callback hardening: shared-secret guard and idempotent settlement on the Daraja callback; session rep binding is first-touch - docs/whatsapp-demo-runbook.md: Track A (no-code UX test) and Track B (full sandbox flow), Meta account-integrity guidance, demo checklist Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tit6o2QgCo8mvvnNopmRD
Three-stage path (demo -> BSP pilot -> Meta Tech Provider) with stage gates, Meta requirements checklist, business model options, go-to-market sequencing by payment rail, risk table, 90-day plan, and success metrics. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tit6o2QgCo8mvvnNopmRD
Self-contained brief for an agent with live browsing access: objective, business context, pages to audit, capture method and comparison matrix fields, six hypotheses to verify or falsify, deliverable format, constraints, and definition of done. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tit6o2QgCo8mvvnNopmRD
…weaks Handoff 1: step-by-step process to bring the scraped Fluid clone to parity with the live FL Kenya page - capture setup, element inventory, fixes in dependency order, scrape-artifact checklist, acceptance criteria, and an Intentional Divergence list so deliberate additions are preserved. Handoff 2: localization audit (Canada benchmark, H1-H6 hypotheses) plus additive-only conversion tweaks constrained to in-place edits and inserted bands, including replacement options for the low-yield aloe graphic. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tit6o2QgCo8mvvnNopmRD
…erce finding - New docs/whatsapp-commerce-competitive-playbook.md: four-layer market map, deep study of Yalo/Haptik/charles, conversion benchmarks with design rules, ease-of-deployment bar, Fluid's differentiation, capability gap analysis, and ten things to copy in priority order - Teardown: new subsection on reps DIY-ing WhatsApp storefronts (Kyte example, slug evidence it is an individual not corporate) plus a shadow-commerce observation - Competitive landscape: new tooling-layer section covering Kyte and peers, what it validates and where the moat is Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tit6o2QgCo8mvvnNopmRD
Template manager (docs playbook identified this as the critical path, since every out-of-window message needs an approved template): - MessageTemplate model plus a pre-built, compliance-reviewed library of six templates (cart recovery x3, receipt, order status, payment failed) with no health or income claims - TemplateService seeds the library, submits to Meta's message_templates API with placeholder examples, and polls approval status - routes/templates.ts exposes library/list/seed/submit/sync so a client never opens the Meta console - whatsapp_configs gains wabaId; WhatsAppService gains sendTemplate() Cart recovery (benchmarks: 18-23% recovery, automated flows drive 60-70% of WhatsApp revenue): - CartRecovery model tracking stage, next attempt, and terminal status - 30min / 24h / 72h arc; scheduled when the STK push fires, cancelled on payment success, reconciled against paid orders before each run - 24-hour window respected: plain text inside the window, approved template outside it, skip rather than send non-compliantly - reply pay now actually works - re-fires the STK push for the open cart (previously the failure message promised this with no handler); cancel and stop close the arc - routes/jobs.ts runner endpoint (secret-protected, cron-friendly) plus an optional in-process interval for demos Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tit6o2QgCo8mvvnNopmRD
Packages the next phase — client-experience strategy and deployment playbook on top of Mike's Meta Commerce API integration — as a copy-pasteable prompt plus a standalone context brief for a fresh session. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tit6o2QgCo8mvvnNopmRD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Takes the WhatsApp commerce scaffold (merged in #2) from "compiles and demonstrates the flow" to a deployable sandbox MVP with the two highest-ROI automations, plus the strategy and execution docs built around it.
Code
MVP completion (the four scaffold TODOs)
config/fastify.tspreserves the raw JSON body;routes/whatsapp.tsverifiesX-Hub-Signature-256over the raw bytes and enforces it wheneverWHATSAPP_APP_SECRETis set (401 on mismatch)WhatsAppService.syncProductToCatalogvia the Commerce Manageritems_batchupsert (retailer_id = Fluid SKU), triggered fire-and-forget from the existing Fluid product webhook so catalog failures never block webhook processingservices/fluidService.tscreates rep-attributed orders on cart submission (DIT token) and marks them paid on M-Pesa settlement;mpesa_paymentscarries thefluidOrderIdlink, with local orders as the fallback source of truthwhatsapp_configsmodel mapsphoneNumberId→ installation (plusaccessToken,catalogId,wabaId); env vars remain the single-tenant fallback, and every outbound send is tenant-awareTemplate manager — identified as the critical path, since every out-of-window message requires an approved template
MessageTemplatemodel +services/templateService.tsUTILITYcategory, no health or income claimsmessage_templatesAPI with the placeholder examples review requires; polls approval statusroutes/templates.ts: library / list / seed / submit / sync, so a client never opens the Meta consoleAbandoned-cart recovery — benchmarks: 18–23% recovery, automated flows drive 60–70% of WhatsApp revenue
CartRecoverymodel +services/cartRecoveryService.tswhatsapp_sessions.lastMessageAt), approved template outside it, and skip rather than send non-compliantlypay/lipanow re-fires the STK push for the open cart and writes a fresh payment row for the callback to settle;cancel/stopclose the arc. Keyword handling runs before the catalog fallback.routes/jobs.ts: secret-protectedPOST /api/jobs/cart-recoveryrunner (cron-friendly, multi-instance safe) plus an optional in-process interval for demo boxesHardening
MPESA_CALLBACK_SECRET) and idempotent settlement (status = 'pending'guard so retries no-op)Docs
docs/whatsapp-commerce-spec.md— updated for the template manager, recovery service, and the 24-hour window ruledocs/whatsapp-demo-runbook.md— Track A (15-min no-code UX test) and Track B (full sandbox: Meta app + test number, Daraja sandbox, deploy, walk the flow, demo checklist), plus Meta account-integrity guidancedocs/whatsapp-commerce-competitive-playbook.md— four-layer market map, deep study of Yalo / Haptik / charles, conversion benchmarks with the design rules they imply, ease-of-deployment bar, Fluid's differentiation (nobody else models a salesforce), capability gap analysisdocs/whatsapp-tech-provider-strategy.md— three-stage path (demo → BSP pilot → Meta Tech Provider) with stage gates, Meta requirements, business model options, market sequencing by payment rail, risks, 90-day plan, metricsdocs/whatsapp-cx-strategy-handoff.md— handoff package for the next phase: a copy-pasteable prompt directing a fresh session to research best-of-breed WhatsApp commerce providers and produce the client-experience strategy + skill-ready deployment playbook (assumes the Meta Commerce API integration layer is handled separately), plus a standalone context briefdocs/fl-localization-audit-brief.md— brief for an agent with live browsing access to audit FL's localization strategy (Canada as benchmark), with six hypotheses to verify or falsifydocs/mist-handoff-1-fidelity.md— process to bring the scraped Fluid clone to parity with the live FL Kenya page, including an Intentional Divergence list so deliberate additions survive the passdocs/mist-handoff-2-improvements.md— additive-only conversion tweaks (in-place edits and inserted bands, no redesign), including replacement options for the low-yield "Aloe as Nature Intended" graphicdocs/forever-living-kenya-teardown.md/-competitive-landscape.md— added the Kyte shadow-commerce finding: reps already DIY WhatsApp storefronts, which validates demand and locates the moatVerification
tsc --noEmitpasses;prisma validatepasses; Prisma client regenerates cleanlyforeverliving.comorforever-living-kenya.fluid.app(both egress-blocked in the authoring environment), so their findings are framed as labeled hypotheses for the executing agent to confirm or correct