Description

The Microsoft 365 calendar integration connects an Outlook / Exchange Online calendar to Kommander through the Microsoft identity platform (OAuth 2.0) and Microsoft Graph. It powers the same features as Google Calendar: chat booking, event types, paid bookings, the public booking page (/book/{organization}/{eventType}), and the operator calendar.

A context (personal account or organization) has one active calendar. Connecting Microsoft replaces a previous Google connection and vice versa; availability settings, event types, and booking keywords are kept.

The routes are /api/integrations/microsoft-calendar/authorize and /api/integrations/microsoft-calendar/callback. After consent Kommander stores an encrypted refresh token in the calendar MCP server config with provider: "microsoft_calendar".

ToolMicrosoft Graph surface
calendar_check_availabilityGET /me/calendar/calendarView (events not shown as Free block time)
calendar_create_meeting / event-type bookingsPOST /me/calendar/events with isOnlineMeeting (Teams) and transactionId
calendar_list_upcomingGET /me/calendar/calendarView
calendar_update_meetingPATCH /me/events/{id}

App Registration (once per Kommander deployment)

  1. In the Microsoft Entra admin center  open App registrations > New registration.
  2. Name it (e.g. Kommander Calendar) and choose Accounts in any organizational directory and personal Microsoft accounts so any customer tenant can connect.
  3. Add a Web redirect URI, replacing the host with the deployed app host:
https://app.example.com/api/integrations/microsoft-calendar/callback

For local development also add http://localhost:9002/api/integrations/microsoft-calendar/callback (Microsoft allows plain http only for localhost).

  1. Under Certificates & secrets create a client secret and copy its Value (not the Secret ID; the value is shown only once). Note its expiry and rotate it before it lapses.
  2. Under API permissions > Microsoft Graph > Delegated add offline_access, User.Read, and Calendars.ReadWrite.
  3. Complete publisher verification (Branding & properties). Many tenants block users from consenting to multi-tenant apps from unverified publishers.
  4. Configure the runtime and restart:
AUTH_SECRET=... # Encrypts stored OAuth refresh tokens (32 bytes; e.g. `openssl rand -hex 32`). # Use the same key everywhere that shares a database. CREDENTIAL_ENCRYPTION_KEY=... MICROSOFT_CALENDAR_CLIENT_ID=... MICROSOFT_CALENDAR_CLIENT_SECRET=... # Optional: lock connections to one tenant instead of "common" # MICROSOFT_CALENDAR_TENANT_ID= NEXT_PUBLIC_BASE_URL=https://app.example.com

The calendar login app is separate from the MICROSOFT_CLIENT_ID used for “Sign in with Microsoft”; keeping them apart means sign-in never asks for calendar permissions.

Connecting A Calendar

The connecting user must be an organization admin or manager with the manage_integrations permission (personal accounts always can).

  1. Open Integrations > Calendar, enable the integration, and select Microsoft 365 / Outlook.
  2. Click Connect with Microsoft 365 and sign in with the mailbox that owns the calendar (for demos, a shared sales mailbox works well).
  3. After the redirect the page shows Connected to Microsoft 365 / Outlook and the signed-in address.
  4. Configure availability and, optionally, event types. Share the public booking link or let the assistant book from chat.

Calendar ID defaults to primary (the mailbox’s default calendar). To target another calendar, paste its Graph calendar id.

If users see Need admin approval, a Microsoft 365 administrator of the customer’s tenant can approve Kommander once for the whole organization by opening:

https://login.microsoftonline.com/{customer-tenant-id}/adminconsent?client_id={MICROSOFT_CALENDAR_CLIENT_ID}

Alternatively the administrator can connect the calendar first and tick Consent on behalf of your organization.

Testing The Integration

Run this checklist after setup, after changing the app registration, and before handing the integration to a customer. Use a test organization and a mailbox whose calendar you can freely modify.

1. Connect

  1. Open Integrations > Calendar, enable the toggle, select Microsoft 365 / Outlook, and click Connect with Microsoft 365.
  2. Sign in and accept the consent screen.
  3. Expected: you land on /integrations/calendar?mscal_success=true and the card shows Connected to Microsoft 365 / Outlook with Signed in as followed by the connected mailbox.

2. Read checks (no calendar changes)

While signed in to Kommander, these operator endpoints must return 200 with "provider": "microsoft_calendar":

GET /api/operator/calendar/events?contextId={orgId}&timeMin={iso}&timeMax={iso}&timezone=Europe/Rome GET /api/operator/calendar/availability?contextId={orgId}&date=YYYY-MM-DD&timezone=Europe/Rome&durationMinutes=30

Compare the result with Outlook for the same day:

  • Events created directly in Outlook are listed with readOnly: true.
  • Busy, tentative, out-of-office, and working-elsewhere events remove the overlapping slots.
  • Events shown as Free and cancelled events do not remove slots. This is expected, not a bug.
  • Slot times match the weekly hours configured under Availability rules in the assistant’s timezone.

The availability preview under Integrations > Calendar > Availability rules shows the same slots.

3. Book from the chatbot

  1. Open External assistant (/chatbot-trial) in the same organization.
  2. Ask for a booking, for example “Vorrei prenotare una demo domani alle 10” or “I’d like to book a demo tomorrow at 10”.
  3. The assistant offers free slots, asks for name and email, then confirms. Use your own email as the attendee so the invitation only reaches you.
  4. Expected in Outlook: a new event at the confirmed time, the attendee invited, and a Teams join link (work/school accounts). In Kommander’s Calendar page the event is editable, not read-only.
  5. If the organization has active event types, the assistant books through the event type instead of a generic meeting; paid types return a Stripe Checkout link first.

4. Public booking page

Open /book/{organizationSlug}/{eventTypeSlug} in a private window, book a slot, and confirm the event appears in Outlook. This is the page to share with customers who asked for a “public calendar page” (for example to replace a Microsoft Bookings link).

5. Clean up

Delete the test meeting from Kommander’s Calendar page (this also sends the cancellation) or directly in Outlook. Use Disconnect on the integration card if the test mailbox should not stay connected.

How It Behaves

  • Teams links. Meetings are created with a Teams online meeting. Accounts without Teams (e.g. personal Outlook.com) are retried automatically without one.
  • Invitations. Graph sends the invitation to the attendee on create, and a cancellation when a Kommander-managed meeting is deleted.
  • Time zones. Kommander reads and writes Graph date-times in UTC (Prefer: outlook.timezone="UTC") and applies the assistant’s IANA timezone itself, so no Windows time-zone mapping is needed.
  • Free events. Outlook events shown as Free do not block availability. Everything else (busy, tentative, out of office, working elsewhere) does.
  • Provenance. Kommander stamps managed events with a private extended property. Events created in Outlook directly are read-only in Kommander.
  • Token rotation. Microsoft issues a new refresh token on each refresh. Kommander stores the latest one (encrypted) automatically. Connections that stay unused for about 90 days expire and must be reconnected.

Common Errors

OAuth callback errors are shown on /integrations/calendar?mscal_error={code}; codes are the same as for Google Calendar.

SymptomLikely causeSolution
calendar_forbidden (You need the Manage integrations permission…) when clicking ConnectThe user’s membership lacks manage_integrations; common for members whose permission list was stored before that permission existed.Run npm run migrate:manage-integrations-permission with MONGODB_URI pointing at that environment’s database (the script reads .env.local), or grant the member the permission.
mscal_error=calendar_config_error after consentCREDENTIAL_ENCRYPTION_KEY (or ENCRYPTION_KEY) is not set, so the refresh token cannot be stored.Set the key and restart. Authorization codes are single-use, so click Connect again.
A slot is offered although Outlook shows an eventThe event is marked Free or is cancelled.Expected behavior. Change the event to Busy in Outlook if it should block time.
AADSTS50011 redirect URI mismatchThe app registration redirect URI differs from {NEXT_PUBLIC_BASE_URL}/api/integrations/microsoft-calendar/callback.Make them identical (scheme, host, path).
Need admin approvalThe customer tenant blocks user consent.Use the admin-consent link above.
calendar_token_exchange_failedNo refresh token returned (missing offline_access) or an expired client secret.Check API permissions and the client secret expiry, then reconnect.
calendar_auth_error later onRefresh token revoked, expired after inactivity, or the user’s password/MFA policy changed.Reconnect the calendar.
Integration shows “not available”MICROSOFT_CALENDAR_CLIENT_ID / _SECRET are not set on the server.Configure the env vars and restart.

Limitations

  • Delegated access only: the connected mailbox’s calendar is used; there is no room/resource booking or multi-mailbox round-robin yet.
  • Microsoft Bookings pages are not used; Kommander’s own event types and public booking page replace them.
  • Change notifications (webhooks) are not subscribed; Kommander reads Graph on demand.