Microsoft Bookings Integration (via MS Power Automate) using MS Graph
IntegrationIntroduction
You can integrate third-party systems with Service Manager in many ways. The method you select will depend on business requirements, architectural and security constraints as well as the characteristics specific to each third-party application or service.
This document describes an integration process that has already been implemented in a customer context.
To find out more about this integration (e.g. scripts to be used), please do not hesitate to contact your EasyVista contact, or your service provider and integrator.
Overview of the integration
Microsoft Bookings is a solution for planning and managing business customer appointments using a shared calendar.
This integration enables you to access calendar data via Microsoft Power Automate. It provides two examples on how to list appointments and create new ones.
Note: The Microsoft Power Automate workflow accesses data using the Microsoft Graph gateway as there is no Microsoft Bookings connector in Microsoft Power Automate.
Preview of the tools used in this integration
IntegrationTool_MicrosoftAzureLogicApps
- Microsoft Azure Logic Apps enables you to create logic apps that run workflows and provide access to cloud data and services using ready-to-use connectors.
IntegrationTool_MicrosoftGraph
- Microsoft Graph is a gateway for accessing all data available in Microsoft Cloud Services via the Microsoft Graph API.
See List of all permissions available for the Microsoft Graph API.
IntegrationTool_MicrosoftPowerAutomate
- Microsoft Power Automate (formerly known as Microsoft Flow) enables you to automate recurrent tasks by building workflows using Web applications. The tool relies on standard connectors based on Microsoft Azure Logic Apps for interfacing with any endpoint via HTTP/HTTPS. It can also use the Microsoft Graph gateway via the Microsoft Graph API.
- The Microsoft Bookings API provides several types of resources for accessing Microsoft Bookings data, i.e. information on businesses, customers, staff members, services and calendars.
Integration Data Feed (direction) | Authentication Type | Integration Connector Options | ||
---|---|---|---|---|
|
|
|
Available versions | ||
---|---|---|
SaaS-based | On-premises | |
Service Manager | ![]() |
![]() |
Third-Party Product | ![]() |
N/A |
Microsoft Bookings API - Definitions
API methods are accessed using a URL in the following format.
example List all businesses saved in Microsoft Bookings
Objects used by the Microsoft Bookings API
- bookingBusiness object: Top level object in the API representing a business and containing business information on customers, teams, etc. as well as appointments.
- bookingBusinesses: All information on businesses. You access a specific business using its unique ID.
- bookingAppointment: All business appointments. An appointment is made up of a start time and an end time.
- bookingCustomer: All business customers.
- bookingCService: All services provided by a business.
- bookingStaffMember: All staff members providing services in a business.
Step-by-Step Integration Process
Prerequisites
- You must have an Azure subscription. If this is not the case, you can create a free account, or you can buy an Azure Pay-As-You-Go subscription.
See the procedure.
- You must have the relevant accounts and access rights to the services interfacing with Logic Apps.
- You must have a subscription to Office 365 Business Premium.
- You must have created the Microsoft Graph gateway for accessing Microsoft Bookings data.
See the pocedure.
- You must have the IDs provided by Microsoft Azure: Tenant (Directory) ID, Application (client) ID, Client secret.
Description of the workflow
Enable the Microsoft Graph gateway in Microsoft Power Automate
Step 1: Go to the Microsoft Power Automate start page.
1. Log in to the Microsoft Power Automate website using your account login.
Step 2: Create a flow for retrieving the Azure AD application information.
Note: The flow below will run automatically. You can use any type of trigger.
1. Select + Create in the left pane and click Instant flow.
2. Select the trigger method for Manually trigger a flow.
3. Click Create.
4. Store the Azure AD application information by creating the Initialize variable actions shown below.
Action | Details | |
---|---|---|
4.a Retrieve the tenant ID. |
|
|
4.b Retrieve the Azure AD appplication ID |
|
|
4.c Retrieve the client secret. |
|
|
4.d Retrieve information on the account accessing the Microsoft Graph API. |
|
5. Encode the client secret and password by creating two Compose actions.
Note: The {variables} instructions will automatically be replaced by the dynamic variables you previously created.
Action | Details | |
---|---|---|
5.a Encode the client secret. |
|
|
5.b Encode the password. |
|
Step 3: Request an access token to the Microsoft Graph API.
1. Create a HTTP action.
2. Click in the title bar and rename the action, HTTP POST Microsoft Graph.
3. Specify the information on the action.
Note: The {variables} and {outputs} instructions will automatically be replaced by the dynamic variables you previously created.
- Method: Select the POST value.
- URI: Enter the URL below.
https://login.microsoftonline.com/@{variables('Tenant')}/oauth2/v2.0/token
- Headers: Specify the following values.
- Key: content-type
- Value: application/x-www-form-urlencoded
- Body: Enter the following code.
client_id=@{variables('App ID')}&scope=https://graph.microsoft.com/.default&grant_type=password&client_secret=@{outputs('Compose')}&username=@{variables('Email')}&password=@{outputs('Compose_2')}
- The access token will be generated. It enables the Azure AD application to access Microsoft Bookings resources.
- Token properties are stored in the Body variable.
4. Split the access token properties.
- Create a Parse JSON action.
- Specify the information on the action.
- Content: Select the dynamic variable called Body from the HTTP Microsoft Graph action.
- Schema: Enter the following JSON code.{
"type": "object",
"properties": {
"token_type": {
"type": "string"
},
"scope": {
"type": "string"
},
"expires_in": {
"type": "integer"
},
"ext_expires_in": {
"type": "integer"
},
"access_token": {
"type": "string"
}
}
}
The values of the access token's properties will automatically be stored in dedicated variables.
Step 4: Retrieve a business ID in the calendar.
1. Retrieve all businesses in the calendar.
- Create a HTTP action.
- Click
in the title bar and rename the action, HTTP GET Microsoft Bookings.
- Specify the information on the action.
- Method: Select the GET value.
- URI: Enter the URL below.
Note: You can filter businesses by adding the criteria you want in the URL.https://graph.microsoft.com/beta/bookingBusinesses
- Headers: Create the two following lines.
- Key: content-type
- Value: application/json
- Key: Authorization
- Value: Bearer @{body('Parse_JSON')?['access_token']}
2. Retrieve the business ID you want by creating the Initialize variable actions shown below.
Note: The {variables} instructions will automatically be replaced by the dynamic variables you previously created.
Action | Details | |
---|---|---|
2.a Retrieve the body containing the list of businesses. |
|
|
2.b Split the body in an array. |
|
|
2.c Retrieve the business ID. |
|
|
2.d Split the business ID in an array. |
|
|
2.e Retrieve the business ID with double quotes. |
|
|
2.e Split the business ID with double quotes in an array. |
|
|
2.g Retrieve the business ID without double quotes. |
|
The business ID will be stored in the ID Final without double quote variable. It enables you to access Microsoft Bookings resources for the business you want.
example List all services provided by the business; create a business appointment
Examples of integration
List all business appointments
1. Create a HTTP action.
2. Click in the title bar and rename the action, HTTP GET Microsoft Bookings Appointment.
3. Specify the information on the action.
Note: The business ID is called using the ID Final without double quote variable initialized when the gateway was enabled.
- Method: Select the GET value.
- URI: Enter the URL below.
concat(concat('https://graph.microsoft.com/beta/bookingBusinesses/',@{variables('ID Final without double quote')}),'/appointments')
- Headers: Create the two following lines.
- Key: content-type
- Value: application/json
- Key: Authorization
- Value: Bearer @{body('Parse_JSON')?['access_token']}
Create a new business appointment
1. Specify the information on the appointment by creating an Initialize variable action.
Action | Details | |
---|---|---|
1.a Define the appointment information. |
example { "customerName": "testezv", "end": { "@odata.type": "#microsoft.graph.dateTimeTimeZone", "dateTime": "2020-06-09T15:30:00+02:00", "timeZone": "USA/Boston" }, "start": { "@odata.type": "#microsoft.graph.dateTimeTimeZone", "dateTime": "2020-06-09T15:00:00+02:00", "timeZone": "USA/Boston" }, "serviceName": "test ezv" } |
2. Save the appointment in the calendar.
- Create a HTTP action.
- Click
in the title bar and rename the action, HTTP POST Microsoft Bookings Appointment.
Specify the information on the action.
Note: The {variables} instructions will automatically be replaced by the dynamic variables you previously created when the gateway was enabled.- Method: Select the POST value.
- URI: Enter the URL below.
concat(concat('https://graph.microsoft.com/beta/bookingBusinesses/',@{variables('ID Final without double quote')}),'/appointments')
- Headers: Create the two following lines.
- Key: content-type
- Value: application/json
- Key: Authorization
- Value: Bearer @{body('Parse_JSON')?['access_token']}
- Body: Enter the instruction below.
json(@{variables('Json for creating appointment')})
The new appointment will be added to the business calendar.
AccountFreeCreation
How to create a free Azure account
1. Go to the Microsoft Azure website.
2. Click Start free.
3. Log in to your professional Microsoft account.
4. Enter the login information.
5. Click Next.
6. Tick the I agree box.
7. Click Sign up.