Example configuration Microsoft Power Automate to send a notification whenever an agent is in a reasoncode state for longer than x seconds

Introduction

This example shows you how you can use Microsoft Power AutomatePreviously named Microsoft Flow. to automatically send you a notification whenever the threshold for an agent to be on a specific reason code is met

Preview:

 

Configuration

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

  2. Click "My Flows":

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

  4. Type "Recurrence" and provide the recurrence rate in seconds.

    Note Microsoft Power Automate limits the recurrence rate to a minimum of 60 seconds

  5. Next you need to initialize 6 variables; to do so add an Action and type Initialize Variable. Repeat this step for each of the variables below.

    The first variable is created to store all the uris that have exceeded the KPI threshold. Name the variable, change the type to "String" and leave the value empty.

    The second variable is created to store the reasoncode name. Name the variable, change the type to "String" and enter the ReasonCode name.

    In the third variable you store the amount of seconds that the KPI needs to meet before sending the notification. Name the variable, change the type to "Integer" and enter an amount (in seconds).

    Because Microsoft Flow calculates time from an UTC 0 perspective, you need to correct the timestamps. This variable contains the total hours your timezone differs from UTC 0. This value can be negative. Name the variable, change the type to "Integer" and enter an amount (in hours).

    The fifth variable is created to calculate the time the flow is running in your timezone. Name the variable, change the type to "String" and enter:

     addHours(utcNow(),variables('HourCorrection'), 'yyyy-MM-dd hh:mm:ss') 

    The last variable is created to store the trigger time later in the flow. Name the variable, change the type to "String" and leave the value empty.

  6. Add an Action and type HTTP. This will create an API request, in which it will retrieve data from the Anywhere365 CoreThe Core is the center of Anywhere365. It manages all the Dialogues. API. As method select "GET" and for the URI fill in your Core API (http(s)://{fqdnA fully qualified domain name (FQDN), sometimes also referred as an absolute domain name, is a domain name that specifies its exact location in the tree hierarchy of the Domain Name System (DNS).}/dashboardservice/api/{uccname}/agent)

  7. Add an Action and select "Parse JSON". In the content slot select "Body" from the HTTP Output

    {

    "type": "array",

    "items": {

    "type": "object",

    "properties": {

    "SipAddress": {

    "type": "string"

    },

    "PresenceState": {

    "type": "integer"

    },

    "LastPresenceChange": {

    "type": "string"

    },

    "ReasonCode": {

    "type": "string"

    },

    "LastReasonCodeChange": {

    "type": "string"

    },

    "IsFormal": {

    "type": "boolean"

    }

    }

    }

    }

  8. Add an Action and type Apply to each and select "Body" from the parse JSON step in the Select an output from previous steps

  9. Add an Action and type Set Variable and select Variable 5.6. As value fill in:

    addSeconds(items('Apply_to_each')?['LastPresenceChange'], variables('NAME OF VARIABLE 5.2'), 'yyyy-MM-dd hh:mm:ss')  

    replace fill the name of variable 5.2 in the designated spot

  10. Add and Action and type Condition. For this condition you need to have 2 conditions in the "And" form

    First select variable 5.6. as operator select "is less or equal to"; select variable 5.5 to compare it too

  11. The following steps are added in the "If Yes" side of the condition action. There will be no actions for this flow under the "If No" side

    Add an Action and type "Compose". Under the expressions tab enter:

    concat(items('Apply_to_each')?['SipAddress'], ' is on ', variables('ReasonCodeValue'), ' longer than ', variables('Seconds On ReasonCode'), ' seconds')

  12. Add an Action and type "Compose". Under the "Dynamic Content " tab, select Output of the previous Compose action and the variable you created at "Step 5.1". Separate them with a line break.

  13. Add an Action and type "Set Variable ". Select the variable from the previous step (created at step 5.1) and under value select the output from the previous step

  14. Add an Action and type "Compose". As value, select the variable you created at step 5.1

  15. Outside the for each action, add and Action and type Condition. As first value type "not(empty(variables('Variable 5.1')))". as operator select "is not equal to". In the second field, under the expression tab, type "true" (without the "")

  16. Under the "if No" side, you need to add the final Action, which sends you a notification. You can either chose to send a notification or send out an email to specific email addresses. In this example we chose for an Outlook Email, as this allows for multiple supervisors addresses

    Hi,

    Currently one or more of your agents are on @{variables('5.2')} for more than your KPI value.

    These are the agents that have exceeded the threshold:

    @{variables('5.1')}

    Please advise your Anywhere365 Inflight Snapper or Inflight Wallboard for more information