You can now automate invoice processing in Power Automate with the new Encodian Flowr action AI – Process Invoice. This action is pre-trained, so all you need to do is provide your invoice in either PDF or image format, and it will automatically identify and extract key information contained within the document.
This isn’t the only new AI document processing action available in the latest Flowr release, there is also:
Automatically extract important details from submitted contracts
Uses artificial intelligence to analyze and extract key information from the provided ID document
Applies artificial intelligence to identify and extract important details from a provided U.S. health insurance card
Harness the power of AI to instantly extract valuable insights from any receipt
This blog outlines a solution for automating the processing of invoices which are received in the “Invoice Mailbox”. After the invoices have been processed, they are saved to a SharePoint library. A Power App allows users to view all invoices which are stored within a SharePoint library, where they can preview the original PDF and validate that the AI-extracted data is correct.
This flow moves an invoice from an email attachment to a SharePoint library. It also uses the new Encodian Flowr action ‘AI – Process Invoice’ to extract key invoice information and saves the extracted data to SharePoint alongside the file content URI, allowing us to view the PDF document in the Power App.
For the trigger, I have set the ‘Include Attachments‘ property to ‘Yes‘, and I’ve added a ‘Subject Filter‘ to look for emails containing the word ‘Invoice‘. You can configure the trigger as needed for your invoice mailbox; however, I’ve applied these settings to filter the emails received for the purposes of this example.
Once an email has been received, we need to loop through all the attachments. There may be multiple attachments detected, even if only one file is actually attached to the email. This is because the Power Automate trigger action identifies any images used in the email body or signature as attachments. Therefore, we need to filter through all detected attachments to find the actual PDF document we want to use.
We can do this by looping through the attachments using an ‘Apply to each’ loop.
Inside the loop, I have added a condition to check whether the current attachment is a ‘PDF‘. For this, I am checking if the ‘contentType‘ (from dynamic content) contains the value ‘pdf‘. If this condition is true, the attachment is a PDF, so we can save the document in SharePoint. If the condition is false, no action is needed, and the loop will continue.
To create the file in SharePoint, you can use the ‘Name‘ and ‘ContentBytes‘ dynamic properties within the ‘Create file’ action.
Next, we can use Flowr’s AI – Process Invoice action to extract the invoice data contained within the PDF document. All we need to do is provide the ‘contentBytes‘ property as the ‘File Content‘ input.
The invoice data extracted by the AI – Process Invoice action is returned as a JSON string. Any new lines for data in the invoice document (e.g. Address) will appear in the output with a line break (\n). If these aren’t removed, they will remain in the JSON and appear in the data sent to and displayed in the app. To clean this up, I’m replacing the line breaks with a space in a compose action.
json(replace(outputs('AI_-_Process_Invoice')?['body/result'],'\n',' '))
I also have a second compose action that puts the file content in a format that the PDF Viewer in the Power App can use to display the document.
dataUri(body('Get_file_content'))
To finish the flow, we will update the file properties of the invoice document we saved to SharePoint to save the invoice data JSON.
I have created a single-screen Canvas App that connects to the ‘Invoice‘ SharePoint document library. Users can browse the available invoices using a gallery and view the PDF document and the extracted information side by side.
When the view icon is pressed, there are multiple things happening:
Select(Parent); Set( varInvoiceData, ParseJSON(ThisItem.'Invoice JSON') ); ClearCollect( InvoiceItems, ForAll( varInvoiceData.Items, { Code: Text(ThisRecord.ProductCode), Quantity: Text(ThisRecord.Quantity), Amount: Text(ThisRecord.Amount), Description: Text(ThisRecord.Description) } ) ); Set( pdfFileContent, ThisItem.'File Content' ); Set( showPDF, true );
You need to make sure you are using the ‘ParseJson‘ function when setting the ‘varIncoiceData’ variable, as the data is in JSON format. This allows you to easily extract and work with the data within the app. Below is an example of the JSON sent from Power Automate:
‘Items’ are contained within a JSON array. We want to display this data in a ‘Table’ control in the Power App. To do this, we need to save the data to a collection using the ‘ForAll’ function. When defining your collection columns, make sure to use:
Text/Number(ThisRecord.JSONKey)
For example:
Text(varInvoiceData.InvoiceId)
You need to tell PowerApps what type of value it is, or it will give you an UntypedObject error. This also applies when setting values for the text fields.
The app screen looks like this after an invoice has been selected:
The ‘Visible’ property of the PDF viewer is set to ‘showPDF‘, which is why it is shown when the view icon is clicked (we are setting ‘showPDF ‘ to true in the last formula).
The document property is set to ‘pdfFileContent‘. We don’t need to do any formating to this in the Power App as this has been handled in the Power Automate flow.
The invoice details are being populated from ‘varInvoiceData‘.
The Invoice Amount is being calculated using the following formula, noting that if the ‘Invoice’ itself contained a ‘Total’ value you could simply use this extracted value:
Text( Sum(InvoiceItems, Value(Substitute(Amount, "£", ""))), "£#,##0.00" )
When the PDF Viewer is visible, a Collapse icon is shown. However, after it is pressed, the icon changes to a PDF icon.
The OnSelect property of this icon is:
If(Self.Icon = Icon.DocumentPDF, Set(showPDF, true), Set(showPDF, false))
The Icon property is:
If(showPDF,Icon.CollapseView, Icon.DocumentPDF)
The Visible property is set so that the icon is only visible if there is invoice data loaded in the app:
!IsBlank(txt_invoiceID.Text)
The Reset icon refreshes the SharePoint data and resets all the variables used in the app:
Refresh(Invoices); Set(varInvoiceData, Blank()); Set(pdfFileContent, Blank()); Clear(InvoiceItems); Set(showPDF, false)
The new AI – Process Invoice action from Encodian Flowr makes it easier than ever to automate invoice handling with Power Automate. With just a few simple steps, you can extract structured invoice data from PDFs or image files, store it alongside documents in SharePoint, and present it seamlessly within a Power App for validation and review.
Whether you’re processing dozens or thousands of invoices, this solution saves time, reduces manual input, and boosts overall efficiency. And with additional AI-powered document actions for contracts, receipts, ID documents, and more, Flowr puts advanced automation right at your fingertips.
Search 200+ Actions to see how Flowr can save you time
Sign up for your free 30-day trial; no cards, catches, or contracts.
Don’t struggle! Try out our Premium Support packages today.
Technical Evangelist