Skip to content

SMS

The SMS module provides the types, format converters, and validation functions needed to build SMS templates that the Rule platform can render and send.

An SMS template is a single <rc-sms> element. The whole message is the text content of that element, written in SMS RFM (SMS Rule Flavor Markdown).

Template formats

A template exists in two equivalent representations. Both carry the same content and convert between each other.

  • JSON (SmsDocument) — the canonical format. The Rule API accepts and returns this. Every other format converts to or from it.
  • XML — a compact, readable representation of the same template. The text body of <rc-sms> is an SMS RFM string.

A minimal example in both formats:

xml
<rc-sms>Your order has shipped!
Account: ::placeholder{type="Subscriber" original="[Subscriber:email]" name="Email"}</rc-sms>
typescript
import type { SmsDocument } from '@rule/rcml';

const doc: SmsDocument = {
  tagName: 'rc-sms',
  content: {
    type: 'sms',
    content: [
      { type: 'message', text: 'Your order has shipped!\nAccount: ' },
      {
        type: 'placeholder',
        attrs: {
          type: 'Subscriber',
          name: 'Email',
          original: '[Subscriber:email]',
          value: null,
        },
      },
    ],
  },
};

The document structure is explained in Template; the content model is explained in Content.

In this section

PageWhat it covers
TemplateSmsDocument structure and createSmsDocument() usage
ContentSmsContentJson flat sequence model and node types
UnsubscriptionRequired unsubscribe footer and createUnsubscribeNodes()
SMS RCMLThe rc-sms element reference
RCML ContentSMS RFM flavor and node reference
Building programmaticallycreateSmsDocument, the sms builder namespace, SMS RFM ↔ JSON, XML round-trip
ValidationValidating documents and content before submission
Building with LLMUsing spec objects to drive LLM-assisted template generation