Skip to content

Phase 47: wire WhatsApp 24h-window confirmation template check (KI-031)#266

Merged
RJK134 merged 1 commit into
mainfrom
feature/47-ki031-confirmation-window
Jun 17, 2026
Merged

Phase 47: wire WhatsApp 24h-window confirmation template check (KI-031)#266
RJK134 merged 1 commit into
mainfrom
feature/47-ki031-confirmation-window

Conversation

@RJK134

@RJK134 RJK134 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Phase 47 — KI-031: wire the WhatsApp 24h-window confirmation template check

Delivers the one genuinely code-deliverable item left on the backlog. confirmation.service.ts shouldUseTemplate() was DEMO-only — in production it fell through to free text unconditionally (a TODO(prod)), which would cause real WhatsApp sends to be rejected by Meta outside the 24-hour customer-service window.

Change

  • shouldUseTemplate(enquiryId) now (in production) queries the most-recent INBOUND WhatsApp EnquiryMessage for the enquiry and uses the approved template when it is ≥24h old or absent; free text only inside the window. Demo mode still always templates; a confirmation with no linked enquiry → template.
  • Decision extracted into a pure, unit-tested requiresTemplate(lastInboundAt, now) helper (boundary tested at exactly 24h), plus a confirmation behaviour test proving the outside-window path calls sendTemplateMessage (not free text). Existing free-text tests default the window to "inside".

Scope / status

  • No schema change. Single service + its test + KNOWN_ISSUES updated (KI-031 → resolved-with-notes).
  • It stays dormant until the live Meta WhatsApp path is enabled (externally blocked on Meta business verification) — but the logic is now correct and tested rather than a TODO, so there's nothing to remember when Meta goes live.

Verification

lint ✓ · typecheck ✓ · prisma validate ✓ · build ✓ · unit suite 2,835 → 2,839 (+4).

On the rest of the backlog (honest note)

This PR is the only remaining code item. The other backlog entries are not code-deliverable or not worth building on spec:

  • Meta verification / n8n hosting / Vetup API — external/credentialed actions no agent can perform (the runbooks already cover them: META_WHATSAPP_GO_LIVE.md, N8N_PRODUCTION_SETUP.md, the Vetup plan in CLIENT_PRESENTATION_HANDOVER.md).
  • Invoicing tail (multi-currency / recurring billing) — genuinely low value for a single-CHF-practice and a real risk to the working finance module; I'd recommend against building them speculatively. "Refunds of received money" (a deliberate Phase 41 exclusion) is the only defensible one — happy to build it if you confirm you want it.

Final merge left to Richard / Freddie.

https://claude.ai/code/session_01VzJJTUcvzZgS9jN8aap9iv


Generated by Claude Code

shouldUseTemplate() was DEMO-only — production fell through to free text
unconditionally (a TODO(prod) that would fail real sends outside Meta's
24h customer-service window). It now queries the most-recent INBOUND
WhatsApp EnquiryMessage for the enquiry and uses the approved template
when that is >=24h old or absent; free text only within the window. Demo
mode unchanged; a confirmation with no linked enquiry -> template.

- Pure, unit-tested requiresTemplate(lastInboundAt, now) helper (boundary
  at exactly 24h) + a confirmation behaviour test for the outside-window
  template path. Unit suite 2,835 -> 2,839.
- KI-031 marked resolved in KNOWN_ISSUES (still dormant until the live
  Meta WhatsApp path is enabled; the logic is now correct + tested). No
  schema change.

https://claude.ai/code/session_01VzJJTUcvzZgS9jN8aap9iv

@RJK134 RJK134 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed

@RJK134 RJK134 merged commit 3931e8d into main Jun 17, 2026
9 of 10 checks passed
@RJK134 RJK134 deleted the feature/47-ki031-confirmation-window branch June 17, 2026 08:59
RJK134 added a commit that referenced this pull request Jun 17, 2026
The self-built 'BugBot PR Review' check in claude-code-review.yml has
been failing identically on every recent PR (#261/#263/#266/#267) with
an internal 'directory mismatch for directory ".../tsconfig.json" ...
this indicates a bug. You don't need to do anything' error in the post-
buffered-inline-comments step — it crashes ~20s in, regardless of PR
content. The recurring spurious red obscures the real merge gates.

Root cause: this workflow pinned anthropics/claude-code-action to an
older v1.0 commit (1dc994ee, 2026-06) whose internal action.yml step
has the bug. Bump to 51ea8ea7 (refs/tags/v1, the same SHA the sibling
claude.yml workflow already uses), which clears the crash.

Other workflows (claude.yml, claude-code-fix.yml) are unaffected — they
already use 51ea8ea7 / @v1. Real merge gates (check/docker/security/
e2e/GitGuardian) and the substantive AI reviewer (Cursor Bugbot) are
untouched.

https://claude.ai/code/session_01VzJJTUcvzZgS9jN8aap9iv

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants