AWS Builder Center
How to Build Appointment Reminders with Amazon EventBridge Scheduler and AWS Lambda

How to Build Appointment Reminders with Amazon EventBridge Scheduler and AWS Lambda

Build appointment reminders with Amazon EventBridge Scheduler and AWS Lambda. Handle rescheduling, cancellations, time zones, retries, and duplicate delivery risks.

Love to Learn Tech especially AI things.
A clinic appointment reminder needs to follow the current booking. If the patient changes the appointment, an old reminder must be recognized as stale. If delivery is retried, the system needs to avoid casually sending the same message again.
Amazon EventBridge Scheduler can initiate a reminder at the planned time, and AWS Lambda can read the latest appointment before handing a message to the notification provider. The appointment database remains the authority for whether a reminder should be sent.
This article develops a reference design for a reminder sent 24 hours before an appointment. It includes a Python schedule-creation example and the application rules needed around it. Database transactions, provider integration, and infrastructure permissions are implementation prerequisites.

Define the reminder policy first

Assume a clinic wants one reminder per appointment version. The message asks the patient to open the portal and review the booking. The application supports cancellation, rescheduling, notification preferences, and delivery status tracking.
Write down what happens when someone books less than 24 hours ahead. For this example, the application creates a separate immediate notification job if the appointment is still in the future and consent permits it. It skips expired appointments. Quiet hours and local notification rules need their own policy.
Event
Application action
Appointment confirmed
Commit booking and reminder intent
Schedule created
Record the schedule identifier
Appointment moved
Increment appointment version and create replacement intent
Appointment cancelled
Commit cancelled status and invalidate reminder eligibility
Old reminder arrives
Compare its version with the current booking and skip it
Delivery outcome uncertain
Record uncertainty and reconcile with the provider
Use opaque appointment identifiers in event payloads. Fetch contact details and consent from the authorized application store when processing. That keeps a copied schedule payload from becoming a second patient contact database.

Store the booking and reminder intent together

A useful appointment record includes an appointment ID, clinic ID, start time in UTC, clinic time zone, status, version, notification preference reference, and update timestamp.
When a booking changes, commit its new state and a reminder-intent record in one database transaction. An outbox worker creates the corresponding AWS schedule and records its result. If a worker stops after the database commit, the intent remains available for retry.
Use a deterministic name based on the opaque appointment ID, version, and reminder type. On a retry after an uncertain schedule-creation response, retrieve and compare an existing schedule before accepting a name conflict as success. The outbox entry should be marked complete only when the expected schedule is confirmed.
This closes a common gap. Writing a booking and then making a separate schedule call can leave a confirmed appointment without a reminder if that call fails and there is no durable retry record.

Create a one-time schedule

The following example uses UTC instants and a one-time  at  expression. It targets a reminder Lambda function and configures a Scheduler delivery DLQ. Environment variables identify resources created during deployment.
import json
import os
from datetime import datetime, timedelta, timezone

import boto3

scheduler = boto3.client("scheduler")

def create_reminder_schedule(appointment):
starts_at = datetime.fromisoformat(appointment["starts_at_utc"])
if starts_at.tzinfo is None:
raise ValueError("Appointment time must include a UTC offset")

starts_at = starts_at.astimezone(timezone.utc)
remind_at = starts_at - timedelta(hours=24)
if remind_at <= datetime.now(timezone.utc):
raise ValueError("Route this booking through the short-notice policy")

schedule_name = (
f"appt-{appointment['id']}-v{appointment['version']}-24h"
)
payload = {
"appointment_id": appointment["id"],
"appointment_version": appointment["version"],
"reminder_type": "24h",
}

return scheduler.create_schedule(
Name=schedule_name,
GroupName=os.environ["SCHEDULE_GROUP"],
ScheduleExpression=f"at({remind_at:%Y-%m-%dT%H:%M:%S})",
ScheduleExpressionTimezone="UTC",
FlexibleTimeWindow={"Mode": "OFF"},
ActionAfterCompletion="DELETE",
Target={
"Arn": os.environ["REMINDER_FUNCTION_ARN"],
"RoleArn": os.environ["SCHEDULER_ROLE_ARN"],
"Input": json.dumps(payload),
"RetryPolicy": {
"MaximumEventAgeInSeconds": 3600,
"MaximumRetryAttempts": 3,
},
"DeadLetterConfig": {
"Arn": os.environ["SCHEDULER_DLQ_ARN"],
},
},
)
Keep generated schedule names within AWS limits and use a restricted identifier alphabet. The scheduler execution role must trust EventBridge Scheduler and permit invocation of the selected function plus required delivery to the DLQ. The schedule-creation worker needs schedule permissions and narrowly scoped permission to pass the execution role.
The example configures a one-hour delivery retry window as a product choice. The handler must still reject events that have become too late to be useful.  ActionAfterCompletion  removes completed schedules. Retain delivery history in the application's own records.

Check current state when the reminder arrives

A schedule created yesterday knows yesterday's appointment version. The Lambda handler must load today's state before sending.
Use a strongly consistent read or the database's appropriate transactional mechanism. Validate confirmed status, matching version, future appointment time, notification preference, channel eligibility, and whether the reminder is still inside its permitted delivery window.
The application processing sequence is:
Load the current appointment.
Reject cancelled, expired, or superseded versions.
Check consent, channel eligibility, and reminder deadline.
Conditionally claim this appointment-version reminder.
Ask the provider to send using a stable idempotency key, if supported.
Record provider acceptance or an uncertain outcome.
Reconcile final delivery status from provider events.
This sequence is application pseudocode. The claim and appointment eligibility check need transaction or conditional-write semantics so concurrent workers cannot both acquire the same reminder. A claim should have a recoverable lease or explicit recovery process if its worker stops.
Use a key such as  appointment-id:version:24h . A provider with idempotency support can reduce duplicate sends when the API response is lost after acceptance. Without that support, a crash between provider acceptance and the application's status update creates an uncertain outcome. Reconcile provider records before retrying when possible. Do not label a database claim alone as an exactly-once delivery guarantee.
A booking can also change after the last eligibility check and before the external send. Define the dispatch cutoff with the clinic and record the version used. Keep notification content general and direct patients to the portal for the current booking details.

Handle cancellation and rescheduling

On rescheduling, commit the new start time, increment the appointment version, and write a replacement reminder intent in the same transaction. Attempt to remove the obsolete schedule as cleanup. An already queued old event can still arrive, so version validation remains necessary.
On cancellation, commit the cancelled status first and arrange schedule cleanup through durable work. A delayed cleanup job must not make a cancelled booking eligible again.
For a patient-facing message, use wording such as “Please open your patient portal to review your upcoming appointment.” Avoid putting diagnosis, procedure details, or sensitive notes into notification previews. A separate cancellation or reschedule confirmation should follow its own consent and template rules.

Separate delivery failures from function failures

EventBridge Scheduler has retry and DLQ settings for failures delivering an event to its target. With an asynchronous Lambda target, acceptance by Lambda and successful execution of the function are separate stages.
Configure Lambda asynchronous retry behavior and an on-failure destination for function errors. Then monitor the notification provider's acceptance and delivery statuses. Provider acceptance does not establish that a patient received or read the message.
Failure
Where to look
Scheduler lacks permission to invoke Lambda
Scheduler delivery metrics and DLQ
Lambda fails while reading the database
Lambda errors and asynchronous failure destination
Provider temporarily rejects a request
Application delivery state and provider retry policy
Provider accepts but response is lost
Idempotency key and reconciliation records
Phone number or email is invalid
Provider status events and staff follow-up workflow
Coordinate retry deadlines across these layers. A six-hour application retry after a short Scheduler retry window can still deliver an obsolete reminder unless the handler checks the business deadline again.

Be explicit about time zones

For “24 hours before,” subtract 24 elapsed hours from the appointment's UTC instant. “At 9 a.m. on the previous local calendar day” is a different policy. Compute that using the clinic's named time zone and resolve daylight-saving transitions explicitly.
Keep the original clinic time zone alongside the UTC start time for display and policy calculations. Test ambiguous and nonexistent local times in markets with daylight-saving changes.
EventBridge Scheduler uses 60-second invocation precision. Disabling the flexible window does not create second-level timing. Set patient and staff expectations around a reminder window.

Test a realistic pilot

Create an appointment several minutes ahead in a test environment using synthetic contact information. Verify the normal reminder, then repeat with cancellation, rescheduling, duplicate events, a provider timeout, and a worker crash after a claim.

Check that an obsolete version is skipped, a failed schedule creation is retried from the outbox, and an uncertain provider outcome is visible to operators. Test late retries and short-notice appointments separately.

For budgeting, count schedule invocations, Lambda requests and duration, database reads and conditional writes, queue or destination usage, log retention, and provider messages. SMS and WhatsApp charges depend on channel, destination, and provider rules, so estimate them separately from AWS execution costs.

Before expansion, have staff trace one reminder from booking change to provider status using opaque identifiers. They should be able to identify whether a reminder was skipped, accepted, delivered, or left uncertain without opening raw patient data in logs.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article