SMS Links Shortening Guide
Overview
All SMS messages containing links to private application routes must use the shortLink function to create shortened URLs. This ensures better deliverability, user experience, and proper company redirection.
Why Shorten SMS Links?
- Character Limit - SMS has 160 character limit, long URLs consume valuable space
- User Experience - Short links are easier to read and tap on mobile devices
- Deliverability - Some carriers may flag messages with long URLs as spam
- Tracking - Shortened links provide click analytics
- Security - Masks internal URL structure
Link Format for SMS
Standard Private Route Link
const smsLink = await shortLink(`${origin}/sign-in?path=/view/reservation/${orderNumber}&companyId=${companyId.slice(0, companyId.length - 8)}`);SMS Message Example
const message = `New reservation of ${vehicleName}. Created by: ${customerName}. View order: ${smsLink}`;Implementation Pattern
Basic SMS with Link
import { shortLink } from '@power-rent/lib/shortener';import sendSMSByPhoneNumber from '../lib/sendSMSByPhoneNumber';
// 1. Create the full URL with authentication and company contextconst fullUrl = `${origin}/sign-in?path=/view/reservation/${orderNumber}&companyId=${companyId.slice(0, companyId.length - 8)}`;
// 2. Shorten the linkconst shortUrl = await shortLink(fullUrl);
// 3. Build SMS messageconst message = `Your order ${orderNumber} is ready. View details: ${shortUrl}`;
// 4. Send SMSawait sendSMSByPhoneNumber({ phone: customerPhone, message, companyId});SMS Link Examples
Order Status Notifications
const orderLink = await shortLink(`${origin}/sign-in?path=/view/reservation/${orderNumber}&companyId=${companyId.slice(0, companyId.length - 8)}`);const message = `Order ${orderNumber} status changed to ${newStatus}. View: ${orderLink}`;Vehicle Reminders
const vehicleLink = await shortLink(`${origin}/sign-in?path=/view/vehicle/${vehicleId}&companyId=${companyId.slice(0, companyId.length - 8)}`);const message = `Vehicle ${vehicleName} requires attention. Check details: ${vehicleLink}`;Driver Notifications
const driverLink = await shortLink(`${origin}/sign-in?path=/view/reservation/${orderNumber}&companyId=${companyId.slice(0, companyId.length - 8)}`);const message = `New delivery assignment for ${vehicleName}. Details: ${driverLink}`;Signature Requests
const signatureLink = await shortLink(`${APP_DOMAIN}/signature-request/${requestId}`);const message = `Please sign ${documentName}. Link: ${signatureLink}`;Best Practices for SMS Links
✅ DO
- Always use
shortLink()for any URL in SMS - Include clear call-to-action text before the link
- Keep message under 160 characters when possible
- Test links on mobile devices
- Use descriptive text that explains what the link does
❌ DON’T
- Send raw, long URLs in SMS
- Forget to await the shortLink function
- Include multiple links in one SMS
- Use generic text like “click here”
- Send links without context
1. Signature Request SMS (sendInvitationByPhone.resolver.js)
// Current (WRONG)const link = `${APP_DOMAIN}/signature-request/${requestId}`;const smsMessage = replaceVariables(getMessage(messages.sendInvitationSmsMessage.id));await sendSMSByPhoneNumber({ phone: customerPhone, message: smsMessage, companyId });
// Should be (CORRECT)const link = await shortLink(`${APP_DOMAIN}/signature-request/${requestId}`);const smsMessage = replaceVariables(getMessage(messages.sendInvitationSmsMessage.id));await sendSMSByPhoneNumber({ phone: customerPhone, message: smsMessage, companyId });✅ Correctly Implemented Examples
1. Change Status SMS (changeStatusSMSNotifications.js)
// Correctly shortenedconst openOrderLink = await shortLink(`${origin}/sign-in?path=/view/reservation/${order.number}&companyId=${companyId.slice(0, companyId.length - 8)}`);2. Create Order SMS (createOrderSMSNotifications.js)
// Correctly shortenedconst openOrderLink = await shortLink(`${origin}/sign-in?path=/view/reservation/${result.number}&companyId=${companyId.slice(0, companyId.length - 8)}`);3. Driver Login SMS (sendDriverLoginLink.js)
// Correctly shortenedconst shortAppLink = await shortLink(`${appDomain}/sign-in?path=/view/reservation/${order.number}&companyId=${companyId.slice(0, companyId.length - 8)}`);Character Count Examples
Before Shortening
https://cloud.toprent.app/sign-in?path=/view/reservation/ORD-123456&companyId=comp_abc123def456(95 characters)After Shortening
https://short.toprent.app/xyz789(32 characters)Saved: 63 characters - Significant space savings for SMS!