Using AI Builder in Apps and Flows

Complete the full lesson to earn 25 points

Work through each section, then tap “Mark as Complete” on the last one.

Module: Manage Environments

Section: Configure AI Builder

Lesson: Using AI Builder in Apps and Flows

Introduction: The Evolution of Intelligent Automation

In the modern digital workplace, the ability to process data automatically is no longer a luxury; it is a fundamental requirement for operational efficiency. AI Builder is a capability within the Power Platform that allows organizations to infuse intelligence into their business processes without requiring deep expertise in data science or complex machine learning coding. By providing a low-code interface to create, train, and deploy AI models, AI Builder bridges the gap between raw business data and actionable insights.

Understanding how to integrate these models into Power Apps and Power Automate is critical because it transforms static applications into dynamic tools capable of reading documents, classifying text, detecting objects in images, or predicting future outcomes. Whether you are automating invoice processing, sentiment analysis for customer feedback, or inventory management through image recognition, AI Builder serves as the engine that drives these intelligent workflows. This lesson will guide you through the architectural considerations, practical implementation steps, and industry best practices for leveraging AI models effectively across your environment.


Understanding the AI Builder Ecosystem

Before diving into the technical implementation, it is important to understand the two primary ways AI models are consumed within the Power Platform: Power Apps and Power Automate. While both platforms utilize the same underlying AI models, the context in which they are used dictates the design pattern.

In Power Apps, AI Builder is primarily used for real-time interaction. Users often need to scan a document, take a photo of an item, or receive a prediction on a screen while they are actively working within the application. The interface must be responsive, and the AI model must return data that can be immediately displayed or used to update record fields.

In Power Automate, AI Builder is used for background processing. This is where you handle high volumes of data, such as processing hundreds of incoming email attachments or performing scheduled analysis on a database of records. Because these processes run in the background, latency is less of a concern than in a user-facing application, allowing for more complex, multi-step workflows.

Callout: Real-Time vs. Background Processing The fundamental difference between using AI in Power Apps and Power Automate lies in the user experience. Power Apps focus on immediate feedback loops, where the user triggers the AI and views the result instantly. Power Automate focuses on task automation, where AI models act as silent workers processing data in the background, often triggered by events like a new file creation or a scheduled timer.


Configuring AI Models for Use

Before you can add an AI model to an app or flow, you must ensure the model is properly configured and published within your environment. AI Builder offers several prebuilt models (which are ready to use out of the box) and custom models (which require you to provide training data).

Steps to Prepare an AI Model:

  1. Define the Business Problem: Identify whether you need a prebuilt model (e.g., Sentiment Analysis, Key Phrase Extraction) or a custom model (e.g., Form Processing, Object Detection).
  2. Gather Training Data: If using a custom model, collect representative samples. For Form Processing, gather at least five documents of each layout type. For Object Detection, collect at least 15 images per object.
  3. Train the Model: Use the AI Builder portal to upload your data and map the fields. Training time varies based on the volume of data.
  4. Publish the Model: Once training is complete and the model performance is verified, you must publish it to make it available for use in your apps and flows.

Note: Always verify the "Performance" score of your model in the AI Builder portal before publishing. If the score is low, your model will frequently return incorrect or empty data, which can lead to data integrity issues in your downstream systems.


Implementing AI Builder in Power Apps

Integrating AI into a canvas app is handled through specific AI Builder controls. These controls provide a drag-and-drop interface, drastically reducing the amount of manual configuration required.

Implementing a Form Processor Control:

The Form Processor is one of the most common use cases. It allows users to upload a document (like a receipt or invoice) and extract information into your app's fields.

  1. Add the Control: In your canvas app, navigate to the "Insert" menu, select "AI Builder," and choose "Form Processor."
  2. Configure the Model: In the properties panel, select the AI model you previously trained and published.
  3. Map the Output: Once the user scans a document, the control populates an object called FormProcessor1.Fields. You can reference these in your form fields.

Example Code Snippet: If you want to set the value of a text input box named txtTotalAmount to the value extracted from a field named "Total" in your form processor, you would set the Default property of the text input as follows:

// Setting the value extracted from the AI model
FormProcessor1.Fields.Total.Value

This code tells the app to look at the result of the AI processing and pull the specific value identified under the "Total" key. This is a simple yet powerful way to automate data entry.

Warning: Be mindful of the "Confidence Score" returned by the model. If the model is not confident in the data it extracted, it may return a null value or incorrect text. Always implement validation logic to alert the user if a confidence score falls below a certain threshold (e.g., 80%).


Implementing AI Builder in Power Automate

Power Automate is the powerhouse for batch processing. When you trigger a flow, you can pass data from a file, a database, or an email directly into the AI model.

Creating a Document Processing Flow:

  1. Trigger: Start with a trigger such as "When a file is created in a folder" (e.g., SharePoint or OneDrive).
  2. Action: Add an AI Builder action by searching for "Extract information from documents."
  3. Configuration: Select your model from the dropdown menu and point the "File Content" parameter to the file content provided by the trigger.
  4. Processing: Use the output from the AI action to update a database, send an email, or notify a manager.

Example Logic in Power Automate: When you use the "Extract information" action, the output is provided as a JSON object. You can access individual fields using expressions or by selecting them from the dynamic content list.

// Example of accessing a field in a flow
outputs('Extract_information_from_documents')?['body/fields/InvoiceNumber/value']

This expression navigates the JSON output structure to retrieve the specific invoice number identified by the AI. You can then use this value in a "Create Item" action in a SharePoint list or a Dataverse table.


Best Practices for AI Builder Deployment

To ensure that your AI-powered solutions are reliable and maintainable, you must follow established industry standards. AI models are not static; they require ongoing care.

  • Version Control: Always keep track of which version of an AI model is being used. If you retrain a model, test it in a development environment before overwriting the production version.
  • Data Privacy: Never train models on sensitive personal identification information (PII) unless your environment is specifically configured for compliance and security.
  • Error Handling: Always include "Condition" blocks in your Power Automate flows. Check if the AI model successfully extracted data before attempting to write it to your database. If the extraction fails, send a notification to an administrator to review the document manually.
  • User Feedback Loop: In your Power Apps, provide a way for users to correct the AI's output. If the AI incorrectly identifies a field, allow the user to edit it. This feedback is essential for continuous improvement of your business processes.

Callout: The "Human-in-the-Loop" Principle Regardless of how accurate your AI model is, it will eventually make an error. The "Human-in-the-Loop" principle dictates that for high-stakes processes (like financial transactions or legal documentation), the AI should serve as a suggestion engine, not an autonomous decider. Always ensure a human can review and approve AI-generated data before it is finalized in your primary systems.


Comparison of AI Builder Models

When deciding which model to use, refer to the following guide to understand the capabilities and requirements:

Model Type Best For Training Data Requirement
Form Processing Invoices, receipts, tax forms 5+ documents per layout
Object Detection Inventory, damage assessment 15+ images per object
Prediction Predicting churn, trends Historical data (CSV/Excel)
Category Classification Sorting emails, feedback 50+ items tagged by category
Entity Extraction Pulling dates, names from text 50+ examples of text

Common Pitfalls and How to Avoid Them

Even with a low-code approach, there are common mistakes that can hinder your success with AI Builder.

1. Insufficient Training Data

The most frequent cause of poor model performance is a lack of training data. Many developers try to train a model with only two or three samples. While the platform might allow you to proceed, the model will struggle with variability. Always aim for more data than the minimum requirement to account for different document orientations, lighting conditions, or formatting styles.

2. Ignoring Model Retraining

AI models are not "set and forget." As your business documents change—for example, if your vendor changes their invoice format—your model will become less accurate. Establish a schedule to review model performance every 3 to 6 months and retrain as necessary to incorporate new data patterns.

3. Over-complicating the Flow

Avoid building massive, monolithic flows. If you have an AI process that performs five different tasks, break it into smaller child flows. This makes debugging significantly easier. If the AI extraction step fails, you can isolate the error without having to restart the entire workflow.

4. Neglecting Security Permissions

AI models are assets that require security controls. Ensure that only authorized users have access to create or edit models. In your apps, use Row-Level Security (RLS) or app-level permissions to ensure that users can only see the data that the AI extracts if they have the appropriate clearance to view the underlying documents.


Advanced Configuration: Using AI Builder with Power Automate Expressions

Sometimes, the standard dynamic content provided by AI Builder isn't enough. You may need to manipulate the data before it is sent to your database. For example, if your AI model extracts a date in a format that your database doesn't support, you can use Power Automate expressions to reformat it.

Step-by-Step Date Conversion:

  1. Get the date: Retrieve the string date from your AI extraction step.
  2. Add a "Compose" action: Use the expression formatDateTime to convert the string.
  3. Expression Syntax:
    formatDateTime(outputs('Extract_information')?['body/fields/Date/value'], 'yyyy-MM-dd')
    
  4. Result: This ensures that the date is correctly formatted for your SQL or Dataverse backend, preventing errors during data insertion.

This level of precision is what separates a basic implementation from a professional-grade automation. Always consider the data types expected by your downstream systems and use expressions to normalize the output from the AI model.


Managing AI Builder Capacity

AI Builder consumes "AI Credits." These credits are pooled at the tenant level. It is vital to monitor your consumption to avoid service interruptions.

  • Monitoring: Use the Power Platform Admin Center to view credit consumption reports. You can see which environments and which models are consuming the most credits.
  • Allocation: Administrators can allocate specific amounts of credits to different environments. This prevents a single test environment from consuming all the credits for the entire organization.
  • Warning Thresholds: Set up alerts in the admin center to notify you when your organization reaches 80% or 90% of your credit capacity.

Tip: If you are running high-volume batch processing, consider scheduling these tasks during off-peak hours if possible. While AI Builder capacity is not strictly time-bound, ensuring that your background flows don't compete with high-priority user-facing apps can improve the perceived performance of your environment.


Troubleshooting and Support

When an AI model fails to perform as expected, follow this systematic troubleshooting approach:

  1. Check the AI Builder History: Navigate to the AI Builder portal and view the "Run History" for your model. Look for failed runs or runs with low confidence scores.
  2. Verify Input Quality: If the model failed, check the input file. Was the document blurry? Was it a format the model wasn't trained on? Sometimes, the issue is with the source data, not the model.
  3. Review Logic: If the data was extracted correctly but the flow failed later, check the downstream actions. Did the field name change in your database? Did the data exceed the character limit for the field?
  4. Test in Isolation: Create a simplified flow that only runs the AI model and sends the output to a Compose action. If this works, the issue lies in the complex logic you added later, not the AI model itself.

Integrating AI Builder into the Development Lifecycle (ALM)

For larger organizations, you should manage your AI models as part of your Application Lifecycle Management (ALM) strategy.

  • Solutions: Always include your AI models in Power Platform Solutions. This allows you to transport the model configuration between development, test, and production environments.
  • Environment Variables: Use environment variables for AI model IDs. This prevents hardcoding IDs in your flows, allowing you to easily point your production flow to a production-ready model without editing the flow logic.
  • Documentation: Maintain a document detailing the training data sources, the version history, and the intended use case for each model. This is critical for auditing and compliance, especially in regulated industries.

Future-Proofing Your AI Strategy

The landscape of AI is shifting rapidly. While today you might be using standard form processing, tomorrow you might be integrating Generative AI features within the Power Platform. By building your apps and flows with a modular approach, you make it easier to swap out older, rigid AI models for more flexible, modern counterparts as they become available.

Focus on the process, not just the tool. The most successful implementations of AI Builder are those that solve a clear, well-defined business problem. Before building, ask yourself:

  1. Is this process repetitive?
  2. Does it rely on structured or semi-structured data?
  3. Will automating this save significant time or reduce human error?

If the answer to these questions is "yes," you have a prime candidate for AI Builder integration.


Key Takeaways

  1. Context Matters: Distinguish clearly between real-time AI needs in Power Apps and background batch processing in Power Automate to design the most efficient architecture.
  2. Data Quality is Paramount: The accuracy of your model is directly proportional to the quality and quantity of your training data. Never cut corners during the data collection phase.
  3. Human-in-the-Loop: Always implement verification steps. AI should assist human decision-making, not replace the accountability required for critical business transactions.
  4. Proactive Maintenance: AI models require periodic retraining as business data patterns evolve. Treat them as living assets that need monitoring and updates.
  5. Use Solutions for ALM: Always bundle your models and flows into Solutions to ensure consistent deployment across your development, testing, and production environments.
  6. Monitor Credit Usage: Keep an eye on your organization's AI credit consumption in the Admin Center to prevent unexpected service interruptions during high-volume periods.
  7. Error Handling is Essential: Never assume the AI will succeed. Build robust error-handling logic into your flows to manage null results or low-confidence outputs gracefully.

By following these principles, you will be well-equipped to deploy AI Builder in a way that is stable, scalable, and genuinely useful to your organization. The transition to intelligent automation is a journey, and mastering these core integration patterns is your first step toward building a more efficient, data-driven environment.

Loading...
PrevNext