Please note: at the time of this publishing you can not reference a Flow from PowerApps in a solution....but this should be resolved soon!
The steps:
- Login to PowerApps
-
Navigate to Solutions
- Create a new Solution
- Open your Solution
- Add a new Flow
- Set the trigger to PowerApps. Note I also named the flow at this step: “Sentiment from PowerApps”
-
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!!!!!!!!!!
-
Set the model to “SentimentAnalysis Model”
Note: the other AI Builder Models I had created and available to the Flow
-
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-analysis (watch those evil smart quotes!)
- en
- fr
- it
- ja
- zh-Hans
- zh-Hant
- Replace the “My Text” argument with Ask in PowerApps by clicking the “Ask in PowerApps” shape in the bottom of the action
- Replace the “My Language” argument with Ask in PowerApps by clicking the “Ask in PowerApps” shape in the bottom of the action
- Add a new Step and add the Parse JSON action
- Specify the content as the Response Payload. Specify the schema as the JSON below.
JSON for the Schema:
(Also can be found here: https://docs.microsoft.com/en-us/ai-builder/flow-sentiment-analysis)
{
“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”: {}
}
}
- Add a PowerApps Response Action to the Flow
- Set the PowerApps Response to return an output a text value that is documentsentiment object from the parse JSON action.
- Save flow
- Go back to Solutions
- Add a new Canvas App. ( in this is a Phone form factor…but it isn’t really that important)
- Add a button and a Text Input and a button control
-
Add a label control and set the text equal to mysentiment.sentiment
PowerApps will complain about this…ignore for the time now.
- 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)
- And here it is running!
Note the AI action gives many sentiment heuristics such as the scores for each sentiment type