Free n8n template

Appointment reminder reply handler n8n template

What it does

When a patient replies to a reminder text, this workflow records STOP opt-outs, checks your consent table, and only texts back numbers with recorded SMS consent. Claude classifies the reply as confirm, cancel, reschedule, question or unclear, your scheduling system applies the change, and anything clinical, unclear or failed lands in a staff queue. You need n8n, Twilio, Postgres, an Anthropic API key and a scheduling webhook.

What this workflow does

  1. Twilio inbound SMS (Webhook) receives the reply, and Reply to Twilio (empty TwiML) answers Twilio straight away.
  2. Normalize and screen (Code) converts the number to E.164 and checks fixed rules before any AI: single-word opt-out keywords (STOP, CANCEL, END, QUIT, UNSUBSCRIBE and others), HELP, and your clinician-written urgent phrase list.
  3. Postgres: look up consent and appointment reads the consent row and the next upcoming appointment for that number.
  4. Gate on consent (Code) applies the order that matters: opt-outs are always recorded; numbers without recorded consent are never texted and go to staff; urgent phrases get a fixed reply to call 911 or the office plus an urgent staff task; everything else is classified.
  5. Route reply (Switch) sends each reply down the right path.
  6. Postgres: record opt-out updates the consent table, so the reminder sender skips the number from then on.
  7. Claude: classify reply (HTTP Request) returns intent, confidence, a clinical concern flag and any preferred times as strict JSON, at low effort.
  8. Parse intent and decide (Code) handles refusal, max_tokens and API errors. Plain-words opt-out requests are recorded as opt-outs. Clinical mentions and low confidence go to staff.
  9. Scheduling system: apply action (HTTP Request) posts confirm, cancel or reschedule to your scheduling webhook, and Compose reply writes a short confirmation or up to three open slots.
  10. Twilio: send reply texts the patient. Postgres: add to staff queue collects every reply that needs a person, including failed sends.

Before you import

  • Self-hosted n8n on HIPAA-eligible infrastructure, a Twilio account covered by a BAA (Twilio signs BAAs for Security and Enterprise Edition accounts) and registered for A2P 10DLC, and a BAA-covered arrangement for the model API.
  • A Postgres database with sms_consent, appointments and staff_queue tables, kept in sync with your EHR or scheduling system.
  • A scheduling endpoint that accepts { appointmentId, action, preferredTimes }. DrChrono and Acuity have APIs; Epic and athenahealth usually need partner or customer-specific approval first.

Setup

  1. Create the three tables listed in the sticky note, with phone numbers in E.164.
  2. Set your Twilio number’s incoming message webhook to the production URL.
  3. Review URGENT_PHRASES with a clinician and set PRACTICE_TZ in Compose reply.
  4. Replace REPLACE_WITH_SCHEDULING_WEBHOOK_URL, REPLACE_WITH_TWILIO_NUMBER and REPLACE_WITH_PRACTICE_NAME.
  5. Write reminders that ask for C to confirm and R to reschedule. CANCEL is one of Twilio’s default opt-out keywords and YES is a Twilio opt-in keyword, so both trigger Twilio’s own handling.

Test it

From a test phone with a consent row, reply C, R with a preferred day, a question, and STOP. Check the scheduling calls, the replies and the consent table. Repeat from a number without a consent row and confirm nothing is texted and a staff row appears instead.

Make it production-ready

  • Under the TCPA, automated texts need the patient’s prior consent, and FCC rules require honoring an opt-out made by any reasonable means, including a plain-words reply, within 10 business days. Have counsel review consent language and message content. This template is not legal advice.
  • Validate Twilio’s request signature before trusting the webhook.
  • Keep clinical details out of every message, and add an error workflow that alerts staff if the workflow stops.
  • Slot picks (a reply of 1, 2 or 3) go to staff in this starter; add a step to book them once write-back is reliable.
  • claude-haiku-5-5 is a cheaper option for this short, high-volume classification.

Read the full guide at How to reduce no-shows with AI appointment reminders, or talk to us about connecting your EHR.

Next steps