SMS
Metadata schema for populating SMS templates in SolidX applications.
Where it lives
JSON Pointer: /smsTemplates
JSONPath: $.smsTemplates
Parent: Root of the metadata file
Overview
SMS templates in SolidX let you define and manage text-message templates with dynamic content.
The template body is stored in a separate text file referenced by the body field. The file contains the actual SMS message and can include Handlebars placeholders for dynamic values.
Example: SMS Templates Metadata
This example defines an OTP template used during login. The body field points to a separate text template file.
SMS templates schema example
{
..., // Other metadata
"smsTemplates": [
{
"name": "otp-on-login-custom",
"displayName": "Custom: Otp On Login",
"body": "otp-on-login-custom.handlebars.txt",
"description": "Send sms with OTP when logging in.",
"smsProviderTemplateId": "<TEMPLATE_ID_FROM_SMS_PROVIDER>",
"active": true,
"type": "text"
},
]
}Example: SMS Template File
Below is an example of the content of the otp-on-login-custom.handlebars.txt file referenced by the metadata above.
SMS template file example
Hi {{ firstName }}, Login to {{ solidAppName }}, using {{ mobileVerificationTokenOnLogin }} as your verification code.Example: Sending SMS Using a Template
This snippet shows how an application service sends an OTP verification message to a user using an authored SMS template via SmsServiceFactory.
SMS sending code example
import { SmsServiceFactory } from 'your-sms-service';
async sendOtpSms(user: { mobile: string; firstName?: string; username: string, mobileVerificationTokenOnLogin: string }, otp: string) {
const smsService = SmsServiceFactory.getSmsService();
await smsService.sendSmsUsingTemplate(
user.mobile,
'otp-on-login',
{
solidAppName: process.env.SOLID_APP_NAME,
mobileVerificationTokenOnLogin: user.mobileVerificationTokenOnLogin,
firstName: user.username,
fullName: user.fullName ? user.fullName : user.username,
}
);SMS Templates Metadata Attributes
name (string, required, unique)
Unique name for the sms template. It should be in kebab-case format (e.g., example-template-name).
displayName (string, required)
Display name for the sms template.
body (string, required)
- In metadata JSON,
bodyholds the template filename. - SolidX resolves that file from
module-metadata/<module-name>/sms-templates/. - The file content is plain text and can include Handlebars placeholders such as
{{placeholderName}}.
Further Reference
- SMS Body Creation: SMS Templates Guide
Please refer to the Handlebars Documentation for more information on using Handlebars syntax in SMS templates.
smsProviderTemplateId (string, optional)
Unique identifier for the SMS template from the SMS provider (e.g., Twilio, Nexmo). This ID is used to reference the template when sending SMS messages through the provider's API.
description (string, optional)
A brief description of the SMS template.
active (boolean, optional)
Indicates whether the SMS template is active. Defaults to true.
type (string, optional)
Type of the SMS template. Currently supports text only.

