Service Manager to WhatsApp Integration (via MS Power Automate)

Last modified on 2023/11/17 18:46

Facebook Graph API: 13+

   Microsoft Azure is constantly evolving. As such, some of the screens shown in the procedures below may be different from the ones in the final interface.

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

WhatsApp is an instant messaging app for smartphones and tablets.

This integration enables you to send a WhatsApp message to the recipient of a change request via Microsoft Power Automate after accepting or rejecting the change request.
 

Preview of the tools used in this integration

IntegrationTool_MicrosoftAzureLogicApps
  • Microsoft Azure Logic Apps: It enables you to create logic apps that run workflows and provide access to cloud data and services using ready-to-use connectors.
IntegrationTool_MicrosoftPowerAutomate
  • Microsoft Power Automate (formerly known as Microsoft Flow): It 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.
Integration Data Feed (direction) Authentication Type Integration Connector Options

Favicon EasyVista - 32.png Service Manager

Down arrow.png

Logo Icon - Microsoft Flow.png

Down arrow.png

Logo - WhatsApp.png

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

    EV Integration connector icon - Workflow.png    Workflow

    EV Integration connector icon - Business rule.png    Business rule

  • MS Power Automate :

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

    (Service Manager trigger => Logic Apps)

Available versions
SaaS On-premises
Service Manager Check icon.png Check icon.png
Third-party product Check icon.png N/A

Microsoft Power Automate flows

The integration between Service Manager and WhatsApp will trigger two separate flows in Microsoft Power Automate when the status of a Service Manager change request is changed.

MS Power Automate flow 1: Change request acceptedService Manager MS Power Automate flow 2: Change request rejected Service Manager
Data feed diagram 1 - EN.png Data feed diagram 2 - EN.png

Prerequisites

Best Practice

  • The integration describes the process for change requests. You can adapt it to send a WhatsApp message for approving incidents using the resource dedicated to integration in the REST step of an incident process. Open url.png See Service Manager phase > step 3

Caution

Caution_TitleActionInPowerAutomateFlow
  • When you create workflow actions in Microsoft Power Automate, you must rename them as indicated in the procedure. This is because certain items of information in the name refer to the title of the action. If you do not respect the naming convention, the workflow will not be triggered correctly.

example  The split(body('Analyze_Ticket_Info')'')?['AVAILABLE_FIELD_6'],',') instruction refers to the action called Analyze Ticket Info

   Spaces in the title will automatically be replaced by the underscore _.

Integration process

In Azure DevOps

1. Create the MS Power Automate flows.

     Open url.png See the step-by-step integration process.

Best Practice icon.png  Import the preconfigured flows below containing all of the steps to MS Power Automate.

   Flow Change request accepted
   Flow Change request rejected

In Service Manager

2. Create a dedicated resource called Service Manager to WhatsApp used in a REST step of a process. Open url.png See the detailed procedure.

Step-by-Step Integration Process

Microsoft Azure Logic Apps: Create flow 1 Change request accepted

Description of the Change request accepted flow

Azure flow description - Flow 1.png
  • Step 1 : Create the step that will trigger the flow
  • Step 2 : Configure the WhatsApp URL to be called
  • Step 3 : Send a WhatsApp message when the request is accepted in Service Manager
  • Step 4 : Send a WhatsApp message when the request is closed in Service Manager
  • Step 5 : Save the configuration of the workflow

Best Practice icon.png  Import the preconfigured flow below containing all of the steps to MS Power Automate.

   Flow Change request accepted


Step 1: Create the step that will trigger the flow

==> The workflow is triggered when a change request is accepted in Service Manager.

1. Log in to the Azure portal using your Azure account.

2. Create a new logic app. Open the Logic App Designer.
      Open url.png See Microsoft Azure Logic Apps integration for details on the procedure

3. Create a When a HTTP request is received step that will trigger the workflow.

Microsoft Power Automate - Trigger - When a http request is received.png
  • Specify the information on the trigger.
    • Body: Copy and paste the JSON schema below.

      {
         "type": "object",
         "properties": {
             "Description": {
                 "type": "string"
              },
             "id": {
                 "type": "string"
              },
             "Host": {
                 "type": "string"
              },
             "URL": {
                 "type": "string"
              },
             "Account": {
                 "type": "string"
              },
             "Title": {
                 "type": "string"
              },
             "Telephone": {
                 "type": "string"
              },
             "Type": {
                 "type": "string"
              }
          }
      }
    • Method: Select the POST value.
  • Save the trigger.

    The following information will be retrieved from Service Manager: Ticket description, ticket ID, Host, Account, URL, ticket title, recipient's phone number, status of the ticket stored in the Type variable.


Step 2: Configure the WhatsApp URL to be called

1. Define the following variables by creating Initialize variable actions in the order listed below.

Microsoft Power Automate - Action - Initialize variable.png
Variable 1:
  • Rename the action Initialize variable Version using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter Version.
    • Type: Select the String value.
    • Value: Specify the version of the Facebook Graph API used by WhatsApp.

Caution: The Facebook Graph API version must be version 13 or later.

Variable 2:
  • Rename the action Initialize variable Phone-Number-ID using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter Phone-Number-ID.
    • Type: Select the String value.
    • Value: Specify the WhatsApp sender's phone number ID.

  Contact your administrator to obtain the ID.

Variable 3:
  • Rename the action Initialize variable Bearer Token using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter Bearer Token.
    • Type: Select the String value.
    • Value: Specify the Bearer Token for accessing your WhatsApp account.

2. Create a Compose action to remove the + character from the recipient's phone number.

Microsoft Power Automate - Action - Compose.png
Compose 1:
  • Rename the action Compose Remove + using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Inputs: Enter the instruction below.
      replace(triggerBody()?['Telephone'],'+','')


Step 3: Send a WhatsApp message when the request is accepted in Service Manager

          Flow 1 - Condition Yes.png

1. Create a Condition action to check for changes to the status of the request.

Flow 1 - Condition Accept request - Line condition.png
  • Rename it Condition using Browse black points icon.png in the title bar.
  • Click Add to add the following line to the condition.
Value tested Condition line
Status changed
  • Select Value: Select the Type field to return the status of the request.
  • Comparator: Select is equal to.
  • Value: Enter {Implementation}.

    Replace {Implementation} with the value corresponding to the Accepted status in your repository.

example Accepted, Validated, Approved ==> The value corresponds to the  Completed meta-status

2. Define the actions to be performed when the status of the request is equal to {Implementation} (Example: Accepted - condition satisfied).

  • Go to the If Yes branch.
  • Select Add an action to add the following actions.

3. Create a HTTP action to notify that the change request is accepted.

Flow 1 - Condition Accept request - HTTP Post.png
  • Rename it HTTP currently in progress using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Method: Enter the POST value.
    • URI: Enter the following expression.
      concat('https://graph.facebook.com/',variables('Version'),'/',variables('Phone-Number-ID'),'/messages')
    • Headers:
      • Enter the Bearer value.
      • Enter the following expression.
        Bearer @{variables('Bearer Token')}
    • Body: Copy and paste the JSON schema below.
      { "messaging_product": "whatsapp", "preview_url": false, "recipient_type": "individual", "to": "@{outputs('Compose_Remove_+')}", "type": "text", "text": { "body": "Your request no. @{triggerBody()?['id']} has been validated, it is being processed" } }


Step 4: Send a WhatsApp message when the request is closed in Service Manager

Note: The workflow will automatically close the request once it is accepted.

          Flow 1 - Condition No.png

1. Define the actions to be performed when the status of the request is not equal to {Implementation} (Example: Closed - condition is not satisfied).

  • Go to the If No branch.
  • Select Add an action to add the following actions.

2. Create a HTTP action to notify that the change request is closed.

Flow 1 - Condition Close request - HTTP Post.png
  • Rename it HTTP end using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Method: Enter the POST value.
    • URI: Enter the following expression.
      concat('https://graph.facebook.com/',variables('Version'),'/',variables('Phone-Number-ID'),'/messages')
    • Headers:
      • Enter the Bearer value.
      • Enter the following expression.
        Bearer @{variables('Bearer Token')}
    • Body: Copy and paste the JSON schema below.
      { "messaging_product": "whatsapp", "preview_url": false, "recipient_type": "individual", "to": "@{outputs('Compose_Remove_+')}", "type": "text", "text": { "body": "Your request no. @{triggerBody()?['id']} has been closed" }


Step 5: Save the configuration of the workflow

1. Click Save at the bottom of the flow.

          Azure flow 1 - Save configuration.png

Microsoft Azure Logic Apps: Create flow 2 Change request rejected

Description of the Change request rejected flow

Azure flow description - Flow 2.png
  • Step 1: Create the step that will trigger the flow
  • Step 2: Configure the WhatsApp URL to be called
  • Step 3: Send a WhatsApp message when the request is rejected in Service Manager
  • Step 4: Save the configuration of the workflow

Best Practice icon.png  Import the preconfigured flow below containing all of the steps to MS Power Automate.

   Flow Change request rejected


Step 1: Create the step that will trigger the flow

==> The workflow is triggered when a change request is rejected in Service Manager.

1. Log in to the Azure portal using your Azure account.

2. Create a new logic app. Open the Logic App Designer.
      Open url.png See Microsoft Azure Logic Apps integration for details on the procedure

3. Create a When a HTTP request is received step that will trigger the workflow.

Microsoft Power Automate - Trigger - When a http request is received.png
  • Specify the information on the trigger.
    • Body: Copy and paste the JSON schema below.

      Display the JSON schema

      {
         "type": "object",
         "properties": {
             "Description": {
                 "type": "string"
              },
             "id": {
                 "type": "string"
              },
             "Host": {
                 "type": "string"
              },
             "URL": {
                 "type": "string"
              },
             "Account": {
                 "type": "string"
              },
             "Title": {
                 "type": "string"
              },
             "Telephone": {
                 "type": "string"
              },
             "Type": {
                 "type": "string"
              }
          }
      }
    • Method: Select the POST value.
  • Save the trigger.

    The following information will be retrieved from Service Manager: Ticket description, ticket ID, Host, Account, URL, ticket title, recipient's phone number, status of the ticket stored in the Type variable.


Step 2: Configure the WhatsApp URL to be called

1. Define the following variables by creating Initialize variable actions in the order listed below.

Microsoft Power Automate - Action - Initialize variable.png
Variable 1:
  • Rename the action Initialize variable Version using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter Version.
    • Type: Select the String value.
    • Value: Specify the WhatsApp version used.

Caution: The Facebook Graph API version must be version 13 or later.

Variable 2:
  • Rename the action Initialize variable Phone-Number-ID using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter Phone-Number-ID.
    • Type: Select the String value.
    • Value: Specify the WhatsApp sender's phone number ID.

  Contact your administrator to obtain the ID.

Variable 3:
  • Rename the action Initialize variable Bearer Token using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Name: Enter Bearer Token.
    • Type: Select the String value.
    • Value: Specify the Bearer Token for accessing your WhatsApp account.

2. Create a Compose action to remove the + character from the recipient's phone number.

Microsoft Power Automate - Action - Compose.png
Compose 1:
  • Rename the action Compose Remove + using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Inputs: Enter the instruction below.
      replace(triggerBody()?['Telephone'],'+','')


Step 3: Send a WhatsApp message when the request is rejected in Service Manager

1. Create a HTTP action to notify that the change request is rejected.

Flow 2 - Condition Reject request - HTTP Post.png
  • Rename it HTTP end using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Method: Enter the POST value.
    • URI: Enter the following expression.
      concat('https://graph.facebook.com/',variables('Version'),'/',variables('Phone-Number-ID'),'/messages')
    • Headers:
      • Enter the Bearer value.
      • Enter the following expression.
        Bearer @{variables('Bearer Token')}
    • Body: Copy and paste the JSON schema below.
      { "messaging_product": "whatsapp", "preview_url": false, "recipient_type": "individual", "to": "@{outputs('Compose_Remove_+')}", "type": "text", "text": { "body": "Your request no. @{triggerBody()?['id']} has been denied" }


Step 4: Save the configuration of the workflow

1. Click Save at the bottom of the flow.

          Azure flow 2 - Save configuration.png

Service Manager: Create a dedicated resource used in a REST step of a process

Notes:

  • The dedicated resource called Service Manager to WhatsApp will enable you to send a WhatsApp message when the change request is approved or rejected in Service Manager and when it is closed.
  • It is associated with a Microsoft Power Automate service.
  • It is used in a Service Manager process using a REST action type.
CreateInServiceManagerRestResource_Procedure

Step 1: Manage rights for using the Service Manager REST API

1. Select Administration > Access Management > User Profiles in the menu.

2. Select a user profile authorized to use the Service Manager REST API.

3. Tick the REST API box.

Your changes will automatically be saved.

4. Repeat the procedure for all authorized profiles.

Step 2: Create a resource called Service Manager to WhatsApp associated with a Microsoft Power Automate service

        Open url.png See the detailed procedure.

Step 2.a: Create a service called Microsoft Power Automate

1. Select Administration > REST > Services in the menu.

2. Create a new service.

          New REST service - None authentication.png

3. Specify the information below.

  • Service Name: Enter the label Microsoft Power Automate.
  • Authentication Method: None.
  • Service URL: URL for accessing the new Microsoft Power Automate service.
    • Copy and paste the URL you stored in your text editor when creating the MS Power Automate flow (step that will trigger the flow).
    • You should keep only the text displayed in yellow below.

      https://prod-35.westeurope.logic.azure.com:443/workflows/?????/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=??????

    • Replace prod-35.westeurope with {subdomain}.
       

Step 2.b: Create a connection to the Microsoft Power Automate service.

1. Create a new connection.

          New REST connection - None authentication.png

2. Specify the information below.

  • Connection Name: Enter the label Service Manager to WhatsApp.
  • Authentication Method: None.
  • Service Name: Select the Microsoft Power Automate service you created at step 2.a.
    The URL of the service will automatically appear.
  • subdomain: Copy and paste the prod-35.westeurope value of the URL you stored in your text editor.
     

Step 2.c: Create a resource associated with the Microsoft Power Automate service

1. Create a new resource.

          New REST resource - None authentication.png

2. Specify the information below.

  • Label: Enter the label Service Manager to WhatsApp.
  • Resource URI: ID of the new resource.
    • Copy and paste the URL you stored in your text editor when creating the MS Power Automate flow (step that will trigger the flow).
    • You should keep only the text displayed in yellow below.

      https://prod-35.westeurope.logic.azure.com:443/workflows/?????/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=??????

  • Contents: Body of the query containing the data to be updated. Copy and paste the text below without inserting any spaces or line breaks.

   If you paste a JSON schema copied from a third-party editor such as Microsoft Word or Notepad++, invisible characters may be inserted. This will create an error in the processing of the REST step using the resource.

{"Description": "{Description}","id":"{id}"}

Step 3: Use the Service Manager to WhatsApp resource in a REST step of a process

1. Open the workflow or the business rule-related process you want.

  • Workflow: References > Other References > Workflows (Operation/Transition)
  • Business rule: Administration > Business Rules > Related Processes

2. Click and drag the new Service Manager to WhatsApp resource from the REST Actions category of the palette of action types to the graphic editor of the process.

A new step will be added to the process.

          New REST action in workflow - Add in GUI.png

3. Double-click to define the properties of the new step.

     Open url.png See the description

          New REST action in workflow - Properties.png

4. Click Confirm Changes.

Verification and test

1. Create a change request in Service Manager, managed by the workflow using the Service Manager to WhatsApp resource.

2. Accept the request and check that the recipient of the change request has correctly received the WhatsApp message, Your request no. XXX has been validated.

          Service Manager - Accept change request.png
       WhatsApp - Accept change request.png

3. Reject the request and check that the recipient of the change request has correctly received the WhatsApp message, Your request no. XXX has been denied.

          Service Manager - Reject change request.png
       WhatsApp - Reject change request.png

List of files to download

Note: To find out how to install them, see the integration process.

Links to other integrations

Tags:
Powered by XWiki © EasyVista 2022