Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / createSmsDocument

Function: createSmsDocument()

createSmsDocument(options): SmsDocument

Defined in: rcml/src/sms/create-sms-document.ts:68

Create an SMS RCML document.

Returns an SmsDocument that can be passed to client.templates.createSmsTemplate or client.templates.updateSmsTemplate.

A UUID is automatically generated for the id field. The Rule editor requires this identifier to open and save templates.

Parameters

options

CreateSmsDocumentOptions

SMS document options.

Returns

SmsDocument

A valid SmsDocument.

Throws

When a pre-built SmsContentJson is supplied and fails schema validation.

Example

typescript
import { createSmsDocument } from '@rule/rcml';

// From an SMS RFM string
const doc = createSmsDocument({
  content: 'Your order has shipped!\nAccount: [Subscriber:email]',
});

// From a pre-built content JSON document
const doc2 = createSmsDocument({
  content: {
    type: 'sms',
    content: [{ type: 'message', text: 'Hello!' }],
  },
});

const template = await client.templates.createSmsTemplate({
  name: 'Order shipped SMS',
  content: doc,
});