Delivery-Mode Gate and SMS Consent State Machine

    1

    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

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    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

    MetricValue
    Recipient+15550109999 (Encrypted at rest)
    Delivery Modedemo
    Consent Statusrequested
    Action Takengate.requestConsent recorded
    Audit Trail IDmsg_8829_x92
    Provider Sentfalse (Simulated)
    EncryptionAES-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

    1. Review the data/consent.db SQLite file to verify the HMAC blind index is working for search.
    2. Simulate an inbound START keyword from this number to move the state machine to granted.
    3. Switch DELIVERY_MODE to live in your .env only after verifying the demo_queued logs.

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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+

    Permissions

    Environment Variables
    Read Files
    Write Files
    Listed18 days ago

    What's inside

    Frequently Asked Questions

    This skill acts as a fail-safe between your application logic and your SMS provider, preventing accidental messages during development via a three-state gate (disabled, demo, live) while enforcing strict TCPA-compliant consent states.

    It is designed for Node.js 22.5+ environments and integrates seamlessly with any AI agent or backend framework that supports custom JavaScript modules, utilizing native 'node:sqlite' and 'node:crypto' for maximum performance.

    Security is built-in through AES-256-GCM encryption for PII and HMAC blind indexing, which allows you to look up records by phone number without ever storing or searching against plain-text data.

    The package includes the core Node.js logic, a pre-configured SQLite schema for consent tracking, the multi-state delivery gate, and a comprehensive audit trail system for carrier compliance reviews.

    Setup is minimal: initialize the store with a SQLite path and a 32-byte encryption key, then run the boot preflight check to ensure your environment variables are correctly configured for your intended delivery mode.

    Yes, the state machine includes a mandatory 24-hour cooldown for consent requests and supports idempotent webhook processing to ensure 'STOP' and 'START' signals are handled reliably without double-processing.

    New in APIs & Backend