Invoice Scanning Process Automation Using Power Automate And AI Builder

The continue statement enables the skipping of the current iteration and moving to the next iteration, while the break statement facilitates the premature termination of the loop execution.

Introduction

Scannable invoices are an important part of the accounts payment process because they make it easier to process and find paper invoices. As companies deal with more and more bills, it becomes clear that they need to automate the process.

Sometimes, we need to push invoice data to the accounting system for reporting and send messages to vendors and customers. This scanning process will help.

Power Automate and AI Builder, two tools from Microsoft's Power Platform, work well together to make this process faster and better.

Power Automate is a service that helps create automated workflows between your apps and services to synchronize files, get notifications, collect data, and more. AI Builder, on the other hand, is a turnkey solution that brings the power of Microsoft AI to Power Automate, enabling organizations to automate processes and glean insights from their data through machine learning models.

Setting Up Invoice Scanning Automation

Before diving into automation, ensure that all necessary components are in place. This includes access to Power Automate, AI Builder, and any additional tools or services required for the specific workflow.

Go to the Power Automation dashboard and click on AI model.

AI Model

And selected prebuild model – “Extract Information from Model”. This model is already trained to extract information from invoices. Once you select this model and use it for scanning it will be able to extract information from most of the invoices.

But in case if you have customer or complex formatting in your invoice document. You can customize this model accordingly.

Explorer

You will find the upload bottom to upload your document and see the accuracy you will get with this model. Apart from that, you will get two buttons, “User prebuild model” and “Create a custom model.”

Prebuild model if you find good accuracy with the existing model, you can directly use this model in your flow. If you want to customize it a little bit according to your requirements, you can select Create Custom Model. In this case, you need to train this model with your current invoice format.

Prebuilt models

When you click on User this model in Power Automate, it will ask you to create a triggered-based Power flow along with the AI build model.

Microsoft office apps

This module will run a button, click read information from pdf, and send an email to the user. You need to specify a username and password for all these apps before moving forward. Create the flow that automatically picks up the name ‘Read information from invoices. You can use the same name or modify it accordingly.

Exploring Power Automate Flow

Step 1. The first setup of flow is a manual trigger, which is used to collect files. Where you can change input according to your needs. By default, it has file upload input along with some file type limited.

Trigger flow

Step 2. Use to extract information from PDF using the same AI builder model that was picked before to use in the model. It will automatically embedded in the flow.

Extract Information

Step 3. Add an action step to create an HTML table. Where in parameters, you will get two options. Option 1 is to automatically create a table when you do not need to map any parameters. What comes from responses will be converted into an HTML table. Another option is custom, which is used to create a custom HTML table and map values coming from previous steps.

Create HTML Table

In our case, it is creating a table for Description, Quantity, and Amount coming in response to the AI build invoice scanning step.

Step 4. Add action step to get logged user office profile, which can be used in the next step to send an email.

Get Profile

Step 5. Send email using Office 365 office connector and use action ‘Send an Email (V2)’.

Code

{ 
  "type": "OpenApiConnection",
  "inputs": { 
    "parameters": { 
      "emailMessage/To": "@outputs('Get_my_profile_(V2)')?['body/mail']",
      "emailMessage/Subject": "Invoice processed",
      "emailMessage/Body": "<p><span style=\"font-size: 16px\">Congratulations </span><span style=\"font-size: 16px\">@{outputs('Get_my_profile_(V2)')?['body/givenName']}</span><span style=\"font-size: 16px\">! Your Power Automate flow ran successfully. Here are some of the fields extracted from the attached invoice by AI Builder Invoice Processing:</span><span style=\"font-size: 16px\"><strong><br>\n<br>\nInvoice ID</strong></span><span style=\"font-size: 16px\">: </span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceId/valueText']}</span><span style=\"font-size: 16px\"> (confidence score: </span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceId/confidence']}</span><span style=\"font-size: 16px\">)<br>\n<br>\n</span><span style=\"font-size: 16px\"><strong>Invoice Date, as written on the invoice</strong></span><span style=\"font-size: 16px\">: </span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceDate/valueText']}</span><span style=\"font-size: 16px\"> (confidence score: </span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceDate/confidence']}</span><span style=\"font-size: 16px\">)<br>\n<br>\n</span><span style=\"font-size: 16px\"><strong>Invoice Date, in standardized date format</strong></span><span style=\"font-size: 16px\">: </span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceDate/valueDate']}</span><span style=\"font-size: 16px\"><br>\n<br>\n</span><span style=\"font-size: 16px\"><strong>Invoice Total, as written on the invoice</strong></span><span style=\"font-size: 16px\">: </span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceTotal/valueText']}</span><span style=\"font-size: 16px\"> (confidence score: </span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceTotal/confidence']}</span><span style=\"font-size: 16px\">)<br>\n<br>\n</span><span style=\"font-size: 16px\"><strong>Invoice Total, in standardized number format: </strong></span><span style=\"font-size: 16px\"></span><span style=\"font-size: 16px\">@{outputs('Extract_information_from_invoices')?['body/responsev2/predictionOutput/result/fields/invoiceTotal/valueNumber']}</span><span style=\"font-size: 16px\"><br>\n<br>\n</span><span style=\"font-size: 16px\"><strong>Line items:</strong></span><span style=\"font-size: 16px\"><br>\n</span><span style=\"font-size: 16px\">@{body('Create_HTML_table')}</span><span style=\"font-size: 16px\"><br>\n<br>\nLearn more about AI Builder Invoice Processing and the information it can extract: </span><a href=\"https://go.microsoft.com/fwlink/?linkid=2148225\"><span style=\"font-size: 16px\">https://go.microsoft.com/fwlink/?linkid=2148225</span></a></p>", 
      "emailMessage/Attachments": [ 
        { 
          "Name": "@string(triggerBody()?['file']?['name'])",
          "ContentBytes": "@triggerBody()['file']['contentBytes']" 
        } 
      ] 
    }, 
    "host": { 
      "apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
      "connection": "shared_office365",
      "operationId": "SendEmailV2" 
    } 
  }, 
  "runAfter": { 
    "

This code is to send an email along with PDF information.

Mail

Testing

Run flow ‘Read information from invoices’ using the details page. It will ask for an Invoice PDF to upload. Upload an invoice. And click on run flow. Check the status of flow on the details page.

Flows

You will receive an email on your logged email in HTML format, which we used in Flow.

Invoice proceed

I got this email at the end of the process.

“Sandeep! Your Power Automate flow ran successfully. Here are some of the fields extracted from the attached invoice by AI Builder Invoice Processing:

  • Invoice ID: INV-3337 (confidence score: 0.972)
  • Invoice Date, as written on the invoice: January 25, 2016 (confidence score: 0.933)
  • Invoice Date, in standardized date format: 2016-01-25
  • Invoice Total, as written on the invoice: $93.50 (confidence score: 0.971)
  • Invoice Total, in standardized number format: 93.5

Line items

Description Quantity Amount
Web Design This is a sample description ... 1 85

It worked. Wow!

Conclusion

Invoice scanning automation, powered by Power Automate and AI Builder, offers a powerful solution to streamline the accounts payable process, enhancing efficiency, accuracy, and cost-effectiveness.

In this article, we learned

  1. How to train AI models in a simple and effortless way
  2. Extract data from the model and compose HTML
  3. Send an email along with HTML reporting embedded with invoice data

As technology continues to evolve, so will the capabilities and applications of automated invoice processing. Businesses that adopt and continuously improve their automation strategies will be well-placed to reap the benefits.


Similar Articles