Relay SMS Platform
Installation

Quick Start

Installation

TerminalCode
npm install @relay-works/templates

Basic Usage

TypeScriptCode
import { getTemplate, renderTemplate, type TemplateData } from '@relay-works/templates'; // Get a template with type safety const otpTemplate = getTemplate('otp-verify'); // Type-safe data const data: TemplateData<'otp-verify'> = { code: '482916', company: 'Acme' }; // Render const result = renderTemplate(otpTemplate, data); console.log(result.text); // "482916 is your Acme verification code." console.log(result.segments); // 1

What You Get

Every template render returns:

  • text - The rendered message ready to send
  • characterCount - Total character count
  • segments - Number of SMS segments (affects cost)
  • encoding - Character encoding used (GSM-7 or UCS-2)

Next Steps:

Last modified on