We built DEV3 AI Booking & Appointments as a WordPress plugin in PHP with a React admin and a light, dependency-free booking widget. Availability is computed by a pure PHP engine that never writes, and every write goes through one booking manager.
Key design decisions
- Wall-clock slots, elapsed-time durations. Opening hours are stored as local times per staff member and converted to UTC per date. Slots line up with the staff member's clock, while durations and buffers are real minutes. Times skipped by a spring-forward change are never offered, and the repeated hour on fall-back day is offered once.
- One engine, every rule. Weekly hours with several intervals, breaks, special hours, time off and business closures (all-day or partial), buffers before and after, minimum notice, maximum advance, group capacity and unpaid holds that expire all live in
Availability\Engine, covered by 20 PHPUnit fixtures.
- No double bookings. Creating or rescheduling takes a MySQL named lock per staff member, re-runs the engine for that exact start and only then inserts. A second request for the same slot gets
dev3bk_slot_taken (HTTP 409).
- Customer timezone at the edge. The API returns UTC ISO starts with local labels grouped by the customer's own date, so a Tokyo customer booking a London stylist sees Tokyo days and times.
- AI returns constraints, not slots. Natural-language requests become a structured
{service, staff, dates, weekdays, time window} object. The server ignores unknown IDs, clamps dates to the booking window and runs the engine, so only real free slots come back. A rules parser answers the same phrases when AI is off.
- AI that suggests, never acts. Reminder copy is a draft you review in a diff and approve before it becomes a template. The no-show score is a deterministic rule model; AI only adds a plain-language hint from anonymised facts and changes nothing.
Architecture
Seven custom tables hold services, staff, staff-service links, schedule exceptions, customers, bookings and an event timeline. The widget is a Gutenberg block and shortcode with a mobile-first step flow, a timezone switcher and Add to Google Calendar and .ics downloads. Payments run as pay later, Stripe Checkout with signed webhooks and policy-based refunds, or WooCommerce checkout through a hidden virtual product (HPOS and block checkout). Guests manage bookings through a keyed link with cancel and reschedule cutoffs; staff get a private iCal feed. Reminders run on a 5-minute cron with a per-booking sent flag. The API client, settings and usage logs come from a shared core used across DEV3's plugins.