Prompt
How do I build a booking page that writes to a user's calendar?
Latest observation
Oct 31, 2026
OpenAI APIWeb search: off
To build a booking page that writes to a user’s calendar, you typically need 4 parts:
- A booking UI where a customer picks a time
- A backend that checks availability and saves the booking
- Calendar API integration to create the event in the user’s calendar
- OAuth login/consent so the user authorizes calendar access
Basic flow
- User opens your booking page.
- They select a service, date, and time.
- Your backend validates the slot is available.
- User signs in with Google/Microsoft/etc. and grants calendar permission.
- Your backend creates the event in their calendar.
- Your system stores the booking record and confirmation status.
What you need
1) Frontend booking page
Include:
- available dates/times
- service type
- attendee info
- confirmation screen
Can be built with React, Vue, plain HTML, etc.
2) Backend server
Use something like:
- Node.js / Express
- Python / FastAPI / Django
- Ruby on Rails
Responsibilities:
- availability lookup
- booking creation
- calendar API calls
- webhook handling if needed
- sending confirmations
3) Calendar provider API
Common options:
- Google Calendar API
- Microsoft Graph Calendar API for Outlook/Office 365
- Apple Calendar usually goes through CalDAV or iCal-style feeds, but direct write access is more limited and often handled indirectly
4) OAuth 2.0
To write to a user’s calendar, you need their permission.
Typical scopes:
- Google:
https://www.googleapis.com/auth/calendar.events - Microsoft:
Calendars.ReadWrite
Example architecture
- Frontend: booking form
- Backend:
POST /bookings - Auth endpoint:
GET /auth/google - Callback endpoint:
GET /auth/google/callback - Calendar writer: service that calls calendar API
Example booking flow with Google Calendar
Step 1: User clicks “Connect Google Calendar”
You redirect them to Google OAuth.
Step 2: User consents
They approve calendar access.
Step 3: Backend receives auth code
You exchange it for an access token and refresh token.
Step 4: Create calendar event
Use Google Calendar API:
await calendar.events.insert({
calendarId: 'primary',
requestBody: {
summary: 'Booking with Acme',
description: 'Consultation booking',
start: {
dateTime: '2026-11-01T10:00:00-05:00'
},
end: {
dateTime: '2026-11-01T10:30:00-05:00'
},
attendees: [{ email: 'customer@example.com' }]
}
})
Important considerations
Avoid double booking
Before creating the event:
- check the calendar for conflicts
- lock the slot in your database
- recheck right before insert
Use refresh tokens
Access tokens expire quickly. Store refresh tokens securely so you can create/update events later.
Time zones
Always store:
- UTC timestamps internally
- the user’s time zone for display and calendar insertion
Privacy/security
- use HTTPS
- encrypt tokens at rest
- request only the minimum scope needed
- let users disconnect calendar access
Rescheduling/canceling
You’ll want to:
- store the calendar event ID
- update or delete the event when the booking changes
If you want a simpler version
If you don’t need to write directly into a personal calendar, you can:
- create an .ics file download
- send an email with “Add to Calendar”
- sync to your own business calendar only
Best practice recommendation
For most booking apps:
- business-side scheduling should use a shared calendar or database
- customer-side calendar event creation should happen only after OAuth consent
- use provider-specific calendar APIs rather than trying to directly manipulate calendar files
If you want, I can show you:
- a minimal working example in Node.js + Google Calendar API, or
- a full booking-page architecture with database tables and endpoints.