Hello! Welcome to the final lesson in our module on "Applying AI Builder Models."
In our last session, you learned how to use the prebuilt text recognition model within a Power Automate flow. We focused on the backend process of extracting all text from an image (OCR) and processing it line-by-line.
Today, we shift our focus from backend automation to real-time user interaction within a Power App. Our goal is to use the prebuilt key phrase extraction AI model in an app to analyze user-provided text. This model doesn't just read text; it identifies the main talking points. For example, if a user enters, "The app is intuitive but the performance on the main dashboard is slow," the model can extract "app," "intuitive," and "main dashboard," giving you the core concepts of the feedback.
This is a powerful capability for building apps that can intelligently categorize user input, suggest tags for content, or analyze customer feedback on the fly. As this is the last lesson in this module, it serves as a great bridge, combining your app development skills with the intelligence of AI Builder.
1. Understanding the Key Phrase Extraction Model
Like the text recognition model we used previously, key phrase extraction is a prebuilt model that requires no training. It takes a string of text as input and returns a list of the most important words and phrases.

To get a precise understanding of its capabilities and limitations, let's consult the official documentation.
Key phrase extraction prebuilt model - AI Builder
The Microsoft Learn article 'Key phrase extraction prebuilt model' provides a concise overview of the model. It covers what the model does, its constraints, and most importantly, the structure of its output.
Please read the introduction, the 'Use in Power Apps' section, and the 'Supported language and data format' and 'Model output' sections. Focus on these key points: What is the core function of the model? What is the character limit for the input text? What information does the model return? (This is crucial for using it in an app).
From the documentation, here are the essential takeaways for a developer:
- Function: It extracts key talking points from unstructured text.
- Input: A text string, up to 5,120 characters.
- Output: A list of strings, where each string is an identified key phrase.
Now, let's put this into practice by building a Canvas App.
2. Implementing Key Phrase Extraction in a Canvas App
We will build a simple app that allows a user to type in text, click a button, and see a list of extracted key phrases. This process involves adding the AI model to the app, writing a Power Fx formula to call it, and binding the results to a control for display.
The following guide explains the general pattern for using any AI model with Power Fx in Power Apps. While its example uses the "Language detection" model, the principles and steps are identical for our "Key phrase extraction" model.
Use AI Builder models in Power Apps
This documentation, 'Use AI Builder models in Power Apps', is your guide for the practical integration. It details how to add a model to your app and the specific Power Fx syntax you'll need.
Please review the following sections: 'Select a model in canvas apps': This shows the essential first step of adding the AI model as a data source to your app. 'Use a model with controls': Pay close attention to the example. Notice how a Text Input is used for user entry and a formula calls the model. Also, note the 'Best practices' tip about using a button's OnClick event. 'Input and output by model type': In the 'Prebuilt models' table, find the row for Key phrase extraction. This gives you the exact formula syntax and output structure you will use.
Step-by-Step Implementation
Let's apply what you've learned from the resources.
-
Create a Blank Canvas App:
- Go to make.powerapps.com.
- Create a new, blank Canvas App (tablet or phone layout).
-
Add the AI Model:
- In the app editor, go to the Data tab on the left pane.
- Click Add data, search for "AI models."
- Select Key Phrase Extraction from the list to add it to your app.
-
Design the User Interface:
- From the Insert tab, add the following controls to your screen:
- A Text input control. Rename it
txtFeedbackInput. Set itsModeproperty toTextMode.MultiLineto allow for more text. Clear itsDefaulttext. - A Button control. Rename it
btnAnalyzeTextand set itsTextproperty to "Analyze Text". - A Vertical gallery control. Rename it
galKeyPhrases. This will display our list of results.
- A Text input control. Rename it
- From the Insert tab, add the following controls to your screen:
-
Write the Power Fx Formula:
- As recommended in the best practices, we will call the model from the button's
OnSelectevent to efficiently manage API calls. - Select the
btnAnalyzeTextbutton. - Set its
OnSelectproperty to the following formula:ClearCollect( colKeyPhrases, 'Key phrase extraction'.Predict(txtFeedbackInput.Text).Phrases ) - Formula Breakdown:
'Key phrase extraction'.Predict(txtFeedbackInput.Text): This calls the AI model, passing the text from our input box..Phrases: As per the documentation, the model's output is a record containing a table namedPhrases. We access this table.ClearCollect(colKeyPhrases, ...): This function takes the resulting table of phrases and stores it in a local collection namedcolKeyPhrases.ClearCollectensures the collection is cleared before new items are added, so you don't mix results from previous clicks.
- As recommended in the best practices, we will call the model from the button's
-
Display the Results:
- Select the
galKeyPhrasesgallery control. - Set its
Itemsproperty tocolKeyPhrases. - Inside the gallery, select the default Title label.
- Set its
Textproperty toThisItem.Value.ThisItem.Valuerefers to the text of the key phrase in the current row of the collection.
- Select the
Now, run your app! Enter some text into the input box (e.g., "The hotel had a fantastic view and the staff was very friendly, but the Wi-Fi was unreliable.") and click the "Analyze Text" button. The gallery should populate with the key phrases: "fantastic view," "staff," "friendly," and "unreliable Wi-Fi."
Test your understanding!
You want to enhance the app to show a count of the key phrases found after an analysis. How would you add a label that displays "Phrases found: 4" (for example) above the gallery?
Show answer
- Add a Text label control above the gallery.
- Set its
Textproperty to the following formula:
The"Phrases found: " & CountRows(colKeyPhrases)CountRows()function returns the number of records in thecolKeyPhrasescollection, giving you a dynamic count of the results.
Conclusion
Congratulations on completing the "Applying AI Builder Models" module! In this lesson, you successfully integrated the key phrase extraction model directly into a Canvas App. This enables you to build more intelligent and responsive user interfaces that can understand and process unstructured text in real time.
Key Takeaways:
- Model Integration: AI Builder models are added to Canvas Apps as data sources, making them available to use in Power Fx formulas.
- Power Fx Syntax: You call the model using the
.Predict()function, passing the required inputs (like a text string). The syntax is consistent across models:'Model name'.Predict(input). - Handling Output: The key phrase model returns a table of phrases, which is best handled by storing it in a collection (
ClearCollect) and displaying it in a gallery. - Event-Driven Calls: Triggering the AI model on a button's
OnSelectevent is more efficient than using an input'sOnChangeevent, which helps manage AI Builder credit consumption.
What's Next?
With your knowledge of integrating AI into both Power Automate and Power Apps, you have a solid foundation in one of the most powerful aspects of the Power Platform.
Our next module, "Power Apps Component Framework (PCF) Development," will transition into pro-developer territory. This is a topic you expressed specific interest in, and it's a critical skill for the PL-400 exam. In the first lesson, we will dive right into the practical setup, starting with installing the Power Platform CLI and initializing your first PCF component project. This will allow you to build fully custom, code-based controls that extend the capabilities of Model-driven and Canvas Apps far beyond what is possible out-of-the-box.