Recently I came across with a requirement by a client to input data automatically in a desktop legacy app which has no exposed API or integration method available also my client did not have any intentions of extending that app.
Complete requirement was to automate their manual process in a way to automatically extract data from attachments(PDF/Images) upon receiving email, create record in Dynamics 365/Power Apps CDS with extracted data also input same data in legacy app.
This kind of implementation would require usually Weeks/Months to develop\test and then deploy in different environments. With power platform and using its components even a non technical person could easily implement this requirement in couple of hours.
lets quickly jump to implementation!!
To implement this I will be configuring/using 4 components of power platform. My client already had a shared mail box setup but if you dont you can follow the steps mentioned under 1. Mail box setup. Otherwise skip first step.
1. Mail Box Setup
If you don’t have office365. You can easily create a trial from here https://portal.office.com
Once you have created. then create a shared mail box by following steps below
Click on Top left dotted icon and then on Admin option
Click on Show all then Click on Exchange option. In Exchange Setup screen click on Recipients and then on Shared link.
Click on + icon then add details. Add the user account as shown in image below
Add this mail box to your outlook. Click on file on the menu. Then Add account. Provide the same email address and password you provided when created trial. This will add your D365 Account and shared folder. Which can be seen on the left below. Restart outlook if you don’t see it.
Our Shared mail box is all setup. Now lets proceed to implement the requirements using Power Automate components.
2. Train AI Builder to Predict and extract data from Email Attachments
Now we will train the AI builder. Which will intelligently identify and extract the required data from attachments.
Click on Admin and click on Power Automate icon. If you don’t see it then click Show All apps
Expand AI Builder and then click on Form Processing. There are other options available which also help predict data from different sources.
Form processing requires you to train it by providing some sample data. Such as shown in images below I have provided 5 images of invoices. It will analyze the provided documents.
Then it will ask you to identify data which need to be extracted
After Fields have been identified. Click on Train button to train AI builder.
After AI shows the confirmation that its training is complete you can save and close it.
3. Create UI Flow: Robotic Process Automation to input data in Legacy App
Before we jump into implementation of UI flow. We should know what input our legacy app requires. I created a dummy .net form based desktop app. You can use any desktop app. My app just takes two input fields and it has one save button to save data.
In the power Automate click on UI Flow on the left menu. Then provide the name
You have both options web and desktop app. Chose desktop. Provide the name of the UI Flow.
Then you will have to add expected text input data. You can put any value at this stage.
On click of next button a screen will display option to download and install Flow UI package. Download and Install it on the machine where you want to host your legacy app.
After installation click on the link “here”. This will take you to the page where you can add and enable the Flow UI Extension.
You can use Recorder with Chrome and with Edge based chromium browser. You can download it from here https://support.microsoft.com/en-au/help/4501095/download-the-new-microsoft-edge-based-on-chromium
Once it all setup. Restart the browser. You will see a launch recorder button. Click on this button launch the recorder.
Once recorder is launched open your legacy app and then click on Record button to start recording. Once done, click on Done button and save this UI Flow. You can also test this flow right away.
After saving it you can also see each steps recorded in flow.
4. Now put all components together in Power Automate-Flow
As we have configured all the components required. We will now use these components in a flow to make it work for us.
- Put Trigger on the Shared Mail Box
In power Automate click on Flow in the menu. Provide a name and then search for email. Select the “When a new email arrives (V3) office 365 Outlook”. Click on sign in to connect the shared box.
Click on advanced options and provide the below mentioned information. You can also put specific email addresses in To.
- Add AI Builder to the FLOW:
Click on Action and add Predict (Common Data Service). If you don’t see this in the list. Then create a solution and create flow inside from that solution.
Select the AI builder we created before.
Put the expected attachment types in Document Type field and then select Attachment Content in Document field.
- Add Robotic Power Automation component UI Flow to Power Automate Flow
We require to download and install Gateway on the machine where legacy app is hosted to allow access to our UI Flow. Download standard gateway from this link. https://docs.microsoft.com/en-us/data-integration/gateway/service-gateway-install. Provide your credentials to gateway. The same email address and password you used to create D365 trial.
Once you are successfully signed in. Gateway will display the message that its up and running as shown in image below.
Now Add action and search for UI Flow and select Run for UI desktop.
Now provide the local login details to connect with your Gateway in the UI Flow
Then select the UI Flow we created earlier.
Your complete flow will look like this in image below. I have created a Parallel branch which is not necessary to create. Also you can select the Run mode to either attended or unattended. I have selected attended which will open the app and input data which can be seen. Unattended will run app in background.
All of our components are now integrated. Lets test. I will send an email to the email address associated with the shared mail box to trigger this FLOW. You can also test this flow quickly by sending email to the same address and then select the option “Use data from 365 outlook”.
A successful flow execution will automatically open the legacy app and input data from the email attachments.