- Home
- Skills
- APIs & Backend
- Delivery-Mode Gate and SMS Consent State Machine
Delivery-Mode Gate and SMS Consent State Machine
The dangerous moment for a messaging service is the first week in production: webhooks, database and UI are all real, and one misread flag texts a stranger.
$29
Works with the AI Agents you already use
Delivery-Mode Gate and SMS Consent State Machine
Example session with this skill installed
Initialize a delivery gate in demo mode and check if I can send a message to +15550109999 for a user named Alice.
- Read your context and instructions
- Compiled the delivery-mode gate
The delivery gate has been initialized in demo mode. The consent state for the recipient has been checked and a record has been created in the audit trail. Since the system is in demo mode, no external network request was made to the provider, but the workflow was fully simulated.
SMS Delivery Gate Execution
| Metric | Value |
|---|---|
| Recipient | +15550109999 (Encrypted at rest) |
| Delivery Mode | demo |
| Consent Status | requested |
| Action Taken | gate.requestConsent recorded |
| Audit Trail ID | msg_8829_x92 |
| Provider Sent | false (Simulated) |
| Encryption | AES-256-GCM |
// Internal state snapshot after execution
{
"correlationId": "msg_8829_x92",
"history": [
{ "kind": "intent", "mode": "demo", "status": "pending" },
{ "kind": "consent_check", "result": "requested" },
{ "kind": "demo_queued", "body": "Alice would like to send you updates..." }
],
"chargeable": false
}
Next steps
- Review the
data/consent.dbSQLite file to verify the HMAC blind index is working for search. - Simulate an inbound
STARTkeyword from this number to move the state machine togranted. - Switch
DELIVERY_MODEtolivein your.envonly after verifying thedemo_queuedlogs.
Connects securely to your tools. The creator never sees your data.
About this skill
The dangerous moment for a messaging service is the first week in production: webhooks, database and UI are all real, and one misread flag texts a stranger. This kit makes sending a three-state decision recorded in an append-only trail, makes consent a state machine that is checked again at the instant of delivery, and makes replayed provider callbacks harmless.
delivery-mode.mjs: DELIVERY_MODE is mandatory operational state. disabled refuses every delivery and records the refusal; demo runs the complete workflow (consent request, message, callback claim, delivery record with the body and recipient) and never calls the provider or charges anyone, so a real deployment can be proven end to end for weeks; live calls your send and a delivery is chargeable only after the provider accepted it. An unknown value throws at boot. handleCompletion claims the correlation id first (replays do nothing), re-checks consent (a late STOP is honoured as blocked_consent), delivers, and calls onChargeable only on sent. handleInbound applies YES/START/STOP/HELP and returns the reply.
consent-store.mjs (node:sqlite): per-number pending/granted/revoked with a 24-hour request cooldown, a revoked number the service never asks again (only the recipient's own START reopens it), requesters recorded, phone numbers encrypted at rest with an HMAC blind index as the lookup and uniqueness key, an append-only delivery trail with encrypted bodies, and a status-guarded claim table for idempotent callbacks. field-crypto.mjs: AES-256-GCM and HKDF-derived subkeys from one 32-byte key. keywords.mjs: the standard grant, revoke and help words, the provider's OptOutType winning over the body, reply templates with STOP and HELP literal, and a reply checker (160 characters, opt-out wording, no public shorteners).
preflight.mjs: pure configuration checks that fail closed at boot: valid mode, owned sender number in E.164, provider credentials, signature validation never disabled in production, HTTPS public base URL that is not a tunnel, a field key, and a recorded approval reference before live delivery in production.
Reference: the mode table, the consent state diagram, idempotent callbacks, what is stored and how, and the six items to settle before going live. 6 tests. Node 22.5+, no packages, no network.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Normalization favors North American/E.164 formats. Requires Node 22.5+. Webhook signature validation must be implemented at the framework level.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 18 days ago
- Software
Node.js 22.5+