Skip to content

Implement WhatsApp 24-hour session window handling #59

Description

@chillwur

Summary

WhatsApp Cloud API only allows free-form messages within 24 hours of the user's last message; outside that window, only pre-approved message templates can be sent. This directly affects the async notifications the transaction-status-tracking issue needs to send.

Description

Track the timestamp of each user's last inbound message (extending the users table) to know whether the 24-hour session window is currently open.

For any backend-initiated message sent outside the window (e.g. 'your delayed swap just confirmed'), fall back to a pre-approved WhatsApp message template instead of free-form text — this requires template registration with Meta, which is an external, one-time setup step to document.

Update services/whatsapp.ts's sendText (or add a sendTemplate alongside it) to branch on window state.

Add tests asserting the correct send path is chosen based on last-message recency.

Deliverables

  • Session-window tracking per user
  • Template-message fallback path in the WhatsApp service
  • Documentation of the Meta template registration step
  • Tests for window-open vs. window-closed branching

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: architectureCore system architecturearea: backendapps/backend (Fastify, WhatsApp webhook, Stellar services)level: advancedCore architecture, senior/experienced-engineer scopetype: featureNew capability

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions