Dialogue Cloud

Example configuration Microsoft Power Automate to categorize email subject based on Microsoft Azure Machine Learning Studio

Prerequisites

  • A Microsoft Azure Machine Learning Studio project, with web service

  • Azure Graph API, with the following permission:

    • Type = Application

    • Permissions = Mail.ReadWrite

Introduction

In this guide you will create a Microsoft Power Automate solution, in which you create a Flow that will set a category on an email based on the subject. This category can be used my the Anywhere365 Text handler to route the dialogue Learn More

Step 1: Create Outlook rule

The Anywhere365 automatically processes a new email as soon as it enters the Inbox. Because of this reason you first need to create an Outlook rule to move the email in a pre-process folder. Below on how to move all email to a folder. Of course you can create your own rules:

  1. Open Outlook (web) client.
  2. Open "Rules, Create New".

  1. Click "Advanced Options...".
  2. Click "Next".
  3. Check "Move it to specified folder".
  4. Select the folder where you want to move it to, for example "Pre-Process".
  5. Click "Finish".

Step 2: Create a Microsoft Flow

  1. From your Office Portal, go to your Power Automate App.

  2. Click "My Flow".

  3. Click "New" and "Create from Blank".

  4. Select connector "Office 365 Outlook, When a new email arrives".

    1. Select the folder you used for the pre-process.

  5. Add the step "Content Conversion, Html to text".

    1. Use "Body" as Content.

  6. Add the step "HTTP":

    1. Set "POST" as method.

    2. Add the Request URI of your model. (Found in WebService, REQUEST/RESPONSE API Help page).

    3. Add the following Header:

      1. Key = Authorization
      2. Value = Bearer [API Key]
    4. Add the following body:

      Note: Body can differ based on your model
      Copy
      JSON
      {
         "Inputs":{
            "input1":{
               "ColumnNames":[
                  "Description"
               ],
               "Values":[
                  [
                     "@{body('Html_to_text')}"
                  ]
               ]
            }
         },
         "GlobalParameters":{
            
         }
      }
  7. Create a new step "Data Operations, Parse JSON".

    1. Content:

      Copy
      Expression
      @{body('HTTP')}
    2. Schema = Use sample payload to generate schema

  8. Add the step "Initialize variable":

    1. Set "TopScoring" as name.

    2. Set "Sting" as Type.

    3. Set the following Value:

      Copy
      Expression
      first(body('Parse_JSON')?['Results']?['output1']?['value']?['Values'])
  9. Add the step "Initialize variable".

    1. Set "Intent" as name.

    2. Set "Sting" as Type.

    3. Set the following Value:

      Copy
      Expression
      replace(replace(split(variables('TopScoring'),',')[0],'"',''),'[','')
  10. Add the step "HTTP".

  11. Set "Patch" as method.

    1. Add the following uri:

      Copy
      Expression
      https://graph.microsoft.com/v1.0/users/[user id]/messages/[Message id]
    2. Add the following body:

      Copy
      Expression
      {
         "Categories":[
            "@{variables('Intent')}"
         ],
         "IsRead":true
      }
    3. Change Authentication to "Active Directory OAuth".

    4. Tenant = Directory (tenant) ID, found in the App Overview

    5. Audience = https://graph.microsoft.com

    6. Client ID = Application (client) ID, found in the App Overview

    7. Credential Type = "Secret"

    8. Secret = Secret, can be created in Azure under "Certificates & Secrets"

  12. Create a new step "Office 365 Outlook, Move Email":

    1. Set "Message id" as Message Id.

    2. Set "Inbox" as Folder.

Step 3: Make it smarter

When using Azure Machine Learning Studio your model is normally already based on a rich amount of data. This information can be expanded with more live data. Below an example on how to create more data.

  1. Make sure the intent out of Azure Machine Learning Studio matches the Skill Name.

  2. Add 2 Classifications:

    1. Intent Correct

    2. Intent Incorrect

  3. Create a sub option on the incorrect intent options with all the possible intents.

    During the conversation the Agent classify if the intent is correct or else provide the correct intent.

  4. This information can be exported and imported to further train your model.