Free guide
The Midnight Booking Workflow
Turn lost after-hours patient texts into confirmed appointments while you sleep.
What You Need
- n8n: The automation platform. Use a self-hosted instance (free) or an n8n Cloud trial.
- Twilio: To receive and send patient text messages. (Pay-per-text, approx. $1โ$2/month).
- OpenAI API: To power the AI agent that reads and replies. We use
gpt-4o-mini. (Approx. $1โ$3/month depending on volume). - Google Calendar: To check your availability and book slots. (Free).
Total cost: Under $5 a month.
Step-by-Step Build Guide
Step 1: Capture the Incoming Text
- Open n8n and create a new workflow.
- Add a Twilio Trigger node.
- Set the event to Message Received.
- Connect your Twilio account using your Account SID and Auth Token.
- Copy the webhook URL provided by n8n and paste it into your Twilio phone number configuration under "A message comes in".
Step 2: Read Intent with OpenAI
- Add an Advanced AI node (OpenAI Chat Model) connected after the Twilio trigger.
- Set the Model to
gpt-4o-mini. - Paste this exact System Prompt: > "You are a friendly, professional front-desk receptionist for a dental clinic. Your job is to read incoming patient texts, determine if they want to book an appointment, and ask for their preferred day if they haven't provided it."
- Pass the incoming Twilio message body as the user input.
Step 3: Check Google Calendar Availability
- Add a Google Calendar node.
- Set the operation to Get Many (or use a Custom API tool if building an agentic loop).
- Connect your clinic's Google Calendar account.
- Filter events for the current week to pull open time blocks.
Step 4: Send Available Slots Back to the Patient
- Add a second OpenAI formatting node to turn the raw calendar JSON into a clean, readable text message.
- Prompt example: "Take these available calendar slots [insert data] and format them into a short, friendly SMS list for the patient. Give them 3 options."
- Add a Twilio node set to Send Message.
- Map the phone number from the original trigger and the AI-formatted text as the message body.
Step 5: Lock in the Appointment
- When the patient replies with their chosen number (e.g., "1 for Tuesday at 2 PM"), use an If node to route the response.
- Add a Google Calendar node set to Create Event.
- Map the patient's name, phone number, and selected time slot into the event details.
- Send a final confirmation text via Twilio: "You're all set for Tuesday at 2 PM. See you then!"
Common Mistakes & Fixes
- Mistake: The AI books appointments in the wrong timezone.
- Fix: Check your n8n workflow settings and ensure your Google Calendar account are set to the exact same local timezone (e.g., America/New_York).
- Mistake: Patients get stuck in an endless loop if they ask non-booking questions (like pricing).
- Fix: Update your OpenAI system prompt to include an escape hatch: "If the patient asks a complex clinical question, reply with: 'I can't answer that here, but our team will call you first thing in the morning!'"
Want more practical builds like this? Follow @letagentswork for weekly automations that save time.
Made by Let Agents Work โ follow @letagentswork
From the reel: Automate Dental Bookings With AI and n8n