Azure AI form intelligence is a wonderful way of reading image invoices. You can now create a document intelligence API and pass on an image document, with preseiely reading embdded words, figures and everything. They return contents in both literature as well as JSON based contents. And guess what? Whenever there is a JSON based content involved, obvously you can leverage them on Azure middlewares like Azure Logic Apps, can't you?
Reading such a JSON response could be tricky. And this document can give you a fair idea to achieve this.
And here are the steps:
Step 1: Create a Document intelligence API: Go to https://portal.azure.com and create a new Form recognizer resource:
For our demo purpose we are selecting 'Standard' pricing tier. Alternately you can also select Free tier, if needed.
Click 'Preview + create' >> Create finish the wizard. It will take few moments to create the resource. Come to the resource thus created and note the endpoint and access keys associated:
Click on 'Go to document intelligence studio'. It will open a new page where by default you can see a lot of options:
After upload, the document intelligent will show the image preview like this, identifying all the embdded literals/words/figures:
Click on Run analysis. It clearly shows all the readable words/figures now:
Click on 'Content', it shows all the embeded table:
Click on Result tab. You can get the JSON associated with it, that contains each and every word, treating it as a 'control', along with its coordinates and the confidence with which it can identify the control. Let us inspect this JSON thoroughly, as we gotta understand it very well.
Copy the JSON and paste it in https://jsoneditoronline.org/#left=local.bazeza&right=local.zowiqo
and click on Beautify it. You will get the schema like this:
Which implies under the \\analyzeReult\\readResults >> 0th node >> lines>>from 17th Node onwards our lines details would start.
Step2: To do this, we can design a logic app, that is capable of reading from an added blob from a storage container like this:
I am using a variable to store the path of the blob and a counter variable, which I would be needing later.
Step 3: Next, add a 'Form recognizer' action with the details which you can get from Azure portal.
Account Key you cam get from the access key of the resource which you created from step-1.
Endpoint URL: you can get from Azure portal.
Use the output of the above step, it will look like this:
Step 3: Use two For-each loops, one for the outer loop to reach till \\analyzeReult\\readResults >> 0th node >> lines:
And the next one to loop through each item of the Lines:
Whew! Our Logic app is now ready. If you now put the invoice of this kind of sturcture in the Azure blob, it will very easily be able to take out the value of the associated line wise items:
The above screenshot is showing from node 18, the values of the line wise items are showing, as expected:
*This post is locked for comments