Automatically process Uber Receipts for expense approvals using AI Builder

Photo by Acharaporn Kamornboonyarush on

A common scenario in most of the businesses is for employees to collect their receipts of the expenses made and then submit expenses along with receipts at the end of the month (or week/fortnight) for reimbursement. This creates a long queue (aka processing time and possible delay in processing) for HR/accounts team to review each receipt for approval. In this article, I have experimented with AI Builder to see if it can help in making the process faster and easier.

An example scenario here considers submission of an expense through a model-driven Power Apps app, but this could be used in Canvas Power App, Dynamics HR, emails or even any other system that connects with CDS. The process is to auto-approves the expense in expense in record tallies with the ‘Total’ field in Uber receipt or sends for further approval (manual offline process).

This demonstration requires three components to be built:

  1. A model-driven Power Apps app with an expense entity and form

  2. An AI Builder model to process Uber receipts

  3. A Power Automate flow to run on the create/update of expense, trigger AI Builder model and based on the result, change expense status

Step 1. Model-driven Power Apps app

Create a new PowerApps model-driven app and create an entity ‘Travel Expense’ entity with three fields:

a. Title

b. Total Expense ($ value)

c. Status

Note: An entity should support notes and attachments.

Also note: this step is not discussed in detail in this app. If model-driven apps are new for you, have a look at this excellent Microsoft docs resource.

Step 2. Create an AI Builder Model

Goto Power Apps maker portal and click on AI Builder on the left.

Click on Form Processing. You’ll notice the Examples and Best practices tab which have great tips on setting up AI models. Enter the name of your model (Read Uber Receipts - for example) and click on Create.

Next screen will ask you to upload documents. Select the files and upload.

Once the documents are uploaded, click on Analyze.

Now the AI engine will run..

..and it will ask you to tag the fields which it was able to find in the documents.

Select the Total field on the document and label it.

Click ‘Done’ and click ‘Next’

Next click on Train to train the newly created model

Once the training is completed..

..go to the Details page. This shows the document that is used to train the AI model, field identified during form processing and how to use the model (Power Automate and Power Apps).

You can also do the quick test by uploading another document and let the AI model find data in the document. Publish the model.

Step 3. Create Power Automate Flow

Go to the solution (created in Step 1) and click on New-> Flow to create a new flow.

Create a flow with a CDS trigger on the entity that we created in Step 1. Next, find notes associated with the expense record, fetch attachment in Notes and then use ‘Apply to each’ to run an AI model on each file. For calling the AI model, use ‘Predict’ action.

Next, fetch the result from the AI model and compare with the expense entered by the user in the form. If both match, then approve the record, else send for manual review.

Lastly, let’s test it out:

  1. Create a new expense record and attached an Uber receipt:

.. in the background, the flow ran:

Record gets updated to manual approval process (In Progress) if expense record total doesn’t match total in receipt:

..otherwise it gets auto-approved:

Hope you will find this useful. Please feel free to share your feedback :)