Scan & Save Data from Images Using AI & Custom Pages in Power Apps

Sending
User Review
0 (0 votes)

In a recent client requirement, we developed a solution to streamline business card processing by leveraging AI and Power Apps. The goal was to scan business cards, extract their data, and display it seamlessly on a custom page. To achieve this, we built a custom page in Power Apps where users can upload a business card image. This triggers a Power Automate flow integrated with an AI model that extracts key details like name, company, and contact information. The processed data is then passed back to the custom page. We implemented the following steps to achieve this.

Steps to create an AI model

1. Open https://make.powerapps.com/ -> Navigate AI hub -> AI models -> Choose Document processing template

Custom Pages in Power App

2. Click on Create custom model

Custom Pages in Power App

3. Choose Document type -> Next
Custom Pages in Power App

4
. Click on ADD -> Define the variables for the data you want to extract from the image ->Done->Next

Custom Pages in Power App

5. Create a New Collection or Add documents -> Next


Custom Pages in Power App

6. Tag the documents by selecting fields such as first name, last name, and others and mapping them to the corresponding variables ->Next

Custom Pages in Power App

Custom Pages in Power App

7. Train and publish the AI model.

Custom Pages in Power App

  • Create a Custom Page and Power Automate Flow

1. Create a solution in your environment -> Add a custom page to the solution.

Custom Pages in Power App

2. Name the page accordingly -> Click on Insert -> “Add Picture“.

Custom Pages in Power App

3. The page will appear like this. After adding the ‘Add Picture’ Then you can design the page according to your requirements.

Custom Pages in Power App

4. Click on ellipsis -> Power Automate -> Add Flow -> Create new flow -> Create from Blank.

Custom Pages in Power App

Custom Pages in Power App
Custom Pages in Power App

5
. Give the name for the flow and add a text input to store the JSON-formatted image, which we will pass from the custom page.

Custom Pages in Power App
6. Create a variable to store the image’s base64 data.
Custom Pages in Power App

7. Parse the JSON-formatted image using the ‘Parse JSON’

Custom Pages in Power App
8. Set the variable base64ImageVar to store the base64 image data.

Custom Pages in Power App

split(string(body(‘Parse_JSON’)), ‘,’)

9. Use the AI model to extract data from the image.

Custom Pages in Power App

base64ToBinary(replace(variables(‘base64ImageVar’)[1], ‘\””}’, ”))

10. Return the extracted data as a response to the Power App.

Custom Pages in Power App

11. Save the flow and go to the custom page. Now you can see your flow in the Power app

Custom Pages in Power App

12. Design the page as required. In the ‘OnSelect’ property of the AddMediaButton, call the Power Automate flow with its name (in our scenario the name is ‘SendImageData’), which will take a JSON-formatted image as an argument and store the response in a variable called ‘BusinessCardReader.

Custom Pages in Power App

Set(BusinessCardReader,SendImageData.Run(JSON(UploadedImage3_1.Image, JSONFormat.IncludeBinaryData)));

13. Read the response from the Power Automate flow, which is stored in BusinessCardReader. Below is the code snippet that stores data in BusinessCardCollection. You can add the code for other fields and give validation.

Custom Pages in Power App

Set(BusinessCardReader, SendImageData.Run(JSON(UploadedImage3_1.Image, JSONFormat.IncludeBinaryData))); If(!IsBlankOrError(BusinessCardReader), Collect( BusinessCardCollection, { FirstName: Text(BusinessCardReader.firstname), LastName : Text(BusinessCardReader.lastname), Email: Text(BusinessCardReader.email), Company: Text(BusinessCardReader.company) } ) )

14. Add a Gallery control on the second screen and display the data by setting the Items property of the Gallery to BusinessCardCollection. This will allow the gallery to show the extracted information from the business card images.

Custom Pages in Power App
Custom Pages in Power App
If(!IsBlank(ThisItem.FirstName),”Name : “& ThisItem.FirstName &” “& ThisItem.LastName,ThisItem.FirstName &” “& ThisItem.LastName)

15. Apply this to all text fields and display them in the gallery. After running the application, it will appear as shown below.

Custom Pages in Power App

Conclusion

This solution shows how AI and automation can make manual tasks easier and faster while improving accuracy. By using AI with custom apps, businesses can manage their data better and stay ahead in today’s digital world.

Inogic's

The post Scan & Save Data from Images Using AI & Custom Pages in Power Apps first appeared on Microsoft Dynamics 365 CRM Tips and Tricks.

Leave a Reply