Quick overview
This workflow provides an n8n booking form that validates appointment requests, reserves the first available staff member in Postgres without double-booking, emails the customer a confirmation via SMTP, and suggests alternative time slots when the requested time is unavailable.
How it works
- Receives an appointment request through an n8n Form with name, email, date, time, and optional notes.
- Validates the request (email/name, notice period, booking window, and staff working hours) and calculates the appointment start/end times.
- Reserves the first available staff member by calling a Postgres function that inserts a booking with conflict protection via unique indexes.
- If a new booking is created, sends a confirmation email via SMTP (BCC to the owner) and stores any email-send error back to Postgres.
- If the customer already has a confirmed booking for the same slot, returns a page confirming the existing booking without changing anything.
- If all eligible staff are taken, loads upcoming bookings from Postgres, computes the next five available times, and returns a page suggesting alternative slots.
Setup
- Create a Postgres credential in n8n and run the one-time setup trigger to create the
bookings table, indexes, and n8n_book_first_free function.
- Add the same Postgres credential to each Postgres node and ensure the database is reachable from your n8n instance.
- Add an SMTP credential for sending emails and set an allowed sender address in the workflow’s
from_email setting.
- Update the booking settings (business name, notification email, slot length, min notice, max days ahead, and staff schedules) to match your business hours and availability.
- Set the workflow timezone in n8n and keep the form’s Time dropdown aligned with your slot grid, then activate the workflow and share the form’s Production URL.