WhatsApp to Service Manager Integration (via MS Power Automate)

Last modified on 2023/05/22 17:26

From:  Facebook Graph API versions 13 and later

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

  To help you set up this integration, you can download the pre-configured flows. Open url.png See the List of files to download

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 use Microsoft Power Automate to create a ticket in Service Manager when a WhatsApp message is sent to the dedicated phone number of the EasyVista Support team.

  • The sender of the message will automatically be loaded in the Recipient field.
  • The ticket title will be Ticket Created from WhatsApp.
  • The text of the message will be loaded to the Description field.

Note: To run the ticket creation process, the text of the message must include the keywords Create and Ticket. Customers can customize the choice of keywords.
 

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

Logo - WhatsApp.png

Down arrow.png

Logo Icon - Microsoft Flow.png

Down arrow.png

Favicon EasyVista - 32.png Service Manager

  • Depending on the third-party service used (authentication managed by Logic Apps)
  • Basic Authentication for the REST API 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

    (Trigger Service Manager => 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 flow

An MS Power Automate flow will create the ticket in Service Manager when a WhatsApp message is received by the EasyVista Support team.

          Data feed diagram - EN.png

Prerequisites

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

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

Best Practice

  • You can modify the keywords Create and Ticket that are searched for by default in the WhatsApp message in step 3 of the MS Power Automate flow.
    • You must not use any accented characters.
    • You can use upper and lower case letters.

Step-by-Step Integration Process

When a WhatsApp message is received, a ticket is created in Service Manager, using Microsoft Power Automate in two phases:

Microsoft Azure Logic Apps: Create the flow

Description of the Create a ticket in Service Manager workflow

Azure flow description.png
  • Step 1 : Create the step that will trigger the flow
  • Step 2 : Break down the WhatsApp message
  • Step 3 : Search for keywords Create and Ticket
  • Step 4 : Create a ticket in Service Manager
  • Step 5 : Save the configuration of the workflow

Best Practice icon.png  Download the file below containing the pre-configured flow. Once you have imported it to Microsoft Azure Logic Apps, you can adapt it to your requirements using the procedure below. This procedure describes all of the steps for creating the workflow.

  Flow Create a ticket in Service Manager


Step 1: Create the step that will trigger the flow

==> The flow is triggered when a WhatsApp message is sent to the dedicated phone number of the EasyVista Support team.

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 Do not specify any information.

4. Create a JSON Analysis action to retrieve information on the WhatsApp message.

Microsoft Power Automate - Action - Parse JSON.png
  • Rename it Parse JSON HTTP Receive using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Contents: Select the dynamic value called Body from the When a HTTP request is received step.
    • Schema: Copy and paste the JSON schema below.

      {
         "type": "object",
         "properties": {
             "messaging_product": {
                 "type": "string"
              },
             "to": {
                 "type": "string"
              },
             "text": {
                 "type": "object",
                 "properties": {
                     "body": {
                         "type": "string"
                      }
                  }
              }
          }
      }


Step 2: Break down the body properties containing the WhatsApp message

1. Define the following Compose actions in the order listed below to break down the contents of the message.

Microsoft Power Automate - Action - Compose.png
Compose 1:
  • Rename the action Compose Body using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Inputs: Enter the instruction below.
      string(body('Parse_JSON_HTTP_Receive')?['text'])
Compose 2:
  • 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(outputs('Compose_Body'),'{"body":"Ack: ','')
Compose 3:
  • Rename the action Compose Remove 2 using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Inputs: Enter the instruction below.
      replace(outputs('Compose_Remove'),'"}','')
Compose 4:
  • Rename the action Compose UPPER using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Inputs: Enter the instruction below.
      toUpper(outputs('Compose_Remove_2'))


Step 3: Search for keywords in the WhatsApp message

          Flow - Condition Yes.png

1. Create a Condition action to check the presence of the keywords Create and Ticket.

Action Azure - Analyze WhatsApp message - Line condition.png
  • Add the following lines to the condition by selecting the And operator and clicking Add.
Value tested Condition line
Presence of the keyword Create
  • Select Value: Enter the instruction below.
    @outputs('Compose_UPPER')
  • Comparator: Select the contains value.
  • Value: Select the CREATE value.
Presence of the keyword Ticket
  • Select Value: Enter the instruction below.
    @outputs('Compose_UPPER')
  • Comparator: Select the contains value.
  • Value: Select the TICKET value.

2. Define the actions to be performed when the WhatsApp message contains the keywords Create and Ticket.

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

3. Create a HTTP action to create the ticket in Service Manager.

Flow - Condition create ticket - HTTP Post.png
  • Rename it HTTP Create a Ticket using Browse black points icon.png in the title bar.
  • Specify the information on the action.
    • Method: Enter the POST value.
    • URI: Enter your Service Manager.
    • Body: Copy and paste the JSON schema below.
      [ { "Catalog_Code": "44", "Origin": "3", "Title": "Ticket Created from WhatsApp", "Description": "@{outputs('Compose_Remove_2')}" } ]

Note:

  • The fields you can use are those described in the Create a ticket method of the Service Manager REST API. The catalog code is a mandatory field.
  • You can modify the values used in this example.
    • Catalog code 44: Workstations
    • Origin code 3: Phone


Step 4: Save the configuration of the workflow

1. Click Save at the bottom of the flow.

          Azure flow - Save configuration.png

Service Manager: Use a resource dedicated to integration in the REST step of a process

  • You must create a dedicated WhatsApp to Service Manager resource.
  • It must be associated with a service and a Microsoft Power Automate connection pointing to the MS Power Automate flow created in phase 1.
  • You can then use the new resource in the REST step of a process.
  • It enables you to run the MS Power Automate flow that will analyze the WhatsApp message and create a ticket in Service Manager.
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 WhatsApp to Service Manager 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 WhatsApp to Service Manager.
  • 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 WhatsApp to Service Manager.
  • 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.

Caution: 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 WhatsApp to Service Manager 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 WhatsApp to Service Manager 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.

          New REST action in workflow - Properties.png

4. Click Confirm Changes.

Verification and test

1. Log in to your WhatsApp account and send a message to the dedicated phone number of the EasyVista Support team.

  • Enter the keywords required to start the ticket creation process which, by default, are Create and Ticket.

          WhatsApp - Send message.png

2. Check that the ticket is created in Service Manager by selecting Service Operation > Incidents > All Incidents in the menu.

3. Check that the ticket is correctly loaded with the information from the WhatsApp message.

  • The sender of the message will automatically be loaded in the Recipient field.
  • The ticket title will be Ticket Created from WhatsApp.
  • The text of the message will be loaded to the Description field.

          Service Manager - View ticket.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