Breadcrumbs

Synchronizing Microsoft Office 365 Outlook and Niagara schedules

Important notice: Microsoft Office 365 and Microsoft Azure are very large platforms. There is not a single configuration possibility. The following tutorial is only an example in a specific environment. If you don't know Microsoft 365 and Azure eco-systems, we strongly advise you to require someone's expertise.


We are going to see how to create a such an interface with full interaction with Azure Office 365

  • Retrieve bookings of the day

  • Create bookings on the fly (from an interface for example)

  • Cancel a booking to free the room (when there is no one inside for example)

Meeting rooms.png


What do you need?

There are a couple of requirements needed in order to create this interaction:

  • A RestNetwork (better if it's licensed...) installed on Niagara from 4.6

  • An Office 365 account https://www.office.com/ of your organization (or your customer organization)

  • An Azure account (it's easier if it's the same one as Office 365)

We are going to use the Microsoft Graph API: https://docs.microsoft.com/en-us/graph/outlook-calendar-concept-overview which is the most recent and easiest to connect to Office 365.

Register your app on Azure

We will follow this tutorial to register the application: https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app


Search for and select Azure Active Directory. On the Active Directory page, select App registrations and then select New registration.

image2019-11-18_23-13-24.png


Give a name to the instance and give a redirect url (localhost is fine).

image2019-11-18_23-15-45.png


Click on Register at the bottom.

Note the Application (client) ID and Directory (tenant) ID somewhere, we will need later

application ID.JPG


Add credentials to the application

From the same Azure application, go to Certificates & secrets

image2019-11-18_23-34-19.png


Select New client secret and give a name to your client secret. Then select Add

image2019-11-18_23-35-26.png


Copy somewhere safe your client's secret value, we will need it after. You won't be able to see it again from the Azure interface. If you lose it, no worries. Just delete the existing one and create a new one (it will impact every application that used it)

image2019-11-18_23-37-38.png


Add permissions to the application

Now from the same Azure application, go to API permissions

image2019-11-18_23-39-56.png


Select Add a permission, a panel will open on the right. Select Microsoft Graph and then select Application permissions

image2019-11-18_23-47-59.png


Browse the permissions and locate Calendars. Select Calendars.ReadWrite

image2019-11-18_23-49-55.png


Configure the RestNetwork

In Niagara, open the RestNetwork palette and then the Examples folder.

image2019-11-18_23-52-49.png


Add the Outlook Calendars examples to your drivers. Open it. Open the Auth device, open inside the http config

image2019-11-18_23-54-53.png


There are three parameters to change from the example:

  • The tenant id in the query.

  • The client_id

  • The client_secret

Example for the query: /7e1b53df-f2b8-4av5c-b17b-3e3faz455f147/oauth2/v2.0/token

Example for the body: client_id=f0b7a7fa-2fa-4cdc-sc9c-5a345a72c144&scope=https://graph.microsoft.com/.default&client_secret=QbvpFC=hVF.slgHaifEs]FzddF31@f854&grant_type=client_credentials


Once you've changed the values. Trigger the ping action on the Auth device. Then Open the Artifacts below, you should get your token in the read value

image2019-11-19_0-26-48.png

The authentication is now configured!


Manage the permissions

You need now to give your consent to allow access to the different calendars. Change the URL below with your own client_id

https://login.microsoftonline.com/common/adminconsent?client_id=myclientId&state=12345&redirect_uri=https://localhost

Then copy-paste it to your Web browser and select Accept

image2019-11-19_0-58-58.png


Create a meeting room

Go to the Office 365 interface and open the Admin center panel. Locate Show All > Resources > Rooms & equipment

image2019-11-19_1-23-31.png


Select Add. And configure a room. Make sure to use the proper domain for the email.

image2019-11-19_0-40-54.png


Select Add (no need to give a premium account for a meeting room)

image2019-11-19_7-53-28.png


Then in the Delegates block below, select Show all

image2019-11-19_12-13-37.png


Add everyone that needs to book the room. Then click on save.

image2019-11-19_12-14-0.png


The Delegate's configuration is optional. It will actually allow people registered as a "delegate" to book the room directly in the room calendar. You actually have two options to create an event.

  • Option 1: You create an event in your own calendar and choose the meeting room as a location

  • Option 2: You create an event in the room calendar.

The first option sounds better, however, the Microsoft API won't allow you to retrieve the name of the booking and it will replace it with your name. For now, we don't know yet if this is a bug of the Microsoft Graph API or an intended limitation. So if you need to visualize the event name, the second option is better. The delegate configuration is necessary only for the second option.


Configuration of the schedule in Niagara

In Niagara,

Open the Calendars device > Schedules > HttpConfig

Right-click in Http Config and in the Actions section click Add Overriding Property, then choose query.

Change the query with the room email address (it's the query used to discover calendars in the manager) 

Example: /beta/users/pollux@mydomain.onmicrosoft.com/findRooms (use beta instead of v1.0)

http config.JPG


Then Open Import Ext Config

Change the query with the room email address (it's the query that will be used once you create the new calendar)

Example: /beta/users/pollux@mydomain.onmicrosoft.com/calendars/${id}/events (use beta instead of v1.0)

Import Ext config.JPG


Then go to Schedules (In the Calendars device) to open the schedule manager. Click on Discover in the manager. A calendar should appear. Add it to the Database and give it a name.

image2019-11-19_9-43-0.png


Its status should be ok

image2019-11-19_9-45-50.png

Now go to your Outlook application (mobile app, Web app, or desktop app) and create a new booking.

Note: Rooms may take some time to appear in the Web app.



You will get the booking in the Niagara schedule

image2019-11-19_11-29-53.png


Create a new event on the fly from Niagara

We only retrieved bookings so far. You can also use the RestNetwork to create bookings in Outlook (from Niagara)

You can drag&drop from the palette a RestScheduleCreateExt or use the provided example with the Sirius room.

image2019-11-19_11-31-58.png     image2019-11-19_12-34-13.png


You have to fill two fields to create bookings:

  • The query with the room email address. Example: /v1.0/users/pollux@yourdomain.onmicrosoft.com/calendars/${ext.scheduleId}/events

  • The body with the information you want to use (the subject, the start date...). Example:
    {"subject":"Improvised Meeting 18:48:58","body":{"contentType":"HTML","content":"Réunion de la SBA"},"start":{"dateTime":"2019-09-17T18:48:58","timeZone":"Romance Standard Time"},"end":{"dateTime":"2019-09-17T19:18:58","timeZone":"Romance Standard Time"},"location":{"displayName":"Paris"},"attendees":[{"emailAddress":{"address":"smith@acme.com","name":"Mr Smith"}}]}

You can fill this information in the Logic folder

Delete the current event from Niagara

You can also delete an existing event if it matches some criteria. You will find an example in the Logic folder of the Sirius schedule example using the occupancy and a OneShot.

You have to modify as well, the query with your email address.

image2019-11-19_12-38-27.png