Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions prompts/ai-builder/invoice-data-extractor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Invoice Data Extractor

## Description

This prompt uses AI Builder's **image input** capability to extract structured data from invoice images or scanned PDFs. It returns a complete JSON object with all billing fields — vendor, line items, totals, tax, currency, and payment terms — ready for direct consumption by Power Automate without manual data entry.

This is the first prompt in the repository to use an **image-type input** (`invoice_image`) rather than text. It demonstrates how AI Builder's multimodal capabilities can replace dedicated OCR or document processing pipelines for common finance automation scenarios.

A null value is returned for any field not found on the invoice, making the output safe to use in downstream flow conditions without causing parse errors.

## Prompt

> You are an invoice processing assistant. Analyze the [invoice_image] provided and extract all relevant billing information. Return the result strictly as valid JSON with fields: invoice_number, invoice_date, due_date, vendor_name, vendor_address, bill_to, line_items (array), subtotal, tax_amount, tax_rate, total_due, currency, payment_terms. Set missing fields to null.

### Supported Language(s)

- [English - US](./en-us/prompt.md)

## Authors

Solution|Author(s)
--------|---------
Invoice Data Extractor | [OwnOptic](https://github.com/OwnOptic) ([@OwnOptic](https://twitter.com/OwnOptic))

## Minimal Path to Awesome

1. Navigate to [AI Builder](https://make.powerapps.com/) and select **AI Builder** > **Explore**
2. Choose **Prompt** and click **Build your own prompt**
3. Copy the content from [prompt.md](./en-us/prompt.md) and paste it into the prompt editor
4. Add an input named `invoice_image` of type **Image**
5. Test by uploading a sample invoice image (PNG or JPEG)
6. Save and publish the prompt
7. Use it in a Power Automate flow:
- Trigger: **When an email with attachment arrives** (Outlook) or **When a file is created** (SharePoint)
- Action: Call this AI Builder prompt, passing the attachment as the image input
- Action: **Parse JSON** with the schema above
- Action: Create a record in Dataverse or post to an AP system

## Disclaimer

**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

<img src="https://m365-visitor-stats.azurewebsites.net/powerplatform-prompts/samples/ai-builder/invoice-data-extractor" aria-hidden="true" />
53 changes: 53 additions & 0 deletions prompts/ai-builder/invoice-data-extractor/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/pnp/samples/v1.0/metadata-schema.json",
"name": "pnp-powerplatform-prompts-invoice-data-extractor",
"version": "1.0.0.0",
"source": "pnp",
"creationDateTime": "2026-03-02T00:00:00Z",
"updateDateTime": "2026-03-02T00:00:00Z",
"title": "Invoice Data Extractor",
"shortDescription": "Extracts structured billing data from invoice images using AI Builder's image input — vendor, line items, totals, tax, currency — returned as strict JSON.",
"longDescription": [
"First repository prompt to use an image-type input. Analyzes invoice images or scanned PDFs and returns a complete JSON object with all billing fields (invoice number, dates, vendor, bill-to, line items array, subtotal, tax, total, currency, payment terms). Null values for missing fields ensure safe downstream processing in Power Automate. Replaces dedicated OCR pipelines for AP automation."
],
"url": "https://github.com/pnp/powerplatform-prompts/tree/main/prompts/ai-builder/invoice-data-extractor",
"products": [
"AI Builder",
"Power Platform",
"Power Automate"
],
"tags": [
"INVOICE",
"OCR",
"IMAGE INPUT",
"JSON",
"FINANCE",
"ACCOUNTS PAYABLE"
],
"categories": [
"AI Builder"
],
"metadata": [
{
"key": "prompt",
"value": "Analyze the [invoice_image] and extract all billing fields as strict JSON. Set missing fields to null."
}
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/powerplatform-prompts/main/templates/previewprompts.png",
"alt": "Preview"
}
],
"authors": [
{
"gitHubAccount": "OwnOptic",
"name": "OwnOptic",
"pictureUrl": "https://github.com/OwnOptic.png"
}
]
}
]
41 changes: 41 additions & 0 deletions prompts/ai-builder/invoice-data-extractor/en-us/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
You are an invoice processing assistant. Analyze the [invoice_image] provided and extract all relevant billing information.

Extract the following fields:
- Invoice number
- Invoice date (format: YYYY-MM-DD)
- Due date (format: YYYY-MM-DD, or "Not specified" if absent)
- Vendor name
- Vendor address
- Bill-to company name
- Line items: for each line, extract description, quantity, unit price, and line total
- Subtotal
- Tax amount and tax rate (if shown)
- Total amount due
- Currency (ISO 4217 code, e.g. USD, EUR, GBP)
- Payment terms (e.g. "Net 30", or "Not specified" if absent)

Return the result strictly as valid JSON using this schema:
{
"invoice_number": "string",
"invoice_date": "string",
"due_date": "string",
"vendor_name": "string",
"vendor_address": "string",
"bill_to": "string",
"line_items": [
{
"description": "string",
"quantity": number,
"unit_price": number,
"line_total": number
}
],
"subtotal": number,
"tax_amount": number,
"tax_rate": "string",
"total_due": number,
"currency": "string",
"payment_terms": "string"
}

If a field cannot be found on the invoice, set its value to null. Do not include any text outside the JSON object.