Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / smsRfmToJson

Function: smsRfmToJson()

smsRfmToJson(input): SmsContentJson

Defined in: rcml/src/sms/sms-rfm-to-json.ts:33

Convert an SMS RFM string into an SmsContentJson document.

SMS RFM uses markdown-directive syntax:

  • :link[text]{href="..." track="true|false" shorten="true|false"} → text node with link mark
  • ::placeholder{type="..." original="..." name="..." value="..." max-length="..."} → placeholder node
  • [Type:Name] shorthand (e.g. [Subscriber:FirstName]) — backward-compatible alias for ::placeholder{...}
  • \ at line end → hard line break within a paragraph
  • Double \n\n → new paragraph

Throws RcmlValidationError if the input contains unsupported constructs.

Parameters

input

string

SMS RFM source string.

Returns

SmsContentJson

Typed SMS content JSON ({ type: 'doc', content: [...] }).

Example

ts
// Shorthand placeholder
const doc = smsRfmToJson('Hi [Subscriber:FirstName]!\nYour order has shipped.')

// Link directive
const doc2 = smsRfmToJson('Click :link[here]{href="https://example.com" track="true" shorten="true"}')