Developer Quick-Start: Learn how to build automated SMS appointment reminders with RedwoodJS 8.8.1 and Twilio Message Scheduling. Reduce no-shows with this complete, production-ready tutorial. Want to skip 10DLC vetting queues, carrier surcharges, and multi-step SDK boilerplate? You can send the same SMS directly via SMSRoute's REST API with instant no-KYC provisioning.
Learn how to build an automated SMS appointment reminder system using RedwoodJS and Twilio that reduces no-shows and improves customer engagement. This comprehensive tutorial shows you how to send SMS reminders via Twilio's Programmable Messaging API and Message Scheduling feature—eliminating the need for custom scheduling infrastructure or cron jobs.
By the end of this RedwoodJS SMS tutorial, you'll have a production-ready application that can:
- Create, read, update, and delete appointments with a GraphQL API
- Automatically schedule SMS reminders using Twilio Message Scheduling
- Handle time zones correctly for international appointment scheduling
- Securely manage Twilio API credentials and environment variables
This guide assumes you understand JavaScript, Node.js, React, GraphQL, and database concepts.
Why Use RedwoodJS and Twilio for SMS Appointment Reminders?
Goal: Build a full-stack appointment reminder application where you manage appointments through a modern GraphQL API, and your system automatically schedules and sends SMS reminders at a configurable time before each appointment.
Problem Solved: Automate appointment reminders to reduce no-shows by up to 38% (industry average). Eliminate manual reminder processes and complex self-hosted scheduling infrastructure by leveraging Twilio's native message scheduling—no background workers or cron jobs required.
Technologies:
- RedwoodJS: A full-stack, serverless-first web application framework based on React, GraphQL, and Prisma. Latest version: 8.8.1 (as of October 2025). Chosen for its integrated structure, developer experience, and conventions that accelerate development of Node.js SMS applications.
- Twilio Programmable Messaging: Industry-leading SMS API for sending appointment reminders. We'll use the Message Scheduling feature via the Twilio Node.js helper library (version 5.9.0 as of October 2025). Chosen for its reliability, 99.95% uptime SLA, and developer-friendly API.
- Node.js: The runtime environment for RedwoodJS's API side. Node.js v22 LTS (v22.20.0) recommended (Active LTS from October 29, 2024 until October 2025; Maintenance LTS until April 2027).
- Prisma: The database toolkit used by RedwoodJS for database access and migrations. Latest version: 6.16.3 (as of October 2025), featuring the Rust-free architecture for improved deployment simplicity and performance.
- PostgreSQL (or SQLite/MySQL): The relational database to store appointment data and track SMS delivery status.
System Architecture:
User Browser interacts with Redwood Frontend, which communicates via GraphQL with the Redwood API. The API uses Prisma to talk to the Database and makes calls to the Twilio API.
Prerequisites:
- Node.js v20.17.0 or greater (required for RedwoodJS v8). Node.js v22 LTS (v22.20.0) recommended for long-term support (Active LTS until October 2025; Maintenance LTS until April 2027). Install from nodejs.org.
- Yarn v4.1.1 or greater (required for RedwoodJS v8). Install via npm: npm install -g yarn or see yarnpkg.com.
- A Twilio account (Sign up for free).
- An SMS-capable Twilio phone number purchased from your account.
- A Twilio Messaging Service configured (see Step 4).
- Access to a terminal or command prompt.
- A code editor (e.g., VS Code).
Step 1: Set Up Your RedwoodJS Project with Twilio
Let's start by creating a new RedwoodJS application and installing the Twilio SDK for Node.js.
- Create the RedwoodJS App: Open your terminal and run the following command, replacing
appointment-reminder-appwith your desired project name:
yarn create redwood-app ./appointment-reminder-app
- Navigate into the Project Directory:
cd appointment-reminder-app
- Install Twilio Helper Library: Install the official Twilio Node.js helper library specifically in the API workspace:
yarn workspace api add twilio
- Environment Variables: RedwoodJS uses a
.envfile for environment variables. Create this file in the project root:
touch .env
Add the following variables to your .env file. We will obtain these values in Step 4
(Integrating with Twilio). Do not commit this file to version control if it contains sensitive
credentials. Redwood's .gitignore includes .env by default. .env
# .env
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=your_auth_token_xxxxxxxxxxxxxx
TWILIO_MESSAGING_SERVICE_SID=MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Database URL (Example for PostgreSQL - adjust if using SQLite/MySQL)
# Replace user, password, host, port, dbname with your actual DB credentials
DATABASE_URL="postgresql://user:password@host:port/dbname?schema=public"
- TWILIO\_ACCOUNT\_SID: Your primary Twilio account identifier.
- TWILIO\_AUTH\_TOKEN: Your secret token for authenticating API requests. Treat this like a password.
- TWILIO\_MESSAGING\_SERVICE\_SID: The unique ID for the Twilio Messaging Service you'll configure. Scheduling requires a Messaging Service.
- DATABASE\_URL: The connection string for your database. Redwood defaults to SQLite for quick setup, but PostgreSQL is recommended for production. Update this connection string according to your database provider (e.g., Railway, Supabase, Heroku Postgres, local installation). For SQLite (default), the line would be DATABASE\_URL="file:./dev.db".
Step 2: Create the Appointment Database Schema with Prisma
Define the database structure for storing appointment data, SMS tracking information, and delivery status using Prisma ORM.
Note: Prisma 6.16.x Rust-Free Architecture As of Prisma 6.16.0 (October 2025), the Rust-free version of Prisma ORM is generally available. This architectural change provides: - Lower CPU footprint by eliminating the extra CPU usage from running the query engine as a binary - Less deployment complexity, as the query engine binary no longer needs to be compiled for specific operating systems - Improved performance, especially when working with large datasets The TypeScript-based query engine makes Prisma more accessible and easier to deploy across different environments.
- Define the Prisma Schema: Open
api/db/schema.prismaand replace its contents with the followingAppointmentmodel:
Prisma
// api/db/schema.prisma
datasource db {
provider = "postgresql" // Or "sqlite", "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}
model Appointment {
id Int @id @default(autoincrement())
name String
phoneNumber String // Store in E.164 format (e.g., +15551234567)
appointmentTime DateTime // Store in UTC
timeZone String // Store the user's IANA time zone (e.g., 'America/New_York')
reminderSent Boolean @default(false) // Flag if reminder is successfully scheduled
scheduledMessageSid String? // Store Twilio's SID for cancellation/updates
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([appointmentTime]) // Add index for sorting/filtering by time
}
- appointmentTime: We store the appointment time in UTC. This is crucial for consistent scheduling across time zones.
- timeZone: Storing the original time zone allows us to format the time correctly for the user and potentially adjust reminder messages.
- scheduledMessageSid: This optional field will hold the unique identifier (Sid) of the scheduled message returned by Twilio. This is essential if you need to cancel or modify the reminder later.
- @@index([appointmentTime]): Added an index to potentially improve query performance when sorting or filtering by appointment time.
- Apply Migrations: Run the following command to create and apply the database migration.
When prompted, give your migration a descriptive name (e.g.,
create_appointment_model).
yarn rw prisma migrate dev
This command does three things:
- Creates a new SQL migration file reflecting the schema changes.
- Applies the migration to your development database.
- Generates/updates the Prisma Client based on your schema.
Step 3: Build the GraphQL API for SMS Appointment Management
RedwoodJS uses GraphQL for its API layer, providing type-safe queries and mutations. We'll generate the necessary SDL (Schema Definition Language) and service files to handle CRUD operations for appointments and integrate with the Twilio SMS API.
- Generate SDL and Service: Use Redwood's generator to scaffold the GraphQL types, queries,
mutations, and the service file for the
Appointmentmodel:
yarn rw g sdl Appointment
This creates:
- api/src/graphql/appointments.sdl.ts: Defines the GraphQL schema (types, queries, mutations).
- api/src/services/appointments/appointments.ts: Contains the business logic (resolvers) for the SDL definitions.
- api/src/services/appointments/appointments.scenarios.ts: For defining seed data for testing.
- api/src/services/appointments/appointments.test.ts: For writing unit tests.
- Refine the GraphQL Schema: Open
api/src/graphql/appointments.sdl.ts. Redwood generates basic CRUD operations. We need to adjust the input types slightly, particularly forappointmentTime.
import gql from 'graphql-tag'
export const schema = gql`
type Appointment {
id: Int!
name: String!
phoneNumber: String!
appointmentTime: DateTime!
timeZone: String!
reminderSent: Boolean!
scheduledMessageSid: String
createdAt: DateTime!
updatedAt: DateTime!
}
type Query {
appointments: [Appointment!]! @requireAuth
appointment(id: Int!): Appointment @requireAuth
}
input CreateAppointmentInput {
name: String!
phoneNumber: String!
appointmentTime: DateTime!
timeZone: String!
}
input UpdateAppointmentInput {
name: String
phoneNumber: String
appointmentTime: DateTime
timeZone: String
}
type Mutation {
createAppointment(input: CreateAppointmentInput!): Appointment! @requireAuth
updateAppointment(id: Int!, input: UpdateAppointmentInput!): Appointment! @requireAuth
deleteAppointment(id: Int!): Appointment! @requireAuth
}
`
- We explicitly expect appointmentTime as a DateTime (which Apollo Server handles as an ISO 8601 string) and assume it's provided in UTC from the client.
- @requireAuth is added for basic authorization (we'll touch on setup later). Remove it if you don't need authentication initially.
- Implement Service Logic (Including Twilio Integration): This is where the core logic
resides. Open
api/src/services/appointments/appointments.tsand implement the resolvers, including the Twilio scheduling logic within thecreateAppointmentandupdateAppointmentmutations.
import { Twilio } from 'twilio'
import { db } from 'src/lib/db'
import { logger } from 'src/lib/logger'
import type {
QueryResolvers,
MutationResolvers,
AppointmentResolvers,
Appointment as TAppointment,
CreateAppointmentInput,
UpdateAppointmentInput,
} from 'types/graphql'
let twilioClient: Twilio | null = null;
try {
if (process.env.TWILIO_ACCOUNT_SID && process.env.TWILIO_AUTH_TOKEN) {
twilioClient = new Twilio(
process.env.TWILIO_ACCOUNT_SID,
process.env.TWILIO_AUTH_TOKEN
);
} else {
logger.warn('Twilio credentials not found in environment variables. SMS scheduling will be disabled.');
}
} catch (error) {
logger.error({ error }, 'Failed to initialize Twilio client.');
twilioClient = null;
}
const scheduleReminder = async (appointment: {
id: number // Can be 0 for new appointments before saving
name: string
phoneNumber: string
appointmentTime: Date
timeZone: string // For reminder message content, not scheduling time
scheduledMessageSid?: string | null // Existing SID for updates/cancellations
}) => {
if (!twilioClient || !process.env.TWILIO_MESSAGING_SERVICE_SID) {
logger.warn(`Twilio client not initialized or Messaging Service SID missing. Skipping reminder scheduling for appointment ${appointment.id}.`);
return null;
}
const reminderOffsetMinutes = 60
const sendAt = new Date(
appointment.appointmentTime.getTime() - reminderOffsetMinutes * 60 * 1000
)
const now = new Date()
const fifteenMinutesFromNow = new Date(now.getTime() + 15 * 60 * 1000)
const thirtyFiveDaysFromNow = new Date(now.getTime() + 35 * 24 * 60 * 60 * 1000)
if (sendAt <= fifteenMinutesFromNow) {
logger.warn(
`Appointment ${appointment.id} at ${appointment.appointmentTime.toISOString()} is too soon to schedule a reminder (calculated sendAt: ${sendAt.toISOString()}). Minimum scheduling window is 15 minutes. Skipping.`
)
return null
}
if (sendAt > thirtyFiveDaysFromNow) {
logger.warn(
`Appointment ${appointment.id} at ${appointment.appointmentTime.toISOString()} is too far in the future to schedule (calculated sendAt: ${sendAt.toISOString()}). Maximum scheduling window is 35 days. Skipping.`
)
return null
}
if (appointment.scheduledMessageSid) {
try {
logger.info(`Cancelling existing reminder ${appointment.scheduledMessageSid} for appointment ${appointment.id}`)
if (twilioClient) {
await twilioClient.messages(appointment.scheduledMessageSid).update({ status: 'canceled' });
logger.info(`Successfully cancelled reminder ${appointment.scheduledMessageSid}`);
} else {
logger.warn(`Twilio client not available, cannot cancel reminder ${appointment.scheduledMessageSid}`);
}
} catch (error) {
logger.error({ error, appointmentId: appointment.id, sid: appointment.scheduledMessageSid }, `Failed to cancel previous reminder. It might have already been sent or canceled.`);
}
}
let localizedAppointmentTime = 'at the scheduled time';
try {
localizedAppointmentTime = new Intl.DateTimeFormat('en-US', {
dateStyle: 'medium',
timeStyle: 'short',
timeZone: appointment.timeZone,
}).format(appointment.appointmentTime);
} catch (e) {
logger.error({ error: e, timeZone: appointment.timeZone }, 'Failed to format date with provided timezone for SMS body');
}
const messageBody = `Hi ${appointment.name}. Reminder: Your appointment is scheduled for ${localizedAppointmentTime} (${appointment.timeZone}).`
try {
logger.info(
`Scheduling reminder for appointment ${appointment.id} to ${appointment.phoneNumber} at ${sendAt.toISOString()}`
)
if (!twilioClient || !process.env.TWILIO_MESSAGING_SERVICE_SID) {
throw new Error('Twilio client or Messaging Service SID not available.');
}
const message = await twilioClient.messages.create({
messagingServiceSid: process.env.TWILIO_MESSAGING_SERVICE_SID,
to: appointment.phoneNumber,
body: messageBody,
scheduleType: 'fixed',
sendAt: sendAt.toISOString(),
})
logger.info(
`Successfully scheduled message SID: ${message.sid} for appointment ${appointment.id}`
)
return message.sid
} catch (error) {
logger.error(
{ error, appointmentId: appointment.id },
'Failed to schedule Twilio message'
)
throw new Error(`Failed to schedule SMS reminder: ${error.message || 'Unknown Twilio error'}`)
}
}
const validateAppointmentInput = (input: CreateAppointmentInput | UpdateAppointmentInput, isUpdate = false) => {
if (input.phoneNumber && !/^\+[1-9]\d{1,14}$/.test(input.phoneNumber)) {
throw new Error('Invalid phone number format. Use E.164 (e.g., +15551234567)');
}
if (!isUpdate && !input.phoneNumber) {
throw new Error('Phone number is required.');
}
if (input.timeZone) {
try {
Intl.DateTimeFormat(undefined, { timeZone: input.timeZone });
} catch (e) {
logger.error({ error: e, timeZone: input.timeZone }, 'Invalid time zone format detected');
throw new Error(`Invalid or unrecognized time zone: ${input.timeZone}. Use IANA format (e.g., America/New_York)`);
}
}
if (!isUpdate && !input.timeZone) {
throw new Error('Time zone is required.');
}
if (input.appointmentTime) {
const time = new Date(input.appointmentTime);
if (isNaN(time.getTime())) {
throw new Error('Invalid appointment time format. Please use ISO 8601 format.');
}
}
if (!isUpdate && !input.appointmentTime) {
throw new Error('Appointment time is required.');
}
if (input.name !== undefined && input.name.trim() === '') {
throw new Error('Name cannot be empty.');
}
if (!isUpdate && !input.name) {
throw new Error('Name is required.');
}
};
export const appointments: QueryResolvers['appointments'] = () => {
return db.appointment.findMany({ orderBy: { appointmentTime: 'asc' } })
}
export const appointment: QueryResolvers['appointment'] = ({ id }) => {
return db.appointment.findUnique({
where: { id },
})
}
export const createAppointment: MutationResolvers['createAppointment'] = async ({
input,
}) => {
validateAppointmentInput(input);
const appointmentTimeUTC = new Date(input.appointmentTime);
let scheduledMessageSid: string | null = null;
try {
scheduledMessageSid = await scheduleReminder({
id: 0,
name: input.name,
phoneNumber: input.phoneNumber,
appointmentTime: appointmentTimeUTC,
timeZone: input.timeZone,
scheduledMessageSid: null
})
} catch (error) {
logger.error({ error, input }, 'Failed scheduling reminder during createAppointment, aborting creation.');
throw error;
}
const reminderSentStatus = !!scheduledMessageSid;
logger.info(`Creating appointment record for ${input.name} with reminderSent=${reminderSentStatus}`);
const createdAppointment = await db.appointment.create({
data: {
...input,
appointmentTime: appointmentTimeUTC,
reminderSent: reminderSentStatus,
scheduledMessageSid: scheduledMessageSid,
},
})
return createdAppointment
}
export const updateAppointment: MutationResolvers['updateAppointment'] = async ({
id,
input,
}) => {
validateAppointmentInput(input, true);
const existingAppointment = await db.appointment.findUnique({ where: { id } });
if (!existingAppointment) {
throw new Error(`Appointment with ID ${id} not found.`);
}
const updatedData: Partial<TAppointment> = {};
if (input.name) updatedData.name = input.name;
if (input.phoneNumber) updatedData.phoneNumber = input.phoneNumber;
if (input.timeZone) updatedData.timeZone = input.timeZone;
let appointmentTimeUTC = existingAppointment.appointmentTime;
if (input.appointmentTime) {
appointmentTimeUTC = new Date(input.appointmentTime);
updatedData.appointmentTime = appointmentTimeUTC;
}
const detailsForScheduling = {
id: existingAppointment.id,
name: input.name ?? existingAppointment.name,
phoneNumber: input.phoneNumber ?? existingAppointment.phoneNumber,
appointmentTime: appointmentTimeUTC,
timeZone: input.timeZone ?? existingAppointment.timeZone,
scheduledMessageSid: existingAppointment.scheduledMessageSid
};
let newScheduledMessageSid: string | null = null;
let reminderSentStatus = existingAppointment.reminderSent;
const needsReschedule = input.appointmentTime || input.phoneNumber || input.name || input.timeZone || !existingAppointment.reminderSent;
if (needsReschedule) {
logger.info(`Rescheduling reminder for updated appointment ${id}`);
try {
newScheduledMessageSid = await scheduleReminder(detailsForScheduling);
reminderSentStatus = !!newScheduledMessageSid;
} catch (error) {
logger.error({ error, input, id }, 'Failed rescheduling reminder during updateAppointment, aborting update.');
throw error;
}
updatedData.scheduledMessageSid = newScheduledMessageSid;
updatedData.reminderSent = reminderSentStatus;
} else {
logger.info(`No relevant changes detected for appointment ${id}, skipping reschedule.`);
updatedData.scheduledMessageSid = existingAppointment.scheduledMessageSid;
updatedData.reminderSent = existingAppointment.reminderSent;
}
logger.info(`Updating appointment record ${id} with reminderSent=${updatedData.reminderSent}`);
const updatedAppointment = await db.appointment.update({
where: { id },
data: updatedData,
})
return updatedAppointment;
}
export const deleteAppointment: MutationResolvers['deleteAppointment'] = async ({
id,
}) => {
logger.info(`Attempting to delete appointment ${id}`);
const appointmentToDelete = await db.appointment.findUnique({ where: { id } });
if (!appointmentToDelete) {
logger.warn(`Appointment ${id} not found for deletion.`);
throw new Error(`Appointment with ID ${id} not found.`);
}
if (appointmentToDelete.scheduledMessageSid) {
try {
logger.info(`Cancelling reminder ${appointmentToDelete.scheduledMessageSid} before deleting appointment ${id}`);
if (twilioClient) {
await twilioClient.messages(appointmentToDelete.scheduledMessageSid).update({ status: 'canceled' });
logger.info(`Successfully cancelled reminder for appointment ${id}`);
} else {
logger.warn(`Twilio client not available, cannot cancel reminder ${appointmentToDelete.scheduledMessageSid} during deletion.`);
}
} catch (error) {
logger.error({ error, appointmentId: id, sid: appointmentToDelete.scheduledMessageSid }, `Failed to cancel reminder during deletion. It might have already been sent or canceled.`);
}
}
const deletedAppointment = await db.appointment.delete({
where: { id },
})
logger.info(`Successfully deleted appointment ${id}`);
return deletedAppointment
}
export const Appointment: AppointmentResolvers = {
}
- Twilio Client: Initialized once with error handling and check for credentials.
scheduleReminderHelper: Encapsulates the logic for calculating sendAt, checking Twilio's constraints (15 min - 7 days), canceling previous messages (if scheduledMessageSid exists and client is available), formatting the message body with the correct time zone (with fallback), and calling the Twilio API. Now checks for client availability.- UTC Handling: All scheduling logic uses the appointmentTime (assumed UTC) directly. The timeZone is used only for formatting the message content for the user.
- E.164 Format: Emphasizes storing and sending phone numbers in E.164 format (+15551234567) for international compatibility. Validation moved to a helper.
- Error Handling: Uses try...catch around Twilio calls and logs errors using Redwood's logger. Crucially, it handles potential failures during scheduling and cancellation. Added checks for Twilio client initialization.
- Validation: Centralized input validation in validateAppointmentInput helper for consistency in create and update. Added timezone validation robustness with try/catch.
- Cancellation: Implements cancellation logic in updateAppointment and deleteAppointment using the stored scheduledMessageSid. It logs errors if cancellation fails but generally proceeds with the primary operation (update/delete). Now checks for client availability before attempting cancellation.
- Update Logic: Refined update logic to reschedule only when necessary and handle status updates correctly.
Step 4: Configure Twilio SMS and Message Scheduling
Now, let's obtain your Twilio API credentials and configure a Messaging Service for SMS appointment reminders. Message Scheduling requires a Messaging Service—you cannot schedule messages using only a phone number.
- Get Twilio Account SID and Auth Token:
- Log in to the Twilio Console.
- On the main dashboard ("Account Info"), you'll find your Account SID and Auth Token.
- Copy these values and paste them into the corresponding TWILIO\_ACCOUNT\_SID and TWILIO\_AUTH\_TOKEN variables in your .env file.
- Purchase a Twilio Phone Number:
- Navigate to Phone Numbers > Manage > Buy a number.
- Select your country and ensure the SMS capability is checked.
- Search for available numbers and buy one that suits your needs. Note the number you purchased.
- Create and Configure a Twilio Messaging Service:
- Navigate to Messaging > Services in the Twilio Console.
- Click Create Messaging Service.
- Enter a Messaging Service friendly name (e.g., "Redwood Reminders").
- For Select what you want to use Messaging for, choose "Notify my users" or a relevant option. Click Create Messaging Service.
- Step 2: Add Senders: Click Add Senders.
- Select Sender Type: Phone Number. Click Continue.
- Select the Twilio phone number you purchased earlier. Click Add Phone Numbers.
- Step 3: Set up integration: You can usually leave these as defaults unless you have specific needs (like custom webhook URLs, which we don't need for scheduling). Click Step 4: Add compliance info.
- Step 4: Add compliance info (Optional but Recommended): Add any required compliance information if applicable. Click Complete Messaging Service Setup.
- Copy the Messaging Service SID: On the Messaging Service's dashboard page, find the Service SID (it starts with MG). Copy this value.
- Paste the SID into the TWILIO\_MESSAGING\_SERVICE\_SID variable in your .env file.
Why a Messaging Service? Twilio's Message Scheduling feature requires sending via a Messaging Service. It provides features like sender ID pools, scalability, content intelligence, and advanced opt-out handling, making it superior to sending from a single number directly for applications.
Important: Twilio Message Scheduling Requirements and Limitations (as of 2025) Required: - Messaging Service SID is mandatory for scheduling. Passing only a From phone number will cause scheduling parameters to be dropped and the message to send immediately. Scheduling Constraints: - Minimum advance time: 15 minutes (messages must be scheduled at least 15 minutes in the future) - Maximum advance time: 35 days (messages cannot be scheduled more than 35 days in advance) Capacity Limits: - Account limit: 1,000,000 scheduled messages at any given time (including subaccounts) - Subaccount limits are separate from parent account allocation Pricing: - Message scheduling is free; you only pay for messages sent Source: Twilio Message Scheduling FAQs and Limitations
- Restart Redwood Dev Server: If your development server is running, stop it
(
Ctrl+C) and restart it to load the new environment variables:
yarn rw dev
Step 5: Build the Frontend Interface for Appointment Reminders
Now, let's create the user interface for managing appointments using Redwood's generators and React components.
- Generate Pages and Cells: We need pages to list appointments and a form to create/edit them. Redwood Cells handle data fetching gracefully.
yarn rw g page Appointments /appointments
yarn rw g cell Appointments
yarn rw g component AppointmentForm
yarn rw g page NewAppointment /appointments/new
yarn rw g page EditAppointment /appointments/{id:Int}/edit
yarn rw g cell EditAppointment
- Implement
AppointmentsCell: Openweb/src/components/AppointmentsCell/AppointmentsCell.tsx. This component fetches and displays the list of appointments.
(Implementation details for React components like AppointmentsCell,
AppointmentForm, AppointmentsPage, NewAppointmentPage,
EditAppointmentPage, and EditAppointmentCell would follow here, including form
handling, date/time input (handling time zones and converting to UTC for the API), displaying appointments,
and linking between pages. This typically involves standard React/GraphQL client patterns using Redwood's
helpers like <Form>, <Submit>, <FieldError>,
useMutation, etc. A full implementation is beyond the scope of this Markdown rewrite task but
would be the next logical step in the tutorial.)
Start by creating a new RedwoodJS application using the command
yarn create redwood-app ./your-project-name. Then navigate to the project directory. Install the
necessary Twilio helper library in the API workspace with yarn workspace api add twilio.
Twilio's Programmable Messaging API is used to send SMS reminders. Its Message Scheduling feature enables reliable delivery without building a custom scheduling system. This simplifies development and ensures robust functionality.
Scheduling is handled by the Twilio Node.js helper library and RedwoodJS services. The
scheduleReminder function calculates the appropriate sendAt time, considering the
appointment time and a predefined offset. It uses the user's time zone for display but schedules based on UTC
for consistency.
Store appointment times in UTC in your database. The user's time zone is stored separately and is used only for displaying the appointment time in the user's local time and formatting the reminder message. Twilio scheduling always uses UTC.
You need Node.js v18 or later, Yarn, a Twilio account, a Twilio phone number with SMS capability, and a configured Twilio Messaging Service. Familiarity with JavaScript, Node.js, React, GraphQL, and database concepts is helpful.
Twilio's Message Scheduling requires a Messaging Service. It offers benefits like sender ID pools, scalability, and advanced opt-out handling, making it more suitable than sending messages from a single number directly.
While RedwoodJS defaults to SQLite for simplicity, PostgreSQL is recommended for production environments due
to its robustness and scalability. You can configure the database connection string in the .env
file.
Your Twilio Account SID, Auth Token, and Messaging Service SID should be stored as environment variables in a
.env file in your project's root directory. RedwoodJS automatically loads these variables, making
them available to your services.
The scheduledMessageSid field in the database stores the unique identifier of the scheduled
message returned by Twilio. This allows you to cancel or modify the scheduled reminder later if needed.
The provided code includes functionality to cancel existing reminders using the stored
scheduledMessageSid. This cancellation logic is implemented within the
updateAppointment and deleteAppointment mutations.
Use the E.164 format (e.g., +15551234567) for phone numbers. This ensures international compatibility. The provided code includes validation to enforce this format.
RedwoodJS uses GraphQL for its API. The appointments.sdl.ts file defines the schema for
appointment data, and appointments.ts contains resolver functions for interacting with the
database and Twilio.
RedwoodJS uses Prisma as its database toolkit. You define the data model in the schema.prisma
file and manage migrations using the Redwood CLI.
You can find your Account SID and Auth Token on the main dashboard ("Account Info") of the Twilio Console after logging in.
The example code schedules the reminder 60 minutes before the appointment. The scheduleReminder
function handles scheduling logic, ensuring the reminder is scheduled within Twilio's constraints (15 minutes
to 7 days in the future).
Yes, the SMS reminder content can be customized. The scheduleReminder function demonstrates
formatting the message body and incorporating details like the recipient's name and the appointment time and
timezone.
Simpler Alternative: Send the Same SMS With SMSRoute (No-KYC, Direct Routes)
If you want to replace legacy aggregator SDK boilerplate, multi-week compliance queues, and opaque carrier surcharges with a single HTTP request, SMSRoute delivers global SMS over direct Tier-1 carrier interconnects with instant API access and transparent per-country pricing.
curl -X POST https://api.sendsmsnokyc.com/messages \
-H "x-api-key: $SMSROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": ["+14155551234"],
"channel": ["sms"],
"body": "Your verification code is 482910"
}'
- Instant onboarding: No KYC paperwork or sales queues — grab an API key and fund with crypto (BTC/USDT) or card.
- Direct Tier-1 routes: Verify real handset delivery, DLR latency, and Sender ID preservation before launch via SMSRoute Live Carrier Testing.
- Transparent global pricing: Compare exact per-country termination rates on our live pricing page.
Ship Global SMS in One API Call
Skip legacy SDK sprawl and carrier bottlenecks. Send OTPs, alerts, and bulk campaigns across 190+ countries with SMSRoute.
Explore SMSRoute Developers →