Phase 47: wire WhatsApp 24h-window confirmation template check (KI-031)#266
Merged
Conversation
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
This was referenced Jun 17, 2026
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>
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.
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.tsshouldUseTemplate()was DEMO-only — in production it fell through to free text unconditionally (aTODO(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 WhatsAppEnquiryMessagefor 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.requiresTemplate(lastInboundAt, now)helper (boundary tested at exactly 24h), plus a confirmation behaviour test proving the outside-window path callssendTemplateMessage(not free text). Existing free-text tests default the window to "inside".Scope / status
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_WHATSAPP_GO_LIVE.md,N8N_PRODUCTION_SETUP.md, the Vetup plan inCLIENT_PRESENTATION_HANDOVER.md).Final merge left to Richard / Freddie.
https://claude.ai/code/session_01VzJJTUcvzZgS9jN8aap9iv
Generated by Claude Code