AIClassify, AIExtract, AIReply, AISentiment, AISummarize, and AITranslate
Applies to: Canvas apps
Description
Dataverse provides a variety of ready-to-use AI functions that are preconfigured and don't require any data collection, building, or training. You can use these prebuilt AI functions in your app and workflows to improve functionality and streamline processes. The AI functions work with canvas apps, AI Builder, and low-code plugins so can easily integrate them into your solutions.
AIClassify classifies text into one of the provided categories. For example, the following list of categories can be used to classify issues submitted by your customers:
- Problem
- Billing
- How To
- Licensing
AIExtract extracts specified entities such as registration numbers, phone numbers, or names of people.
Note
The AIExtract function is still in development and might not operate properly. We will remove this note when it is ready to use.
AIReply drafts a reply to the message that you provide. For example, this function drafts a reply to a customer's review of a product.
AISentiment detects the sentiment of the text that you provide. For example, this function detects whether the sentiment of a customer review is positive, negative, or neutral.
AISummarize summarizes the text that you provide. For example, this function summarizes an email message or text from a document.
AITranslate translates text from another language. For example, this function translates a customer email or product review. The source language doesn't need to be specified, and is automatically detected.
For more information about languages supported for the source and target language, see Translator language support—Translation and review the list of supported languages under the Auto Language Detection column.
Learn more about how to use AI functions in the following video.
Prerequisites
For more information on prerequisites, see Requirements and licensing for prebuilt prompts.
Use in canvas apps
You can call these functions from canvas apps. However, it's a little more complicated than described for other Power Fx hosts:
- You need to add the Environment data source.
- The AI functions are functions in the Environment namespace. Where this documentation describes calling AISummarize( ... ), for example, you need to use Environment.AISummarize( ... ).
- Arguments to the function must be named columns in a record, passed as the only argument. The names of the columns are given in the Syntax section matching the names of the parameters.
- The return value from these functions is always a record containing one column. The name of the column is listed in the Syntax section.
- These functions are behavior functions and cannot be used in Canvas data flow, for example as the input to the Text property of a Text control. Use the Set function to place the result in a global variable, and then use that value elsewhere in your app.
Here's an example:
- Open a canvas app for editing in Power Apps Studio.
- From the Data pane, select Add data and then add the Environment data source.
- From the Insert pane, add a Button control.
- In the formula bar, select the OnSelect property and enter the following formula:
Set( Summary, Environment.AISummarize( {Text: "2, 4, 6, 8, 10, 12, 14, 16"} ).SummarizedText )
- From the Insert pane, add a Text control.
- In the formula bar, select the Text property and enter the following formula:
Summary
- The text box displays an AI generated summary similar to:
The given text is a sequence of even numbers from 2 to 16, increasing by 2 each time.
Note
We are in the process of adding the same function signatures that other Power Fx hosts enjoy to canvas. The new signatures will augment and not replace the current mechanism; apps using the current mechanism will continue to work without modification.
Syntax
AIClassify( Text, Categories )
- Text - Required. A text sentences. The text to classify.
- Categories - Required. Single column of table of text categories.
- For canvas apps, the return value is in the Classification column.
AIExtract( Text, Entity )
- Text - Required. A text sentences. The text to extract the data from.
- Entity - Required. The entity to extract. The name of entity to extract.
- For canvas apps, the return value is in the ExtractedData column, a table of zero or more rows of data matching the provided entity.
AIReply( Text )
- Text - Required. A text sentence. The text to respond to.
- For canvas apps, the return value is in the PreparedResponse column.
AISentiment( Text )
- Text - Required. The text to analyze for sentiment.
- For canvas apps, the return value is in the AnalyzedSentiment column and is "Positive", "Neutral", or "Negative".
AISummarize( Text )
- Text - Required. The text to summarize.
- For canvas apps, the return value is in the SummarizedText column.
AITranslate(Text, TargetLanguage)
- Text - Required. The text to translate.
- TargetLanguage - The language tag to translate into such as "fr" for French. See the Language function for more details.
- For canvas apps, the return value is in the TranslatedText column.
Examples
To setup the following examples:
- In the Tree view, select the App object and add the following to the Formulas property:
Subject = "Washington is a state that offers a variety of food experiences for locals and visitors alike. Whether you are looking for fresh seafood, farm-to-table produce, ethnic specialties, or gourmet treats, you will find something to satisfy your taste buds in Washington. Washington is famous for its seafood, especially salmon, oysters, crab, and clams. The state has a long coastline and numerous rivers and lakes that provide abundant and high-quality seafood.";
- Create a Button control.
- Create a Text control and set its Text property to:
Result
AIClassify
- In Canvas apps, set the OnSelect property of the Button control to:
For all other products, use this formula:Set( Result, Environment.AIClassify( {Text:Subject, Categories: ["Housing", "Food"]} ).Classification )
Set( Result, AIClassify( Subject, ["Housing", "Food"] ) )
- Press the button. The Text control displays the result:
Food
AIExtract
- In canvas apps, set the OnSelect property of the Button control to:
For all other products, use this formula:Set( Result, Environment.AIExtract( {Text:Subject, Entity: "State"} ).ExtractedText )
Set( Result, AIExtract( Subject, "State" ) )
- Press the button. The Text control displays the result.
AIReply
- In canvas apps, set the OnSelect property of the Button control to:
For all other products, use this formula:Set( Result, Environment.AIReply( {Text:Subject} ).PreparedResponse )
Set( Result, AIReply( Subject ) )
- Press the button. The Text control displays a result similar to:
Washington state is indeed a culinary delight, offering a diverse range of food experiences for both residents and tourists. From fresh seafood to farm-to-table produce, ethnic specialties to gourmet treats, there is something to please every palate in Washington. The state is particularly renowned for its seafood, with salmon, oysters, crab, and clams being local favorites. This is due to Washington's extensive coastline and numerous rivers and lakes, which provide an abundance of high-quality seafood. If you have any specific questions or need recommendations for dining in Washington, feel free to ask!
AISummarize
- In canvas apps, set the OnSelect property of the Button control to:
For all other products, use this formula:Set( Result, Environment.AISummarize( {Text:Subject} ).SummarizedText )
Set( Result, AISummarize( Subject ) )
- Press the button. The Text control displays a result similar to:
Washington state is known for its diverse food experiences, catering to both locals and visitors. From fresh seafood to farm-to-table produce, ethnic specialties, and gourmet treats, there is something to please everyone's taste buds. Seafood, particularly salmon, oysters, crab, and clams, is a highlight in Washington. With its extensive coastline, rivers, and lakes, the state offers an abundance of high-quality seafood options.
AISentiment
- In canvas apps, set the OnSelect property of the Button control to:
For all other products, use this formula:Set( Result, Environment.AISentiment( {Text:Subject} ).AnalyzedSentiment )
Set( Result, AISentiment( Subject ) )
- Press the button. The Text control displays the result:
Positive
AITranslate
- In canvas apps, set the OnSelect property of the Button control to:
For all other products, use this formula:Set( Result, Environment.AITranslate( {Text:Subject, Language: "fr"} ).TranslatedText )
Set( Result, AITranslate( Subject, "fr" ) )
- Press the button. The Text control displays a result similar to:
Washington est un État qui offre une variété d’expériences culinaires pour les habitants et les visiteurs. Que vous soyez à la recherche de fruits de mer frais, de produits de la ferme à la table, de spécialités ethniques ou de friandises gastronomiques, vous trouverez de quoi satisfaire vos papilles à Washington. Washington est célèbre pour ses fruits de mer, en particulier le saumon, les huîtres, le crabe et les palourdes. L’État possède un long littoral et de nombreuses rivières et lacs qui fournissent des fruits de mer abondants et de haute qualité.