Dialogue Cloud

Example configuration Microsoft Power Automate to categorize email subject based on Microsoft Dynamics 365

Prerequisites

  • 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 contact information in Dynamics 365 (in this example Account Relation Status), Learn More

Step 1: Create Outlook rule

The AnywhereNow 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 Power Automate Flow

  1. Navigate to Microsoft Power Automate.

  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 "Dynamics 365, List records":

    1. Organization Name = Connect to your organization tenant

    2. Entity Name = Contacts

    3. Filter Query = emailaddress1 eq '@{triggerBody()?['from']}'

  6. Add the step "Initialize variable":

    1. Name = Company

    2. Type = String

    3. Value:

      Copy
      Expression
      first(body('List_records')?['value'])?['_parentcustomerid_value']
  7. Add the step "Dynamics 365, Get record".

    1. Organization Name = Connect to your organization tenant

    2. Entity Name = Accounts

    3. Item identifier:

      Copy
      Expression
      @{variables('Company')}
  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 "HTTP".

    1. Set "Patch" as method.

    2. Add the following uri:

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

      Copy
      Expression
      {
         "Categories":[
            "@{body('Get_record')?['_wsp_relationstatus_label']}"
         ],
         "IsRead":true
      }
    4. Change Authentication to "Active Directory OAuth".

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

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

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

    8. Credential Type = "Secret"

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

  10. Create a new step "Data Operations, Parse JSON".

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

    1. Set "Message id" as Message Id.

    2. Set "Inbox" as Folder.