← All articles

Scheduling

Microsoft Bookings Integration

Embed booking widgets that push appointments into Office 365 with calendar synchronization and automated confirmations.

Published February 15, 2024
drupalmicrosoft-bookingsschedulingappointmentscalendaroffice365automation

Overview

Microsoft Bookings integration for Drupal provides a comprehensive scheduling solution that embeds directly into your website. This integration enables automated appointment management, calendar synchronization, and professional communication with clients through the Microsoft 365 ecosystem.

Features

  • Embeddable booking widget in Drupal pages
  • Automated appointment creation in Office 365
  • Calendar synchronization across platforms
  • Automated email confirmations and reminders
  • Staff availability management
  • Service and pricing configuration
  • Customer self-service booking
  • Appointment cancellation and rescheduling

Technical Details

Technologies: Microsoft Bookings API, Microsoft Graph API, Drupal Block API, Drupal Form API, JavaScript SDK, OAuth 2.0

Requirements:

  • Drupal 9.x or 10.x
  • Microsoft 365 Business with Bookings
  • Azure AD app with Bookings.ReadWrite.All permission
  • SSL certificate for production
  • Calendar.ReadWrite permission for staff

API Endpoints:

List businesses: GET /solutions/bookingBusinesses
Create appointment: POST /solutions/bookingBusinesses/{id}/appointments
Get appointment: GET /solutions/bookingBusinesses/{id}/appointments/{appointment-id}
Cancel appointment: POST /solutions/bookingBusinesses/{id}/appointments/{appointment-id}/cancel

Implementation

  1. Configure Azure AD app with Bookings permissions
  2. Create Microsoft Bookings business
  3. Configure services, staff, and availability
  4. Create Drupal block plugin for booking widget
  5. Implement Graph API client for appointments
  6. Build booking form with validation
  7. Set up webhook for appointment notifications
  8. Implement calendar synchronization
  9. Add customer communication templates
  10. Configure confirmation and reminder emails
<?php
// Example: Drupal block for Bookings widget
namespace Drupal\bookings_integration\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * @Block(
 *   id = "microsoft_bookings_widget",
 *   admin_label = @Translation("Microsoft Bookings Widget"),
 *   category = @Translation("Microsoft 365")
 * )
 */
class MicrosoftBookingsBlock extends BlockBase {
  
  public function build() {
    $business_id = $this->configuration['business_id'];
    $service_id = $this->configuration['service_id'];
    
    return [
      '#theme' => 'bookings_widget',
      '#business_id' => $business_id,
      '#service_id' => $service_id,
      '#attached' => [
        'library' => ['bookings_integration/widget'],
        'drupalSettings' => [
          'bookingsIntegration' => [
            'businessId' => $business_id,
            'serviceId' => $service_id,
            'apiEndpoint' => '/api/bookings/create',
          ],
        ],
      ],
    ];
  }
  
  public function blockForm($form, FormStateInterface $form_state) {
    $form['business_id'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Bookings Business ID'),
      '#default_value' => $this->configuration['business_id'] ?? '',
      '#required' => TRUE,
    ];
    
    $form['service_id'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Service ID'),
      '#default_value' => $this->configuration['service_id'] ?? '',
      '#description' => $this->t('Leave empty to show all services'),
    ];
    
    return $form;
  }
  
  public function blockSubmit($form, FormStateInterface $form_state) {
    $this->configuration['business_id'] = $form_state->getValue('business_id');
    $this->configuration['service_id'] = $form_state->getValue('service_id');
  }
}

Use Cases

  • Healthcare appointment scheduling
  • Professional services consultations
  • Educational institution office hours
  • Client onboarding sessions
  • Service-based business bookings

Benefits

  • Professional scheduling without third-party tools
  • Automated calendar management
  • Reduced no-shows with reminders
  • 24/7 self-service booking availability
  • Integration with existing Office 365 calendars
  • Branded booking experience
  • Reduced administrative scheduling overhead