Microsoft Bookings (via MS Power Automate) Integration


About This Integration

IntegrationIntroduction

You can integrate third-party systems with Product name - ev itsm.png 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 contact the Logo - EasyVista.png Consulting & Professional Services team, the Logo - EasyVista.png Support team, 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 MS 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

  • 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.
  • Microsoft Graph is a gateway for accessing all data available in Microsoft Cloud Services via the MS Graph API.
  • 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 MS 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

Logo - EV Service Manager.png

Down arrow.png

Logo Icon - Microsoft Flow.png

Down arrow.png

Logo Icon - Microsoft Graph.png

Down arrow.png

Logo Icon - Microsoft Booking.png

  • Depending on the third-party service used (authentication managed by Logic Apps)
  • Basic Authentication for the Service Manager REST API
  • Service Manager:

    EV Integration connector icon - Workflow.png    Workflows

    EV Integration connector icon - Business rule.png    Business rules

    *MS Power Automate:

    EV Integration connector icon - Receive.png    Connector: When a HTTP request is received

    (Service Manager trigger => Logic Apps)

Available versions
SaaS-based On-premises
Service Manager Check icon.png Check icon.png
Third-Party Product Check icon.png N/A

Microsoft Bookings API - Definitions

API methods are accessed using a URL in the following format.

https://graph.microsoft.com/{API_version}/{resource_name}

example  List all businesses saved in Microsoft Bookings

https://graph.microsoft.com/beta/bookingBusinesses

   Open url.png See Using the Microsoft Graph API.

Objects used by the 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 object: All information on businesses. You access a specific business using its unique ID.
  • bookingAppointment object: All business appointments. An appointment is made up of a start time and an end time.
  • bookingCustomer object: All business customers.
  • bookingCService object: All services provided by a business.
  • bookingStaffMember object: All staff members providing services in a business.

Step-by-Step Integration Process

Prerequisites

Description of the workflow

        Microsoft Booking flow.png

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 logic app 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.

                  Power Automate - Create new flow.png 

2. Select the trigger method for Manually trigger a flow.

3. Click Create.

4. Store the logic app information by creating the Initialize variable actions shown below.

                  Manually trigger a flow - Flow description.png  MS Flow - Initialize variable action.png

Action Details
4.a Retrieve the tenant ID.
  • Name: Enter the name, Tenant.
  • Type: Select the String value.
  • Value: Copy and paste the tenant ID you stored in your text editor when creating the logic app (Tenant ID variable). The tenant ID was provided by Microsoft Azure. Open url.png See Creating a logic app using the Microsoft Graph API.
4.b Retrieve the logic app ID.
  • Name: Enter the name, App ID.
  • Type: Select the String value.
  • Value: Copy and paste the app ID you stored in your text editor when creating the logic app (Application (client) ID variable). The app ID was provided by Microsoft Azure. Open url.png See Creating a logic app using the Microsoft Graph API.
4.c Retrieve the client secret.
  • Name: Enter the name, Key.
  • Type: Select the String value.
  • Value: Copy and paste the client secret you stored in your text editor when creating the logic app (Client secrets > Value variable). The client secret was provided by Microsoft Azure. Open url.png See Creating a logic app using the Microsoft Graph API.
4.d Retrieve information on the account accessing the MS Graph API.
  • Email of the account.
    • Name: Enter the name, Email.
    • Type: Select the String value.
    • Value: Enter the email of the account.
  • Password of the account.
    • Name: Enter the name, Password.
    • Type: Select the String value.
    • Value: Enter the password of the account.

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.

        MS Flow - Compose action.png

Action Details
5.a Encode the client secret.
  • Compose action
  • Inputs: Enter the instruction below.
    encodeUriComponent(@{variables('Key')})
5.b Encode the password.
  • Compose_2 action
  • Inputs: Enter the instruction below.
    encodeUriComponent(@{variables('Password')})

Step 3: Request an access token to the Microsoft Graph API.

1. Create a HTTP action.

        HTTP Post action - Microsoft Graph.png

2. Click Browse black points icon.png 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 MS Logic App to access Microsoft Bookings resources.
  • Token properties are stored in the Body variable.

4. Split the access token properties.

  • Create a Parse JSON action.
             Parse JSON action.png
  • 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.
             HTTP Get action - Microsoft Booking.png
  • Click Browse black points icon.png 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.

        Get businesses - Flow description.png  MS Flow - Initialize variable action.png

Action Details
2.a Retrieve the body containing the list of businesses.
  • Name: Enter the name, Body.
  • Type: Select the String value.
  • Value: Select the dynamic variable called Body from the HTTP GET Microsoft Bookings action.
2.b Split the body in an array.
  • Name: Enter the name, Body Array.
  • Type: Select the Array value.
  • Value: Enter the instruction below.
    split(@{variables('Body')},',')
2.c Retrieve the business ID.
  • Name: Enter the name, ID.
  • Type: Select the String value.
  • Value: Enter the instruction below.
    @{variables('Body Array')}[3]
2.d Split the business ID in an array.
  • Name: Enter the name, ID Array.
  • Type: Select the Array value.
  • Value: Enter the instruction below.
    split(@{variables('ID')},':')
2.e Retrieve the business ID with double quotes.
  • Name: Enter the name, ID Final with double quote.
  • Type: Select the Array value.
  • Value: Enter the instruction below.
    @{variables('ID Array')}[1]
2.e Split the business ID with double quotes in an array.
  • Name: Enter the name, ID Final Array.
  • Type: Select the Array value.
  • Value: Enter the instruction below.
    split(@{variables('ID Final with double quote')},'"')
2.g Retrieve the business ID without double quotes.
  • Name: Enter the name, ID Final without double quote.
  • Type: Select the String value.
  • Value: Enter the instruction below.
    @{variables('ID Final Array')}[1]

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 Browse black points icon.png 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']}

        HTTP Get action - Microsoft Booking appointment.png

Create a new business appointment

1. Specify the information on the appointment by creating an Initialize variable action.

        MS Flow - Initialize variable action.png

Action Details
1.a Define the appointment information.
  • Name: Enter the name, JSON for creating appointment.
  • Type: Select the Object value.
  • Value: Enter the appointment information in JSON format.

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.
             HTTP Post action - Microsoft Booking appointment.png
  • Click Browse black points icon.png 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.

         Microsoft Flow - Free account.png

3. Log in to your professional Microsoft account.
         Microsoft Flow - Login account.png

4. Enter the login information.
         Microsoft Flow - Account creation - Identification 1.png

5. Click Next.

6. Tick the I agree box.
         Microsoft Flow - Account creation - Identification 2.png

7. Click Sign up.

Links to other integrations

Tags:
Last modified by Unknown User on 2020/10/14 09:55
Created by Administrator XWiki on 2020/07/29 13:51

Shortcuts

Powered by XWiki ©, EasyVista 2020