Microsoft Power Automate: Trigger and Integrate a Flow

Microsoft_Power_Automate_Image_Signed_In.png

Image: Microsoft Poawer Automate UI

Cognigy.AI allows you to easily integrate a flow from Microsoft Power Automate. This tutorial will take you through the steps necessary to trigger your Microsoft Power Automate flow in your Cognigy.AI virtual agent as well as receive information back from your flow. 

 


Table of Contents

  1. Install the Microsoft Power Automate Extension
  2. Connect to a Microsoft Power Automate Flow
  3. Receive Information from Microsoft Power Automate Flow

Install the Microsoft Power Automate Extension

The first step is to install the required integration. In this case, a so-called Extension is installed to Cognigy.AI. Thus, navigate to the Extensions Marketplace inside of the Virtual Agent and add the Microsoft Power Automate Extension by clicking on the Install button. Now follow this installation guide and upload the Extension to Cognigy, where it will be displayed as the following:

 

Congrats! The installation of the Extension is finished!

Connect to Microsoft Power Automate Flow

 

Microsoft_Power_Automate_Extension_in_Cognigy.png

Figure 1: Microsoft Power Automate extension after Upload

After uploading the extension to your Agent you can immediately add it to the flow. To do this: 

  1. Create a new Flow in Cognigy.AI
  2. In the Flow Chart, click on + and navigate to the Microsoft Power Automate Extension:

    Microsoft_Power_Automate_Add_Node_To_Cognigy.png

  3. Now click on Start Flow, to add it to the flow:

    Microsoft_Power_Automate_Start_Flow_Node_In_Cognigy.png

  4. In order to edit the Flow Node click on it. An Edit Node menu will be opened on the right side of the screen:
    Microsoft_Power_Automate_Edit_Node_In_Cognigy.png

  5. Now you need to add the HTML of your Power Automate flow, which can be found by doing the following. 
    1. Create a new flow and choose as the trigger When an HTTP request is receivedMicrosoft_Power_Automate_Find_Trigger_Cognigy.png
    2. You may add a JSON Schema for your request to the trigger you added. This will allow you to add information like your session ID and the current user in order to return information to your flow via the Cognigy API inject functionality. In this example along with the session information we are also sending an Image URL as data, this will be explained later in this article. 
      If you only wish to trigger a Microsoft Power Automate Flow but do not wish to send or receive data this Schema is not necessary. 
      {
          "type""object",
          "properties": {
              "userId": {
                  "type""string"
             },
              "sessionId": {
                  "type""string"
             },
              "URLToken": {
                  "type""string"
             },
              "callbackURL": {
                  "type""string"
             },
              "text": {
                  "type""string"
             },
              "data": {
                  "type""object",
                  "properties": {
                      "imageURL": {
                          "type""string"
                     }
                 }
             }
         }
      }
    3. After adding other steps to your automation and saving your flow a URL is created in your trigger. 
      Microsoft_Power_Automate_Find_URL_Cognigy.png
    4. Copy this URL and add it to your flow: Microsoft_Power_Automate_Flow_URL_In_Cognigy.png
    5. Choose the method "POST" and save the node. Now when this node is reached in your conversation the flow will start.  

Receive Information from Microsoft Power Automate Flow

If you wish for the Microsoft Power Automate flow to send information back to your agent you will need to first send it the appropriate information and also set up the your Power Automate Flow to send the information back. 

There are two ways to do this. Either you can add a custom JSON or you can use the "Use Callback" function. In this article we will explain how to do this via Use Callback. 

 

  1. To activate the Callback fields click "Use Callback" in the Microsoft Power Automate Node.
    Microsoft_Power_Automate_Use_Callback_In_Cognigy.png
  2. New sections will appear under the switch which will be used to configure the callback. Microsoft_Power_Automate_Callback_Sections_Cognigy.png
  3. In the section Callback Config you can add the information you wish to send back to your Cognigy Agent. 
    1. URL is the URL of the function from the Cognigy.AI REST API you wish to use to inject information into the Agent. In the example below we have set up an input inject, however other methods are available. 
    2. Token is the URL token for the webchat being used. This is not required for all channels (for example if you were to use a context inject instead) but if you are using our webchat or integrating with Microsoft Teams it will be required. 
    3. User ID and Session ID already have the correct standard value in the fields, but these can be replaced. This is the information regarding the currently active user and session which allows the context inject to identify the proper active chat the information should be sent back to.
      Microsoft_Power_Automate_Callback_Config_Cognigy.png
  4. The section Callback Payload is used to add any additional information to the information required for the inject. 
    1. Text can be used, for example, to send the last user input to Microsoft Power Automate. 
    2. Data can be used to send any addition information which you wish to send to Microsoft Power Automate. In this example we are sending an image URL added via the File Upload Extension as data to the Power Automate flow. Keep in mind that depending on the data you send you will need to adjust the JSON Schema in your Power Automate trigger accordingly. 
      Microsoft_Power_Automate_Callback_Payload_Cognigy.png
  5. In the Cognigy.Ai Flow after Start Power Automate node and before the Say node with the information you receive, you should add a Wait for Input node. This tells the flow that it should expect an input. In this case the input is coming from the input inject via our API.
    Microsoft_Power_Automate_Wait_For_Input_Node_Cognigy.png
  6. You will now need to add the information in the Microsoft Power Automate flow in order to send the information back to Cognigy after your automation has finished. 
    1. In this example we added two additional steps to the flow. One downloads the image URL sent by the Cognigy flow and the other analyzes this image using the native business card recognition AI from Power Automate.
      Microsoft_Power_Automate_URL_Download_And_Business_Card_Steps_Cognigy.png

    2. After these steps click on the in Power Automate to add a step and choose HTTP.
      Microsoft_Power_Automate_Add_HTTP_To_Flow_Cognigy.png
       
    3. In the HTTP step you can use Dynamic Content created using the JSON Schema in the HTTP trigger as well as your flow to add the relevant information to your API call. 
      Microsoft_Power_Automate_Add_HTTP_Dynamic_Content_Cognigy.png
{
"userId": "",
"text": "",
"data": {
"fullName": "",
"fullAddress": "",
},
"URLToken": "",
"sessionId": ""
}

The information in data can be changed based on the use case.

Now a flow in Microsoft Power Automate can be triggered and information from this flow can be injected into the active conversation: 

Microsoft_Power_Automate_Callback_In_Webchat_Cognigy.png

 


Comments

0 comments

Please sign in to leave a comment.

Was this article helpful?
1 out of 1 found this helpful