Using the Sentiment Analysis Action from PowerApps

 

AI Builder has some amazing features. This walk through will get you started with using their sentiment analysis from PowerApps

  1. Login to PowerApps


  1. Navigate to Solutions

     


 

  1. Create a new Solution

  1. Open your Solution

  1. Add a new Flow

  1. Set the trigger to PowerApps. Note I also named the flow at this step: “Sentiment from PowerApps”

  1. Add the “Predict” action to the Flow.

    Note: if you don’t see the “Predict” action, you are likely NOT in a solution. NOTE this is required!!!!!!!!!!

  1. Set the model to “SentimentAnalysis Model”

    Note: the other AI Builder Models I had created and available to the Flow

  1. Insert the following Text into the Request Payload

    {“text”:”My Text”, “language”:”My Language”}

     

    This from https://docs.microsoft.com/en-us/ai-builder/flow-sentiment-analysisc (watch those evil smart quotes!)

     

 

 

  1. Replace the “My Text” argument with Ask in PowerApps by clicking the “Ask in PowerApps” shape in the bottom of the action

  1. Replace the “My Language” argument with Ask in PowerApps by clicking the “Ask in PowerApps” shape in the bottom of the action

 

  1. Add a new Step and add the Parse JSON action

  1. Specify the content as the Response Payload. Specify the schema as the JSON below.

JSON for the Schema:

 

 

{

“type”: “object”,

“properties”: {

“predictionOutput”: {

“type”: “object”,

“properties”: {

“result”: {

“type”: “object”,

“properties”: {

“sentiment”: {

“type”: “string”,

“title”: “documentSentiment”

},

“documentScores”: {

“type”: “object”,

“properties”: {

“positive”: {

“type”: “number”

},

“neutral”: {

“type”: “number”

},

“negative”: {

“type”: “number”

}

}

},

“sentences”: {

“type”: “array”,

“items”: {

“type”: “object”,

“properties”: {

“sentiment”: {

“type”: “string”

},

“sentenceScores”: {

“type”: “object”,

“properties”: {

“positive”: {

“type”: “number”

},

“neutral”: {

“type”: “number”

},

“negative”: {

“type”: “number”

}

}

},

“offset”: {

“type”: “integer”

},

“length”: {

“type”: “integer”

}

},

“required”: [

“sentiment”,

“sentenceScores”,

“offset”,

“length”

]

}

}

}

}

}

},

“operationStatus”: {

“type”: “string”

},

“error”: {}

}

}

  1. Add a PowerApps Response Action to the Flow

  1. Set the PowerApps Response to return an output a text value that is documentsentiment object from the parse JSON action.

  1. Save flow
  2. Go back to Solutions

  1. Add a new Canvas App. ( in this is a Phone form factor…but it isn’t really that important)

  1. Add a button and a Text Input and a button control

 

  1. Add a label control and set the text equal to mysentiment.sentiment

    PowerApps will complain about this…ignore for the time now.

  1. Select the button you added above and select the menu “Actions”, select Flows then select the Flow you created above.

NOTE: This is currently not working as Flows can not be referenced from a PowerApps in a Solution.

It is working in our staging environment and should be working soon! (Where the screen shots were taken)

  1. And here it is running!

Note the AI action gives many sentiment heuristics such as the scores for each sentiment type

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s