Component evidence

Twilio Text Formatter (format/index.ts)

vercel/chat · packages/adapter-twilio/src/format/index.ts · typescript · MIT
integrationvoicechatdev-toolslang:typescript

Truncates and validates text messages to fit within Twilio length limits. Reuse when integrating SMS notification and messaging features.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/vercel/chat | License: MIT | Copyright 2026 Vercel, Inc
// Provided via justclaw.it.com; keep this notice with the code.
export const TWILIO_MESSAGE_LIMIT = 1600;

export interface TwilioTextOptions {
  limit?: number;
}

export interface TwilioTextResult {
  text: string;
  truncated: boolean;
}

export function truncateTwilioText(
  text: string,
  options: TwilioTextOptions = {}
): TwilioTextResult {
  const limit = options.limit ?? TWILIO_MESSAGE_LIMIT;
  if (!Number.isInteger(limit) || limit < 1) {
    throw new TypeError("limit must be a positive integer");
  }
  if (text.length <= limit) {
    return { text, truncated: false };
  }
  return { text: text.slice(0, limit), truncated: true };
}

export function twilioTextOrPlaceholder(text: string): string 

... (truncated -- full source via MCP)