Expense Management with AI Builder for Dynamics 365 F&O

Hello Dynamics & Power Community !

One of the fundamental challenges with artificial intelligence is that it has historically been out of reach for the many. With limited access to highly sought after resources, drawn out development times, compounded with the added complexity of needing special purpose infrastructure to facilitate the AI development process, there has understandably been various barriers of entry for the broader user base to harness the types of capabilities that fall under the AI domain.

AI Builder is part of Microsoft’s ongoing efforts to democratize AI, empowering users of all skill levels to build, train, and publish AI models in a no-code, guided, point and click environment. It’s now in Global availability state, anyone can infuse AI within their business applications with PowerApps, or add intelligence to automated work processes with PowerAutomate, especially like in Dynamics 365 Finance and Operations use cases !

image-asset.png

High-Level Process Flow

  1. Select a model type : Supported scenarios currently include Binary Classification, Form Processing, Object Detection, and Text Classification.

  2. Connect the model to data : AI Builder can train models based off data that resides within the Common Data Service.

  3. Configure the model : Follow the point and click model building wizard interface. No coding required.

  4. Train the model : This is an automated process handled by the AI Builder service, based on the previously provided inputs.

  5. Publish and use the model
    As an example, there are special AI Builder components available within PowerApps such as a Form Processor or Object Detector. These objects can be connected to a published model.

ai_builder_flow.png

Here are below all AI Builder models (at this time : May 2020).

  • Business Car Reader

  • Object Detection

  • Category or Binary Classification (Prediction) : An AI model that classifies elements of a given data set into two distinct groups by understanding historical data patterns with historical outcomes. Use this AI model for any business questions that can be answered in one of two options (e.g. yes/no, pass/fail, go/no-go). Use cases: Fraud/Not Fraud, Credit Approved/Credit Declined, Customer Churn/Not Churn, etc.

  • In my case for FinOps that I love are : Form Processing and Text Recognition ! It will be my show case here in this article.

Screenshot 2020-05-05_12-54-25-780.png

Expenses showcase

AI Builder costs for the whole tenant around 500 € / month, but depending on the number of expense reports and employees, so therefore the time lost to make a double entry, you will be largely a winner, believe me!

In addition, what is the point of making a double entry by the employee or even an accountant in the ERP when all the important data are already present in the document that (fun?) already has to scan necessarily. It is therefore time lost by several people in the company, who can clearly do something more intelligent!

Finally, you can of course use other models with other flows to better serve a lot of manual flows in your company with Finance and Operations. If you buy the license, you might as well use it for several scenarios. (like Form Processing, for the Warehouse management with product bar code scan etc….)

There is a standard Microsoft mobile application connected to Dynamics365 FinOps for expenses but it is complicated to configure, in addition it implies that the employee has access to Dynamics 365 Finance and Operations or assistance must re-enter everything in the mobile app. For my showcase, the end user has just to download the PowerAutomate Apps, share the flow in read-only and that’s it ! He/she can after launch the flow without any licenses in Dynamics 365 Finance and Operations, quite good no ?

I think this expense management is really important and a real almost global use case for all companies with an ERP, all employees have expenses! Which shows the interest of PowerPlatform in top of Dynamics 365 Finance and Operations !

We could possibly do that with the PowerApps with the AI Builder component or even ask the employee in the PowerApps Portal, to upload the expense which after triggers the flow :)

Finally possibly an employee who has spent his time with his printer in chain scanning several expense reports, this will generate a PDF sent directly to the employee's email, which can be the trigger of the PowerAutomate flow. But like usual, with PowerAutomate we can imagine a lot of different possible triggers !


Let's talk little, let's talk well. Now that things are said, let's get down to business!

First, you can download all samples that I will show in my Github project here :

Sample PowerAutomate flows in order to create automatically Expenses in Dynamics 365 Finance and Operations with the AI Builder of the PowerPlatform.

1/ You will need a Trial or license of AI Builder

2/ Import also the Data Entity (IMPExpTransV2) in your Dynamics 365 FinOps DEV tenant & deploy it (.axpp file with Import Project wizard in Dynamics365 Visual Studio Addin - don't forget to change to your Model Solution)

3/ Import first the childflow

4/ Import the main flow AI Builder + change the URL of the last call at the end of the flow with the generated URL coming from the child flow before.

5/ See if you have a worker assigned in your Systemuser account in Dynamics365 FinOps, as well as a manager with HR module with job positions hierarchies.

6/ Test it with like the example of the expense attach in this github project.

DISCLAIMER : It's just a proof of concept, and don't use it (yet) in production environment. It's just a demonstration and you will need to change/improve based on the use case you want to achieve.

List of Improvements :

=> Ask for a project in the input of the Flow (if you want to have a relationshipt between a project in FinOps and the expense of the end user)

=> Detect automatically the category of the expense (at this time I put hard coded TEST)

=> Attach the expense with DocuRef entity after uploading in your sharepoint repository.

=> Improve the delimiter for the Transaction Date and Total Amount + Currency based on your template of expense in your country.


I will explain now each steps of my flow.

First step, of course since I use the AI Builder Text Recognition, I need the end user to give me the expense :) - After I have a lot of INIT variables, keep in mind here that I have built 2 variables to detect the transactionnal date of the expense and the total amount. You can change that depending of your basic expense template you faced in your market. Maybe to add like a Regex expression to be better than mine :)

PowerAutomate-AIBuilder-1.PNG

After I use the Office 365 connector, to get all informations from the end user that had trigger the flow. (like his email address and so on)


PowerAutomate-AIBuilder-2.PNG

This part is important, because it will give me the possibility of recovering the employee attached to the user account in the HR Module of Dynamics 365 Finance and Operations. I just use the Workers Data Entity in standard in FinOps for that with the previous result with a Query (ODATA)

PowerAutomate-AIBuilder-3.PNG

After, it’s my “Manager” part , because as you will see I want that the manager approve, or not, the expense.

So I use for that all data entities in standard to retrieve in the HR Module, the position hierarchies in Dynamics 365 FinOps. It will give me with the job position, who are my manager ? And give me his/her email address.

PowerAutomate-AIBuilder-4.PNG

Now, we have my manager, good :)

We will go to the next part, nothing complex to say because it’s just calling the AI Builder model for Text Recognition of the expense. I just put the result to an array to have all “lines” of text.

PowerAutomate-AIBuilder-5.PNG

UPDATE 10/05/2020 : You will need to use the Expression “ base64ToBinary” function in the Predict part of your InputImage. Otherwise, it will not work on Mobile PowerAutomate Apps and just in Desktop/Web. Like this :

Screenshot 2020-05-10_16-26-43-636.png

After, it’s the more complex part of the flow, well if you say so… because it’s not very difficult but maybe to improve a little bit for production.

For each page, and each lines of my expense, I check to see if it’s the TransDate of my expense, as well as the Total Amount. Here we can also add a VAT Check to get the VAT Percentage & amount, and also the NAF/APE Code to know which type of expense is it. Because as you will see I didn’t manage that, but in France, in expense at the end of document, we have a code that can say if it’s more an expense for restaurant, hotel, travel etc…

I also get the Currency automatically.

PowerAutomate-AIBuilder-6.PNG

After I just add 2 compose components, but it was for me just to handle the tricky part of French format (comma and period for float number) and also for the date format (ISO 8601) like month/day/year and not day/month/year. You can erase this part if you don’t need it for your use case and depending in which country/format you are.

PowerAutomate-AIBuilder-7.PNG

Next, we can create the expense in Dynamics 365 Finance and Operations, because we have all needed now.

So the Data Entity is my only development part, because in standard we just have a basic Data entity called “Expenses” but it’s on read only state and we can’t extend it….

So I have created a new one, it’s on the Github project if you want to get it faster. I just put after all fields needed. I have highlighted here in yellow, all hard coded stuff, so it’s here the improvement needed to better add the Payment Method and the Expense Type / Category like I said earlier.

PowerAutomate-AIBuilder-8.PNG

Now, the expense is in Dynamics 365 FinOps.

I will ask my manager directly in Microsoft Teams (that we get earlier in the beginning of the Flow) by a Bot if he/she is OK with that :)

I use the standard connector, with a choice of options. I try to use the Adaptive cards, but I was almost septic, because it’s just in preview and I was not very happy for the result. But you can check and try to it with this method :

PowerAutomate-AIBuilder-9.PNG

After I get the response (see that the flow will continue to run before we’ve got a response), we can now call my child flow to approve or reject the expense.

But first, I also added a small part to upload the expense in a Sharepoint folder. The improve part here will also to link it after in Dynamics365 expense record to the DocuRef table/Data entity with the sharepoint file uploaded.

PowerAutomate-AIBuilder-10.PNG

I also add 2 push mobile notifications to inform the user if this expense report has been accepted, and if not in the case of a refusal, the comment left by the manager in Microsoft Teams.

PowerAutomate-AIBuilder-11.PNG

For the child Flow I just call my methods created to my own Data Entity that you had managed to import it with my Github project.

PowerAutomate-AIBuilder-12.PNG

And voilà ! Finish.


Let’s make a quick DEMO here.

So the user now can open up the flow when you share it in readonly state, in his/her mobile with the Power Automate App.

C53714CE-13E0-4334-A838-FDB4C335B253.png

When it launch it, it will be asked to take by camera the expense or upload a previous one in his/her library.

7F5A6646-3FCB-45DE-B2AE-E1B782E84388.png


This will launch of course the Flow.

PowerAutomate-AIBuilder-13.PNG


At the last step, of course we have the approval part.

PowerAutomate-AIBuilder-14.PNG


The user will receive a notification

9AD323EE-8305-4AEF-84BF-D71723E585A8.png


And finally, of course in Dynamics 365 FinOps we have the expense here and in approved state :)

PowerAutomate-AIBuilder-15.PNG


Hope you enjoyed it ! Let’s continue to add insights and AI Builder to Dynamics 365 Finance and Operations process !

You can share it, contact me if you want to improve it together. Feel free also to add me on social networks !