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>Hi ::placeholder{type="Subscriber" original="[Subscriber:FirstName]" name="First name"}, your order has shipped!</rc-sms>
typescript
import type { SmsDocument } from '@rule/rcml';

const doc: SmsDocument = {
  tagName: 'rc-sms',
  attributes: {},
  content: {
    type: 'doc',
    content: [
      {
        type: 'paragraph',
        content: [
          { type: 'text', text: 'Hi ' },
          {
            type: 'placeholder',
            attrs: {
              type: 'Subscriber',
              name: 'First name',
              original: '[Subscriber:FirstName]',
              value: null,
              'max-length': null,
            },
          },
          { type: 'text', text: ', your order has shipped!' },
        ],
      },
    ],
  },
};

The full type model lives in SMS document; the SMS RFM syntax used inside <rc-sms> lives in SMS RFM.

In this section

PageWhat it covers
SMS documentThe SmsDocument and SmsContentJson type model
SMS RFMThe SMS RFM source format: paragraphs, hard breaks, placeholders, links
SMS RCMLThe rc-sms element reference
SMS RFM ContentEvery node and mark with full attribute tables
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