Back to Blog

Invoice scanning process Automation – Power Automate and AI Builder

Invoice scanning is 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 accounting system, also for reporting and need to 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 Power Automation dashboard, click on 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 incase if you have customer or complex formatting in your invoice document. You can customize this model accordingly.

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

Prebuild model if you find good accuracy with 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.

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

This module will run a button click read information from pdf and send an email to 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 for Invoice scanning –  

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

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.

Step 3 – Add an action step to create 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.

In our case, it is creating a table for Description, Quantity, and Amount coming in response to 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 email.  

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

Use code like –  

{ 

  "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": { 

    "Get_my_profile_(V2)": [ 

      "Succeeded" 

    ] 

  }, 

  "metadata": { 

    "operationMetadataId": "a1d3dbef-cdb5-4a84-9c91-290ee0e1e667" 

  } 

} 

This code to send email along with PDF information.

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.  

You will receive email on your logged email in HTML format which we used in Flow –

I got this email at 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:

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 learnt –

How to train AI models in simple and effortless way

Extract data from model compose HTML

Send 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.

Back to Blog
top