Level: Beginner/Intermediate. Read time 5 minutes
Imagine a world where the machines have taken over.
Where human input isn’t required for low-level administrative tasks and handling of documentation.
Where errors are reduced by using AI to accelerate and optimise what could be a time-consuming process.
No, this isn’t the plot to a Stanley Kubrick film, it’s your business after getting to grips with MS Power Automate’s ‘AI Builder’ and more specifically the ‘Document Automation’ function.
What is it for?
The idea behind automating document handling is to take away the human bit. People make mistakes. We misread data, we do not put things in the correct formats and folders, which ends up with nuclear-level panic-stations when you can’t find that particularly important document that you need immediately.
Computers are only as smart as the information that has been input into them. A well setup system – with a little bit of training to users thrown in – should make document managing a much more efficient and errorless part of your organisation’s day.
How is it intended to work?
In most cases document processing follows a similar pattern:
Get the document from a location (Mailbox / SharePoint)
Extract the data from the documents
Send the data to the next destination (either a database or a system within the company e.g., the HR department).
Because of this similar pattern, it allows for a level of automation to be appropriate.
The document automation solution provided by Microsoft consists of the following parts:
Document Automation Email Importer flow – a flow to import documents.
Triggered when an attachment is on an email.
Adds it to a document queue in Dataverse.
Stores the document in Dataverse
Sets state to ‘Extracting Data’
Document Processer Flow – a flow to extract data from the documents
Triggered when a doc is in ‘Extracting Data’ state
Calls an existing AI model to analyze and extract the data.
Stores the data in a Dataverse table
Sets state to ‘Validating Data’
Document Automatic Validation Flow – a flow to see if any manual validation is required.
Triggered when document is set to ‘Validating Data’
Business logic and requirements are set to the data, auto-approval may be instigated if certain set parameters are met.
Sets the document state to ‘Manual Validation.’
Document Automation Application – a Canvas Power App where data and documents can be reviewed and approved.
Review and process the document and the extracted data labels
Sets state to ‘Validated’
How to get it?
How do I install this organisation-wide-changing solution? Pretty simply actually. Well, the initial bit at least anyway.
1. Find and click on the Power Automate Application in MS365.
2. On the left-hand sidebar, click ‘AI Builder’ which should reveal a dropdown for ‘Document automation’
3. Under Select a solution / custom documents and invoices click the button and follow the installation Wizard that should pop-up – ‘Install Solution.’
4. Wait for the installation to complete.
5. Setup your connections from the ones that automatically appear or create your own.
And that’s the base-kit done! But wait…… there’s more……
Configuration 1 - Form Processing Model
Now here’s what could be the fiddly bit, getting things set-up.
Firstly you need a Form Processing Model. You'll need at least five examples of documents to do this.
After logging into Power Automate, select AI Builder, then Explore, then ‘Create.’
There are four stages to creating a Form Processing model:
Choose document type
Choose information to extract
Add collections of documents
Choose document type
Choosing a document type is straightforward. You have two options:
1. ‘Structured and semi structured documents’ – anything that follows a similar template each time. For example a company invoice.
2. ‘Unstructured or free form documents’ – generally documents that have built in paragraphs such as Contracts.
Power Automate will then make the next step available.
Choose information to extract
Here is where a bit of preplanning may be required. You need to know what information you are wanting to collate, as we are now beginning to teach the model how to operate. After we are clear on this, click ‘+ Add’, select ‘Field’, then enter the name of the data field names, for example, ‘Address’ or ‘Product No.’.
Once completed, click ‘+ Add’, then select ‘Single Page table’. This will collate tabulated data instead of a field. Enter the names of the table column headings that are necessary such as ‘Price’ or ‘Quantity’.
Add collections of documents
A collection is documents that share the same layout. Due to how the AI reads the documents, a different collection is required for each layout. For example, if two different customers use a different purchase order layout that is sent to your organisation.
For each collection, select ‘New Collection’ then name it appropriately. For each collection, 5 documents are necessary in order for the AI to learn. Select ‘Add documents’, then follow the upload wizard to do so.
First, tag the defined Fields by dragging a rectangle around the correct data on the document, then click the corresponding Field name. Blue boxes should surround options that can be selected.
If a defined Field or Table is not in a document, you must tell the AI of this occurrence. Select ‘Not available in the document’ on the right-hand panel.
To tag a table, draw a rectangle around it, then select it’s name in the pop-up. We need to draw the rows and columns for the table. This is done by left-clicking for the row separators, then Ctrl and left-click to create columns. Then assign the headers by mapping the appropriate name to it. If the first row contains table headers, select ‘Ignore first row’ on the right-hand panel.
Complete with the remaining necessary documents.
When completed, click ‘Next’ and if all is present and correct looking select ‘Train’ to start the AI learning capability.
To finish, Use the 'Quick Test’ function and if all is well, ‘Publish’.
configuration 2 - Received Emails
To process emails how your organisation requires them to, start by clicking ‘View Solution’ on the ‘Document automation’ page in Power Automate.
Select ‘Document automation base kit’ then ‘Document automation Email Importer’. Click ‘Edit’ on the top banner.
A flow will appear! It should have the title of ‘When a new email arrives (V3)’. Set this to your needs but ensure that ‘Include attachments’ stays as ‘Yes.’ Otherwise it won’t work!
Configuration 3 - Models
To configure the model to how your organisation requires, start by clicking 'Document Automation Application' in the ‘Document automation’ page in Power Automate.
Select the 'Configuration' tab, then 'Add configuration'.
Select your published form processing model.
Click 'Save' when you are happy with overseeing which fields will be mapped into Dataverse.
Just a bit of security admin to complete things. On the top banner, right hand side should be three dots. Select. Then select System Views (at the bottom).
On the left pane click Security Roles, then select System Customizer in the middle panel.
For the most correct settings, follow the image below.
What should the results look like?
When documents arrive in a user email box the Document Automation Email Importer should begin. The email is detected, the data extracted, and the AI called. The data is saved in preparation for review. Whomever is assigned the role of reviewing documents in the organisation then validates the document.
Exporting the data is not yet functional at the time of write with the Document Automation Application.
If you wish to do so, then:
Go to Power Apps, then 'Data'.
Click the 'Tables' menu, then the 'Document Automation Data' table.
Select the 'Export data' button
Enjoy the mechanical revolution!