Skip to content

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.

  1. Character Limit - SMS has 160 character limit, long URLs consume valuable space
  2. User Experience - Short links are easier to read and tap on mobile devices
  3. Deliverability - Some carriers may flag messages with long URLs as spam
  4. Tracking - Shortened links provide click analytics
  5. Security - Masks internal URL structure
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

import { shortLink } from '@power-rent/lib/shortener';
import sendSMSByPhoneNumber from '../lib/sendSMSByPhoneNumber';
// 1. Create the full URL with authentication and company context
const fullUrl = `${origin}/sign-in?path=/view/reservation/${orderNumber}&companyId=${companyId.slice(0, companyId.length - 8)}`;
// 2. Shorten the link
const shortUrl = await shortLink(fullUrl);
// 3. Build SMS message
const message = `Your order ${orderNumber} is ready. View details: ${shortUrl}`;
// 4. Send SMS
await sendSMSByPhoneNumber({
phone: customerPhone,
message,
companyId
});

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}`;

✅ 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 shortened
const 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 shortened
const 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 shortened
const 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!