Home Power PlatformsAI Builder Intelligent AI Builder Sentiment analysis in Power Apps – Canvas app

Intelligent AI Builder Sentiment analysis in Power Apps – Canvas app

by Mo Faheem
AI Builder Sentiment Analysis

With the rising of Big Data, the need for AI Builder sentiment analysis in Power Apps is essential to understand client behaviour and engage in building a better Customer Experience (CX).

PowerPlatforms provide a number of AI models to facilitate building intelligent business apps. Read more about PowerPlatform AI Builder models.

AI Builder Sentiment Analysis in Power Apps

PowerPlatforms provides a premium prebuilt AI Builder sentiment analysis that is trained and tested for common business use, out of which Sentiment analysis is using Natural language processing (NLP). For more information about the sentiment analysis model.

Availability Canvas App

The AI Builder models are available to be used in Power Automate and Power Apps in Canvas App. Sentiment analysis is available under the prebuilt Models.

In this post, we will discuss how to use a Sentiment Analysis in Power Apps.

ai builder sentiment analysis in power apps

AnalyzeSentiment function inputs and ourputs

Input

The input for the model is simply text or a pargraph that needs to be submited to the AI model to get processed.

Output

  • Sentiment – the overall sentiment analysis.
  • Sentences – each sentence in the text score. This variable equires gallery to present the values.

Create AI Builder Sentiment Analysis in Power Apps

We will create a new screan in Power Apps Canvas app, then we will include a the following elements.

  1. Text Input (Multiline field) – Text input will be used for the text that will be analysed.
  2. Button to run the analysis.
  3. Icon to indicate the overall sentiment analysis.
  4. Gallery to present the sentiment analysis of each sentence of the given text.
Canvas app

1. Text input

Add a text input and set it to multiline and name it. In Our example, we set the text input to “SentimentFiled“. The text input value will be executed by the function “AnalyzeSentiment

canvas app add input text

2. Execute the analysis

Add a botton adn set the OnSelect to the code, as shown.

Set(sentimentOutput,AIBuilder.AnalyzeSentiment(SentimentField.Text));

The script will set the variable “sentimentOutput” with the output of the function “AnalyzeSentiment

Sentiment output AnalyzeSentiment

3. Show the overall analysis

The overall analysis has one result value that indicates the sentiment analysis. In addition to this value, there is a score of a value of 0 to 1 to indicate the likelihood of the result.

We can show the overall sentiment analysis result using the sentiment action. In our example the script is “sentimentOutput.sentiment”

{ControlName}.sentiment

Sentiment values

The sentiment has one of four values as follows, based on the collected score of the entire text.

Mixed

Positive

Neutral

Negative

4. Add Icon to indecate the sentiment

Add icon to show the overall sentiment analysis.

In the icon and the color properties, use the “Switch” function to change the “Icon” and the “Color” of the icon based on the resulted analysis.

sentiment analysis

Switch icon code

Use the following code in the icon property. The switch function will replace the icon based on the overall AI Builder sentiment analysis in Power Apps.

Sentiment icon code
Switch(sentimentOutput.sentiment,"positive",EmojiSmile,"neutral",EmojiNeutral,"negative",EmojiSad,EmojiNeutral)

Switch icon color code

Use the following code in the icon property. The switch function will replace the icon color based on the overall AI Builder sentiment analysis in Power Apps. Icon colors are Green for positive, Orange for neutral and red for negative.

Sentiment color code
Switch(sentimentOutput.sentiment,"positive",Green,"neutral",Orange,"negative",Red,Orange)

5. Add galary for multi sentinces text.

When analysing a text with more than one sentences, AI Builder sentiment analysis in Power Apps analyses the overall text and each sentence of the text individually.

As mention above, the overall sentiment analysis shows “mixed” for the entire text.

Meanwhile, each sentence in the text will be analysed independently and values will be included in a table.

In the example, we added icon in the same way we did for the overall sentiment analysis using the switch function.

To present the sentences values, a gallery is added to the screen to show the break down of the sentences and the analysis of those sentences.

Below is the table of results of a given text. values are as follow.

  • Offset – the index letter of the processed text of that sentence.
  • Lenght – the letter counts of that sentence.
  • Sentence score – the confidence of the sentence analysis.
  • Sentiment – the analysis of this sentence.
AI Builder Sentiment analysis canvas app
Sentiment output

Related Articles

Leave a Comment