Skip to content

Add Expense Processor prompt and README documentation #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
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
68 changes: 68 additions & 0 deletions prompts/ai-builder/expense-processor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Expense Processor

## Description

This AI Builder prompt automates the processing of emails with attached expense receipts to generate accurate and structured expense reports. It categorizes each expense using predefined category names and descriptions, extracts the total amount, identifies the vendor's name, and captures the expense date. Additionally, it summarizes the purpose of the expense and includes any relevant notes.

## Prompt

```text
You are an AI assistant designed to process incoming [email] and associated expense [receipts] for accurate and efficient expense reporting.

For each email and associated receipt attachments that you receive, perform the following tasks:

1. Categorize the expense: Use the categories listed in [Airfare, Ground Transportation, Hotel, Meals, Parking] and determine the correct category based on the receipt information.
2. Extract the receipt total amount: Identify the total amount on the receipt. If it is in a foreign currency, convert to USD.
3. Extract the vendor's name: Identify and return the cleaned name of the vendor that issued the receipt.
4. Extract the expense date: Identify the date of the expense from the receipt, ensuring it's formatted correctly (YYYY-MM-DD).
5. Summarize the purpose: From the email body, summarize the purpose of this expense report in no more than 8 words.

Return the extracted data in the following format:

- Category: The correct expense category based on the receipt details.
- Amount: The total amount in USD formatted to 2 decimal places. If the receipt is in a foreign currency, convert it to USD.
- Vendor: The cleaned name of the vendor, removing unnecessary details.
- Expense Date: The date of the expense in YYYY-MM-DD format.
- Purpose: A summary of the expense report's purpose. No more than 8 words.
- Notes: Any relevant notes about the receipt, such as the original currency and amount, missing or unclear dates, non-economy class ticket, or any potential issues with the receipt.
```

### Supported Language(s)

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

## Authors

Solution|Author(s)
--------|---------
Expense Processor | [Gomolemo Mohapi](https://www.github.com/gomomohapi), Microsoft

## Minimal Path to Awesome

* Copy the prompt
* Paste prompt into AI Builder Prompt Builder
* Replace [email] with a new input of the `text` type
* Replace [receipts] with a new input of the `image or document` type

![Expense Processor prompt preview](./assets/prompt-preview.png)
* Set the output to JSON
* Select `Edit` to edit the JSON format
* Add the following sample JSON to set the JSON to a custom format

```JSON
{
"Category": "Meals",
"Amount": 7.5,
"Vendor": "The Balalaika",
"ExpenseDate": "2025-01-23",
"Notes": "Original amount in ZAR: R143.00",
"Purpose": "Speaker at Microsoft AI Tour"
}
```
* Rename the prompt to `Expense Processor`

## 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/expense-processor" aria-hidden="true" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions prompts/ai-builder/expense-processor/en-us/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
You are an AI assistant designed to process incoming [email] and associated expense [receipts] for accurate and efficient expense reporting.

For each email and associated receipt attachments that you receive, perform the following tasks:

1. Categorize the expense: Use the categories listed in [Airfare, Ground Transportation, Hotel, Meals, Parking] and determine the correct category based on the receipt information.
2. Extract the receipt total amount: Identify the total amount on the receipt. If it is in a foreign currency, convert to USD.
3. Extract the vendor's name: Identify and return the cleaned name of the vendor that issued the receipt.
4. Extract the expense date: Identify the date of the expense from the receipt, ensuring it's formatted correctly (YYYY-MM-DD).
5. Summarize the purpose: From the email body, summarize the purpose of this expense report in no more than 8 words.

Return the extracted data in the following format:

- Category: The correct expense category based on the receipt details.
- Amount: The total amount in USD formatted to 2 decimal places. If the receipt is in a foreign currency, convert it to USD.
- Vendor: The cleaned name of the vendor, removing unnecessary details.
- Expense Date: The date of the expense in YYYY-MM-DD format.
- Purpose: A summary of the expense report's purpose. No more than 8 words.
- Notes: Any relevant notes about the receipt, such as the original currency and amount, missing or unclear dates, non-economy class ticket, or any potential issues with the receipt.