Messaging

Send Long SMS Messages with Node.js and Telnyx

An appointment reminder often needs more than a time and a date. A clinic may need to include the location, check-in instructions, preparation details, accessibility information, and a rescheduling option.

That is useful information, but it may not fit in one SMS segment. Sending each paragraph as an unrelated message creates a different problem: messages can arrive out of order, look disconnected, and be difficult to track as one notification.

This Node.js code example shows the other pattern: send one logical long message through Telnyx, let the messaging platform handle carrier-level chunking, and correlate delivery events back to the original message.

Watch the demo: How SMS Chunking Works with Node.js and Telnyx

The architecture

The Express server has four important pieces:

  1. Enable auto_chunk_long_messages on the Telnyx messaging profile.
  2. Validate and send the long text through POST /sms/send-long.
  3. Accept signed message.sent and message.finalized webhook events.
  4. Store a parent delivery record and associate child segment IDs with it.

The application sends one request. It does not manually divide the text into separate API messages. Telnyx handles the segmentation needed for SMS delivery.

appointment workflow
  -> one logical long SMS
  -> Telnyx Messages API
  -> carrier-sized SMS segments
  -> recipient phone
  -> signed delivery webhooks
  -> parent message with child statuses

Why the webhook matters

An HTTP response only tells the application that the send request was accepted. It does not provide the complete delivery lifecycle.

The webhook verifies the Telnyx signature from the raw request body, reads the event type and message identifiers, and updates the delivery map. A production application would replace that in-memory map with a database and add retention, retry, monitoring, and alerting.

Two demo modes

The long-message mode creates a realistic appointment message longer than 1,530 characters. Run npm run demo to exercise automatic long-message chunking.

The recorded demo uses npm run demo -- --sequence for a different visual: four separate appointment messages, each with one readable paragraph. That mode is useful for demonstrating a notification sequence, but it is not the carrier-chunking path.

Reuse the pattern

The same design works for delivery updates, outage notifications, customer support instructions, billing reminders, and other operational messages where completeness and delivery visibility matter.

Start with the sample API reference, replace the appointment content with your business payload, and persist the delivery record in the system that owns the workflow.

Try the example

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/long-sms-chunking-and-tracking-nodejs
cp .env.example .env
npm install
npm start

Keep credentials in .env, never commit that file, and expose the webhook through a public HTTPS endpoint when testing live delivery callbacks.