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! 😁

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: and twitter I also write at, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – Youtube channel -