Relay SMS Platform
Best Practices

2. Use Consistent Formatting

Consistent formatting improves message clarity and professionalism.

Amount Formatting

TypeScriptCode
// ✅ Good - Consistent decimal places amount: '49.99' amount: '149.00' // Even for whole numbers amount: '1,234.56' // ❌ Avoid - Inconsistent formatting amount: '49.9' amount: '149' amount: '$49.99' // Templates add $ automatically

Date and Time Formatting

TypeScriptCode
// ✅ Good - Short and consistent date: 'Jan 15' // Short month + day date: 'Dec 31' time: '2:00 PM' // 12-hour format with AM/PM time: '10:30 AM' // ❌ Avoid - Inconsistent or too long date: 'January 15th, 2024' date: '01/15/2024' time: '14:00' // 24-hour format may confuse users time: '2 PM' // Missing :00

Phone Number Formatting

TypeScriptCode
// ✅ Good - E.164 format to: '+15551234567' // ❌ Avoid to: '555-123-4567' to: '(555) 123-4567'

Order Number Formatting

TypeScriptCode
// ✅ Good - Short and alphanumeric orderNumber: 'A1B2C3' orderNumber: 'ORD-12345' // ❌ Avoid - Too long orderNumber: 'ORDER-2024-01-15-CUSTOMER-12345'

Helper Function

Create a formatting helper:

TypeScriptCode
export const formatters = { amount: (value: number) => value.toFixed(2), date: (date: Date) => date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }), time: (date: Date) => date.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }) }; // Usage const result = renderTemplate(template, { company: 'Acme', amount: formatters.amount(49.99), date: formatters.date(new Date()), time: formatters.time(new Date()) });

Next Steps:

Last modified on