Expand description
WhatsApp Cloud API REST client — outbound message send only.
Mirrors Discord’s rest.rs shape (a single send_message function, no
client struct), with one addition Discord doesn’t need: the 24-hour
customer service window (spec §3.3/§3.4). Outside the window, Meta
rejects a free-form text send (error code 131047); rather than round-trip
to the API to discover that, send_message checks the local window state
first and fails fast (or falls back to a configured template) before
making the HTTP call at all.
Constants§
Functions§
- flatten_
text 🔒 - WhatsApp’s Cloud API has no rich embed support (spec §5.3) — if
OutboundMsg.embedis set, flatten it to plain text rather than dropping it silently. - normalize_
phone 🔒 - Strips everything but ASCII digits, so the same phone number in different
formats — Meta’s inbound
from(no+) vs. a caller-suppliedtoin E.164 (+-prefixed) or with spaces/dashes — normalizes to one 24h-window state key.WhatsAppBridge::record_inbound(mod.rs) applies this same normalization when storing, so the two call sites always agree. - send_
message - POST /{phone_number_id}/messages
- window_
ok 🔒 - True if
now_msis within 24h oflast_inbound_ms. Pulled out as a pure function so the boundary condition (spec §10’s “24h window edge case”) is unit-testable without a clock or network call.