Appearance
Rule.io SDK / rcml/src / smsRfmToJson
Function: smsRfmToJson()
smsRfmToJson(
input):SmsContentJson
Defined in: rcml/src/sms/sms-rfm-to-json.ts:41
Convert an SMS RFM string into an SmsContentJson document.
SMS RFM uses markdown-directive syntax:
:link[url]{track="true|false" shorten="true|false"}→ top-levellinknode::placeholder{type="..." original="..." name="..." value="..." max-length="..."}→placeholdernode[Type:Name]shorthand (e.g.[Subscriber:email]) — backward-compatible alias for::placeholder{...}- Plain text (including embedded
\n) →messagenode
Throws RcmlValidationError if the input contains unsupported constructs.
Parameters
input
string
SMS RFM source string.
Returns
Typed SMS content JSON ({ type: 'sms', content: [...] }).
Example
ts
// Shorthand placeholder
const json = smsRfmToJson('Account: [Subscriber:email]\nYour order has shipped.')
// { type: 'sms', content: [
// { type: 'message', text: 'Account: ' },
// { type: 'placeholder', attrs: { type: 'Subscriber', original: '[Subscriber:email]',
// name: 'email', value: null } },
// { type: 'message', text: '\nYour order has shipped.' },
// ] }
// Link directive
const json2 = smsRfmToJson(':link[https://example.com]{track="true" shorten="true"}')
// { type: 'sms', content: [
// { type: 'link', text: 'https://example.com', attrs: { track: true, shorten: true } },
// ] }