Showing results for 
Search instead for 
Did you mean: 

Handling Company Invoices & Bills With Microsoft Flow

I am running my own company for years. Every month I need to gather all cost bills and invoices (really 95% of them are sent via mail), put them in a single e-mail and send to my accountant. Previously every such e-mail I received, I had to flag, then copy its attachment to a draft mail that was sent by the end of month to my accountant. Manually it was a significant amount of work

Therefore I decided to built a Flow and to engage LUIS for help. The process is quite simple:

  1. When a new e-mail with attachment arrives
  2. Calculate intent 
  3. If above 0.9 automaitcally process it
  4. If above 0.7 assign me a task, that if approved pushes e-mail for processing
  5. Flag mail
  6. Forward it to accountancy
  7. Copy attachments to OneDrive
  8. Enter details to Excel file

LUIS (Language Understanding Intelligent Service)

I decided to utilize the power of Cognitive Services to automatically parse and verify if the received e-mail contains invoice or not. For this purpose I have created new app under: and then two Intents: Invoices and None:



Next, I created an Entity (type Simple) containing keywords (Role names) identifying invoice-related contents, such as: "invoice", "bill", "itinnerary", etc..., for languages in which I usually receive documents (English, Polish, German):



Then I used already received e-mails to train my model. And also, while adding, to bind keywords with Role names:



To do that simply hover keyword (1), then open the created Entity (2), and then select related Role name (3).

Finally I hit "Train", so that my model became ready to test:


Next I verified for some random mail bodies, if the model works fine and finally I've published it.

The Flow

Below is the initiation part of the Microsoft Flow I am using


  1. When a new e-mail with attachments arrives
  2. Convert its contents from HTML to pure text
  3. Next, it's checking if body length is longer than 250 characters.
  4. If yes, it's triming content for calculating prediction to only 250 characters - I noticed, that when trying to post all characters from e-mail, action for calculating prediction was failing. If not - no changes are made.
  5. Next LUIS is taking care of calculating prediction,
  6. And finally is converting the result to float value.

Next it's checking if the prediction value fits within tresholds:


  1. If value is above 0.9 and the Top Scoring Intent Name is "Invoices" then...
  2. it's pushing mail for automatic processing.
  3. Otherwise it's checking if the value is above 0.7
  4. If it is, it's assining me a task, to verify if the mail contains invoicing documents. Here I am using P1 action with custom outcomes: Approve, Reject, Not applicable. The last option here is for a scenario, where I receive e.g. an e-mail with a comment to already received invoice - therefore it is just bypassing the whole mechanisms and terminates the process.
  5. Then evaluating the outcome.
  6. Otherwise terminating the flow.

If the score is bewteen 0.7 and 0.9, Flow is moving into "Switch" action, to check outcome of the approval:2019-07-10_14h51_34.png

  1. The "Switch" action evaluates outcome of the approval. For both "Approve" and "Reject" it's doing the following:
  2. Adds new utterance to intent - either "Invoices" (if approved) or "None" (if rejected)
  3. Then trains the model
  4. If the outcome was "Not applicable" it is terminating Flow to not execute other logic.

Adding utterances to intents and training the model is done using P1 HTTP actions, that are using LUIS endpoints as described here:

Next Flow is processing the mail itself:2019-07-10_14h56_55.png

  1. It falgs the mail, so that I have it in my tasks and I can review if I need to pay it or not
  2. It forwards it to accountancy
  3. Finally, for each attachemnt it copies it to my OneDrive to a folder with current month-year name (if it doesn't exist - it's being created)
  4. And enters information about the e-mail and attachment to an Excel file storing all processed e-mails.

Final words

This is how the Flow works - it saves me really lots of work. What I wish it is also able to do, is to read through the attachments to automatically discover the amount, payment due date etc... so that it would also be able to:

  1. Create me a To-Do task for making the payment
  2. Register cost information in Excel file so later I can see the values

However since the documents are mostly often PDF files, and having different formats, there is no easy way today to get these information using Microsoft Flow only. Possibly one day OCR present in Cognitive Services actions will allow also to process PDF files.

Here is the video that I recently posted covering this scenario!

I hope you find this process inspirational for covering your own needs. If you have any quesitons reach me out here or via my blog ( or through Twitter (@TomaszPoszytek).

Thanks for reading! 😁


Great post, for the pdf invoices, could you use AI Builder form processing feature?


Unfortunately not. I can't use AI Builder. Since that feature is dedicated to PowerApps. I can't utilize it inside Flow so far I know. Or may I be wrong?

I have been able to utilise Business Card AI into flow to capture fields and push to Dynamics, so I am not sure but in general you can add PowerApps trigger and it can generate fields with values out of AI model. See this blog post at the bottom.

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc (
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor