Blog

How to Create an Automated SMS Notification System

The Courier TeamThe Courier TeamUpdated
sms notification system header

When you need to send important alerts from your web or mobile app, SMS is a good fit for time-sensitive notifications, like a fraud warning or a payment issue. It also pairs well with other channels, such as email, Slack, or push notifications. That layered approach lets you pick the right channel for each notification and fall back to another one when the first can't be delivered.

SMS APIs like Twilio and Bird let you send a text with a few lines of code, but they don't handle the logic around an automated SMS. That's the job of an SMS notification system like Courier.

You'll need extra logic around your notifications if you want to:

  • Send the same notification to other channels, like a push notification or an in-app inbox.
  • Trigger notifications from a schedule, a product event, or a series of events.
  • Start notifications from events in your customer data platform.
  • Send a sequence of notifications based on conditions.
  • Respect each user's communication preferences (which channels they want, and which notifications).
  • Include data from third-party systems in your notifications.
  • Fail over to another SMS provider if one goes down, or to another channel if the SMS can't be delivered.

Without an SMS notification system, you're building and maintaining all of that logic yourself.

Components of an SMS notification system

Courier adds four things on top of SMS delivery:

  • Multiple channels: Send to email, push, an in-app inbox, Slack, Microsoft Teams, and more through the same API.
  • Provider and channel failover: Courier retries transient provider errors, moves to the next configured provider if one is unavailable (for example, from Twilio to Bird), and moves to the next channel if a channel fails. See routing.
  • User preferences: Your users choose which channels and which notifications they get, and Courier applies those preferences on every send.
  • Multi-step logic: Journeys add delays, branches, throttles, and send windows between messages, and send limits cap how many messages go out.

Send an SMS with an SMS notification system

This example uses Courier, with Twilio as the SMS provider, in a Node.js app. If you work in another language, the send your first message guide covers the other SDKs.

Step 1: Set up Twilio

Twilio offers a free trial with no credit card required, so this example uses Twilio as the SMS provider. Start by signing up for Twilio. Once you're in the Twilio console, follow its prompts to get a phone number, then send yourself a test SMS to check that Twilio works. Trial accounts can only text verified numbers, so verify the phone you'll test with.

Next, find your Account SID, Auth Token, and Twilio phone number in the console's Account Info panel. You'll need them to connect Twilio to Courier.

Screenshot of the Twilio console showing where to find the account SID, auth token, and phone number.

Step 2: Connect Twilio to Courier

Sign up for Courier, open Integrations, and add Twilio. Enter your Account SID, Auth Token, and either a Messaging Service SID or your Twilio phone number, then select Save. The Twilio integration docs cover each field.

Integrations are per environment, so connect Twilio in the same environment as the API key you'll send with.

Step 3: Create your SMS notification template

This example is an e-commerce package delivery notification. Open Templates, select Add template, choose Design Studio v2, and name it "Package delivery." Select the SMS channel tab, then pick Twilio in the routing selector.

Add a Text block with this message. Type {{ to insert each variable:

Text
Your parcel with reference {{data.packageRef}} is estimated for delivery between {{data.startTime}} and {{data.endTime}} today. Not going to be in? {{data.rescheduleUrl}}

Select Publish, then copy the template ID from the top of the editor. The Design Studio docs cover the editor in more detail.

Step 4: Install the Courier Node.js SDK

You need Node.js 20 or later. Create a directory called package-notification and install the Courier Node.js SDK inside it:

Terminal
mkdir package-notification
cd package-notification
npm init -y
npm install @trycourier/courier

Step 5: Send SMS using Node.js

Now you'll write the code that texts your phone through Courier, with Twilio as the SMS provider. It stores a phone number on the recipient's profile, then sends your template to that user.

Inside package-notification, create a file called send-sms.mjs and add this code:

JavaScript
import Courier from "@trycourier/courier";

const courier = new Courier({ apiKey: process.env.COURIER_API_KEY });

await courier.profiles.create("user_123", {
  profile: { phone_number: "<PHONE_NUMBER>" },
});

const { requestId } = await courier.send.message({
  message: {
    to: { user_id: "user_123" },
    template: "<NOTIFICATION_TEMPLATE_ID>",
    data: {
      packageRef: "<PACKAGE_REFERENCE>",
      startTime: "10:00",
      endTime: "11:00",
      rescheduleUrl: "<RESCHEDULE_OR_SAFE_PLACE_URL>",
    },
    routing: {
      method: "single",
      channels: ["sms"],
    },
  },
});

console.log(requestId);
  • Replace <PHONE_NUMBER> with your own phone number in E.164 format (a plus sign, the country code, then the number, like +12025550156), so you can test that the SMS sends.
  • Replace <NOTIFICATION_TEMPLATE_ID> with the template ID you copied.
  • Replace the values in data with your own. They fill the template's {{data.*}} variables.

Then set your Courier API key and run the script:

Terminal
export COURIER_API_KEY="<COURIER_API_KEY>"
node send-sms.mjs

You'll get a text like this:

An example SMS about an expected package delivery.

The same notification can go out on other channels, too. Add an email channel to the template, set routing to { method: "all", channels: ["sms", "email"] }, and the user gets the delivery update as both a text and an email.

Build multi-step SMS logic with Journeys

Journeys move multi-step notification logic out of your code and onto a visual canvas in Courier. A journey runs once per user. It starts from a trigger (API Invoke, Webhook, Twilio Segment, or Audience), then runs its nodes in order: send, delay, branch, throttle, fetch data, and more. You publish it, and your code or your event stream starts the runs.

Some things you can build with it:

  • Scheduled sends: Journeys have no schedule trigger. To text a whole list or audience 10 days before Black Friday, schedule an SMS broadcast. For a date that's different for each user, add a delay node set to Until and read the time from your data. To keep a text inside business hours, set a send window on the send node, or pass delay: { until: "Mo-Fr 09:00-17:00" } to the Send API (delay and schedule a send).
  • Customer data platform events: The Twilio Segment trigger starts a journey from Segment Track, Identify, or Group events, so you don't have to call Courier from your code.
  • Branching: A branch node sends one SMS if a condition matches and a different one if it doesn't. For example, a gym could send a new member different workout suggestions based on their age.
  • Throttling: A throttle node caps how many times a user (or everyone) passes a point in the journey within a time window, so a busy journey doesn't flood someone with texts.

Here, you'll build a journey that sends an order confirmation SMS when an Order Completed event arrives from Twilio Segment, using Courier's Segment integration.

Step 1: Connect Twilio Segment to Courier

In Twilio Segment, add Courier as a destination and paste in your Courier API key. The Segment integration docs cover the connection. Send a test event from the destination's Event Tester and confirm it shows up in Courier.

Each event's userId has to match a Courier user with a phone_number on their profile, the same way you stored one in Step 5.

Step 2: Create the journey

Open Journeys, select New Journey, name it "Order confirmation," and choose the Segment trigger. Select Order Completed as the source event.

The event's properties become the journey's data, so fields like order_id and total are available to every node.

Step 3: Add an SMS send node

Drag a Send node onto the canvas after the trigger and choose SMS. Select + Create to write its template inline:

Text
Your order #{{order_id}} is confirmed. Total: {{total}}. Thanks for shopping with us.

Journey templates read trigger data without a prefix, so it's {{order_id}}, not {{data.order_id}}. The send node delivers to the user who entered the journey, at their profile's phone_number, through the Twilio integration you connected.

To text larger orders something different, add a Branch node before the send. Set Path 1 to data.total greater than 100 and give it a send node with its own template. The Default path keeps the standard confirmation.

Step 4: Publish and test

Publish each send node's template first, then select Publish on the journey. Publishing the journey doesn't publish its templates, and a run only sends a template's published version.

Fire an Order Completed event from your app, or replay one from Twilio Segment. Open the journey's Logs tab and check that a run appeared with the event's properties as its data. Then find the message itself in Logs.

Start the same journey from your code

If your events don't come through Twilio Segment, build the journey with the API Invoke trigger instead and start each run with the invoke API. Copy the journey ID from the editor:

JavaScript
import Courier from "@trycourier/courier";

const courier = new Courier({ apiKey: process.env.COURIER_API_KEY });

const { runId } = await courier.journeys.invoke("<JOURNEY_ID>", {
  user_id: "user_123",
  data: { order_id: "ORD-9042", total: 49.99 },
});

console.log(runId);

Search for the returned runId in the journey's Logs tab to step through the run node by node.

Conclusion

You've sent an SMS through Courier with Twilio, and built a journey that texts an order confirmation whenever a Twilio Segment event arrives.

You can start on Courier's free Developer plan, which includes 10,000 sends a month, and Twilio's free trial. Courier integrates with many SMS providers, so you don't have to decide right away which one to use. When you're ready to send more notifications, sign up or contact us to talk through your use case.

Similar resources

How to Use Claude Code on Mobile to Design, Test, and Ship Multichannel Notifications — cover

How to Use Claude Code on Mobile to Design, Test, and Ship Multichannel Notifications

A walkthrough of using Claude Code's mobile app with Courier's MCP server and CLI to design, test, and ship a multichannel product announcement from a phone. Covers the full workflow: drafting the content outline, creating notification templates using Courier's elemental format, building channel-specific variants for email, Slack, push, and SMS, customizing brand styling through the API, iterating on design with test sends, getting team approval, and publishing with custom routing rules. The whole thing took a couple hours, mostly cold start and design iterations.

By Kyle Seyler

April 06, 2026

Frame 163970

Transactional vs. product vs. marketing notifications

Transactional notifications confirm something the user did or something that happened to their account. Product notifications help users get value from features they already have. Marketing notifications sell. The consent rules differ by channel: marketing email is opt-out under CAN-SPAM, marketing texts need prior express written consent under the FCC's TCPA rules, and every push notification is gated by the operating system's notification permission.

By Kyle Seyler

October 23, 2025

Video Tutorial Toasts SDK

How to Add Toast Notifications with the New Courier Toasts SDK

Learn how to add real-time, customizable toast notifications to your app with the Courier Toasts SDK. This quick tutorial shows how to integrate toasts using Web Components or React and sync them with your notification center for a seamless, modern UX.

By Dana Silver

October 20, 2025