How to Use AI Builder in Power Apps?

Introduction

Microsoft's AI Builder offers a wide range of AI models, and one powerful capability it provides is sentiment analysis. With sentiment analysis, you can understand the emotional tone of text data, whether it's positive, negative, or neutral. By incorporating this feature into your Power Apps, you can gain valuable insights from user feedback, social media posts, customer reviews, and more. In this step-by-step guide, we'll walk you through the process of using AI Builder to analyze the sentiment of text in your Power Apps.

Step 1. Accessing AI Builder in Power Apps

To begin, ensure you have access to Microsoft Power Apps and the AI Builder. Log in to the Power Apps portal (https://make.powerapps.com/) using your credentials. Ensure that AI Builder is enabled for your Power Apps environment. If it's not already enabled, you can enable it by going to the Power Apps portal and navigating to the "AI Builder" section. If you haven't used AI Builder before, you may need to enable it by following the on-screen instructions.

AI Builder in Power Apps

Step 2. Creating a New Sentiment Analysis Model

In the Power Apps portal, click on "AI Builder" in the left-hand menu, then select "Build”.

AI Builder in Power Apps

Choose "Text classification" and then "Sentiment" with the name “Detect positive, negative or neutral sentiment in text data” to create a new Sentiment Analysis model.

AI Builder in Power Apps

After selecting the “Detect positive, negative, or neutral sentiment in text data”, you can try the samples in the “Type your text” and you can test.

AI Builder in Power Apps

You can use the prebuilt model to test the model that you want to select. You can also choose the training by yourself.

Step 3. Uploading Training Data

To train the Sentiment Analysis model, you need to upload text data labeled with their corresponding sentiments. Prepare a dataset with sample text and their sentiment labels (positive, negative, or neutral) in a CSV file. The more diverse and representative your data is, the better the model's accuracy.

Step 4. Training and Evaluating the Model

Once your training data is uploaded, AI Builder will guide you through the process of training the model. Click on "Train" to initiate the training process. After training, you can evaluate the model's performance by using test data. Review the evaluation metrics to assess the model's accuracy and make necessary adjustments if required. Follow the on-screen instructions to train the model using sample data. The Sentiment Analysis model requires positive, negative, and neutral examples for training. You can provide a set of texts with corresponding sentiments to train the model effectively.

Step 5. Publishing the Sentiment Analysis Model

Once you are satisfied with the model's performance, click on "Publish" to deploy it as a web service. This makes the Sentiment Analysis model accessible to your Power Apps.

Step 6. Creating a Power App

Now, let's create a new Power App or use an existing one where you want to analyze the sentiment of the text.

Step 7. Adding the Sentiment Analysis Component

In the Power Apps editor, click on "Insert" and then choose "AI Builder." Select "Sentiment Analysis" from the list of available AI models.

Step 8. Connecting the Sentiment Analysis Model

Once the Sentiment Analysis component is added to your app, you need to connect it to the published Sentiment Analysis model. Click on the component and select the model you created earlier from the list.

Step 9. Adding Text Input Control

To analyze text input, add a Text Input control to your app's interface. This will allow users to input the text they want to analyze.

Step 10. Displaying the Sentiment Analysis Result

Next, add a Label control to your app where the sentiment analysis result will be displayed. Connect the Label control to the Sentiment Analysis component to show the sentiment result. In the "OnSelect" property of the button or action control, use the "AI Builder" function to analyze the sentiment of the text:

Set(sentimentResult, AIModel.Run(SentimentAnalysisModel, TextInput.Text).sentiment)

Here, "sentimentResult" is a variable where the sentiment analysis result will be stored, "AIModel.Run" is the function to run the Sentiment Analysis model, "SentimentAnalysisModel" is the name of your published Sentiment Analysis model, and "TextInput" is the name of the text input control.

Step 11. Testing the Sentiment Analysis

With your app now set up to analyze sentiment, test it by entering different text inputs and observing the sentiment analysis results.

You can now display the sentiment analysis result using a label or any other control. For example:

If(sentimentResult = "Positive", "Positive Sentiment",

   sentimentResult = "Negative", "Negative Sentiment",

   "Neutral Sentiment")

This example displays the sentiment analysis result as "Positive Sentiment," "Negative Sentiment," or "Neutral Sentiment" based on the output from the Sentiment Analysis model.

Conclusion

By following this step-by-step guide, you will know how to leverage AI Builder in Power Apps to analyze the sentiment of text data. This powerful feature opens up new possibilities for understanding user feedback, customer sentiment, and social media responses. Empower your Power Apps with sentiment analysis and gain valuable insights to make data-driven decisions and enhance user experiences. Experiment with different use cases and datasets to fine-tune the model's performance and make the most of AI Builder's capabilities in your applications.


Similar Articles