Invoice GL coding with Power Automate and AI | AI Prompts for accounting automation

We’ve already covered how to use Power Platform for AP Invoices automation in a previous blog, and today, we bring you how to incorporate AI prompts to automatically recognize which GL account, company and cost center should be assigned to the invoice based on the invoice content.

This blog will show the step-by-step process to automate Invoice GL coding with Power Automate and AI. We will create a custom AI prompt using AI Builder and we will call this prompt from a Power Automate workflow.

Manual GL coding can be very time-consuming and prone to human error, mainly when handling large volumes of invoices. Automation with AI and Power Automate can help you to:

  • Accelerate invoice processing
  • Minimize human errors
  • Ensure compliance with company coding rules (e.g., operations costs start with 5, admin costs start with 6).

Use case description

The use case involves receiving invoices as PDFs via email, storing them in a SharePoint folder, and then automatically extracting and categorizing key invoice details such as expense type, contact person, company, cost center, and GL accounts.

The requirement is to extract the following information from the invoice:

  • Contact person
  • Invoice number
  • Invoice total amount
  • Invoice lines descriptions

Based on above, the prompt should be able to derive the following:

  • Company and cost center based on the contact person
  • Appropriate GL account based on expense type and invoice lines.

Catalog Data for Company, Cost Center and GL Accounts

We have an Excel file contains that two key tables:

Contacts: Names, associated companies, departments, and cost centers.

GL Accounts: GL codes categorized by expense type (e.g., operations costs start with 5; admin costs start with 6).

Turn your ideas into digital solutions

Our team guides you step by step to build custom apps in Power Platform.

The idea is that accounting users can update these catalogs at any time and the automation will pick up the latest list every time, accommodating changes in personnel, companies, or accounts without needing to hardcode these lists.

End result

Once all information is extracted form the invoice and once Company, Cost Center and Account have been identified, for the purpose of this example, we will store this information in a SharePoint list but we can really do many things:

  1. Submit the invoice for review so the accounting team can validate the account assigned
  2. Route invoices with incomplete information to an accountant for manual review
  3. Create the invoice in draft mode in our accounting system (SAP, Oracle, QuickBooks)
  4. Directly post the invoice in the accounting system (SAP, Oracle, QuickBooks)

Step-by-step walkthrough

Create Power Automate workflow

Go to the “AI hub” section in the Power Automate portal and click on “Prompts”

Then use the “Build your own prompt” option

Write some initial instructions and then hit on the “send” button

This will generate the initial version of the prompt, which can be updated at any time.

Click on “Keep it” and then you will be able to freely edit the text and add inputs.

For this scenario we added the following inputs:

  1. PDF Invoice (document)
  2. Contact list (JSON format, Text)
  3. Accounts list (JSON format, Text)

Once the prompt is ready, we can rename and it’s ready to test and use!

Create Power Automate workflow

Now it’s time to start bringing everything together. We’ll see how to build a flow that automates GL coding with Power Automate and we will call the AI prompt.  In the Power Automate portal, create a new workflow. Or open a solution and start a new automation.

Set up trigger

We will use an automated cloud flow for this use case, because we want this automation to run whenever there is a new file in the folder.

Retrieve contacts and GL accounts lists

As mentioned above, we’re storing the catalogs for companies, cost centers and GL accounts in an Excel file, so we will use the “List rows present in a table” action from Power Automate’s Excel connector to retrieve these lists.

Extract PDF content from SharePoint

The PDF content is part of the inputs we set up in the prompt, so we need to extract the file content from SharePoint before calling the AI prompt.

For this use the “Get file content” action and pass the “Identifier” attribute from the trigger as the file identifier field.

Add AI prompt action

Look for the “Run a prompt” action in Power Automate.

Once in place, select the prompt that we just created and when selected, the prompt inputs will show up as new fields in the action.

For Invoice, use the following Power Fx formula:

				
					@{base64(body('Get_file_content_-_PDF_Invoice'))}
				
			

For Accounts and contacts, select the complete output from the Excel results.

Save extracted information in SharePoint

Now it’s time to use the results from the AI prompt and store invoice data in our SharePoint list. For this, we will use the “create item” action in Power Automate and we will select the SharePoint list that was created to store invoices.

Test flow execution

This is how the final workflow should look:

From vision to execution

Whether you're just starting or scaling automation, we help turn your ideas into impactful solutions.

Upload an invoice to the SharePoint folder that was indicated in the trigger and see magic happening!

Once it runs, you will see the data being transferred to SharePOint

Some best practices and additional tips

  • Pagination in Excel Data Retrieval

Excel actions in Power Automate have a default row limit (~256 rows). If your contacts or GL accounts list exceeds this, enable pagination in action settings and increase row limits to avoid incomplete data. You can do this by going to the “settings” tab in the Power Automate action.

  • Handling Missing Invoice information

Some invoices may lack information, or the prompt may not be able to find all data points requested. It’s important that the workflow can handle these exceptions by routing these invoices to a human for manual review.

  • Maintaining Dynamic Data

For this example, we’re storing the contacts, companies, cost centers and GL codes in an Excel spreadsheet. Any other data source can be used for this purpose such as SharePoint, Dataverse or even the accounting system itself.

The key consideration is to ensure the prompt always receives up-to-date information, accommodating staff changes or new cost centers.

Step-by-step video

Head to our YouTube channel and watch a full step-by-step video to learn how to use Power Automate and AI Builder prompts to automate GL Coding for AP invoices.

How our Power Platform Development services can help

Using our Power Platform consulting services and Agentic automation services we have helped finance and accounting teams save hours of manual work by combining AI Prompts and Power Automate.

Contact us, we’ll be more than happy to have a conversation and see how we can be of help to your team.

Author
Power Platform Consultant | Business Process Automation Expert
Microsoft Certified Power Platform Consultant and Solution Architect with 4+ years of experience leveraging Power Platform, Microsoft 365, and Azure to continuously discover automation opportunities and re-imagine processes.