Skip to content

Microsoft 365 Bookings Web Components Widget, run on CloudFlare Workers

Notifications You must be signed in to change notification settings

bman46/bookings-workers

Repository files navigation

Microsoft Bookings Widget

Deploy to Cloudflare

This project provides a custom frontend and backend integration for Microsoft 365 Bookings. It enables a modern, user-friendly booking experience while leveraging Microsoft Bookings as the backend. The backend is OpenAPI-compliant, making it easy to integrate with the frontend and other systems. The frontend is built as a widget using LitElement web components, and the backend exposes endpoints for business info, services, staff availability, and appointment creation.

Get started

  1. Sign up for Cloudflare Workers. The free tier is more than enough for most use cases.
  2. Create an Azure EntraID app.
  3. Continue to either the Development or Deployment instructions.

Development

  1. Clone this project and install dependencies with npm install
  2. Set the needed env vars in a file named .dev.vars
TENANT_ID=[Directory (tenant) ID]
CLIENT_ID=[Application (client) ID]
CLIENT_SECRET=[Client secret value]
  1. Update index.html with information about your booking page.
  2. Run wrangler dev to start a local instance of the API.
  3. Open http://localhost:8787/docs in your browser to see the Swagger interface where you can try the endpoints.
  4. Changes made in the src/ folder will automatically trigger the server to reload, you only need to refresh the Swagger interface.

Deployment

  1. Sign up for Cloudflare Workers. The free tier is more than enough for most use cases.
  2. Deploy to CloudFlare: Deploy to Cloudflare
  3. On the deploy screen, under Advanced settings > Build variables add the following variables. Click the encrypt button for CLIENT_SECRET:
TENANT_ID=[Directory (tenant) ID]
CLIENT_ID=[Application (client) ID]
CLIENT_SECRET=[Client secret value]
ALLOWED_ORIGINS=[Domain/subdomain that can use this widget],[another (optional) domain/subdomain that can use this widget]

Tip

If you already deployed the app, you can add this using the Cloudflare Dashboard.

  1. Embed the widget into your website. Example:
<!DOCTYPE html>
<head>
  <script type="module" src="(your worker domain)/index.js"></script>
</head>
<body>
  <booking-card api-url="(your worker domain)" bookings-id="[email protected]" service-displayName="My Service" icon="🔧"></booking-card>
</body>

Azure EntraID Configuration

  1. Sign in to the Microsoft Entra admin center as at least an Application Developer.

  2. If you have access to multiple tenants, use the Settings icon in the top menu to switch to the tenant in which you want to register the application.

  3. Browse to Entra ID > App registrations and select New registration.

  4. Enter a meaningful name for the app, for example booking-widget.

  5. Select Accounts in this organizational directory only (John McShane Auto Body only - Single tenant) for Supported account types

  6. Click Register

  7. On the app Overview screen, note the Application (client) ID and Directory (tenant) ID. These will be used later.

  8. Navigate to Certificates & secrets > Client secrets and click new client secret. Name it accordingly, click Add. Note the value for use later. We will refer to this as the Client secret value in future steps

  9. Navigate to API Permissions > Add a permission > Microsoft Graph > Application Permissions. Assign the following GraphAPI permissions:

Bookings.Read.All
BookingsAppointment.ReadWrite.All
  1. Click Add Permissions to set the permissions. Then, click Grant Admin Consent for [COMPANY] button to grant the app access to these API endpoints.

  2. Return to either the Development or Deployment instructions.

Pictures

Time selection

Time selection screen

Customer Information

Customer information

Confirmation Screen

Booking confirmation

Releases

No releases published

Packages

No packages published