# Expense Report Approval

|                      |                                                                    |
| -------------------- | ------------------------------------------------------------------ |
| **Time to complete** | 15 minutes                                                         |
| **Difficulty**       | Beginner                                                           |
| **Prerequisites**    | Expense system access, Email connection                            |
| **You'll build**     | An assignment that routes expense reports to managers every Monday |

***

### Why Automate This?

**The Problem**: Finance teams spend 5-10 hours weekly manually reviewing submitted expense reports, identifying the right approver, and sending email notifications. Reports sit in queues, approvals get delayed, and employees wait longer for reimbursements.

**The Solution**: A Duvo assignment that automatically processes submitted expense reports every Monday morning—extracting details, identifying the correct manager, and sending approval requests with all necessary information attached.

**Expected Results**:

* Reduce approval cycle from 3-5 days to same-day
* Eliminate 5+ hours of manual routing per week
* Zero missed or forgotten expense reports
* Complete audit trail of all approvals

***

### What You'll Build

By the end of this tutorial, you'll have an assignment that:

1. Checks your expense system for submitted reports from the past week
2. Extracts employee details, amounts, and receipts
3. Looks up each employee's manager in your HR system
4. Sends a formatted approval email with the report attached
5. Updates the expense system status to "Pending Approval"

***

### Before You Start

Make sure you have these ready:

* [ ] **Expense management system** - You'll need login credentials. [Set up logins](https://docs.duvo.ai/resources/my-logins)
* [ ] **Email connection** - Connect Gmail or Outlook. [Connect connection](https://docs.duvo.ai/connections/how-to-add-connection)
* [ ] **HR system access** (optional) - For automatic manager lookup. Otherwise, you can specify managers manually.

***

### Step 1: Create Your Assignment

1. Click **"+ Create Assignment"** from your dashboard
2. Select **"Use Assignment Builder"** (recommended for this tutorial)

![Create Assignment Button](https://2799416172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV0i3nXTFWDeWtbyZ9xMo%2Fuploads%2Fgit-blob-baed45156c0e414ce157b1a61cc6f8f321b6e730%2Fhow-to-build-agent-1.png?alt=media)

***

### Step 2: Describe Your Workflow

Paste this prompt into the Assignment Builder:

```
Every Monday morning, check our expense management system for expense reports submitted in the past 7 days that have status "Submitted".

For each report:
1. Extract the employee name, email, report ID, total amount, submission date, and all line items with receipts
2. Look up the employee's direct manager in the HR system
3. Send an email to the manager with subject "Expense Report Approval Required - [Employee Name] - [Report ID]"
4. Include the report summary and total amount in the email body
5. Attach the expense report PDF
6. Update the report status to "Pending Manager Approval"

If a manager can't be found, escalate to the department head.
If the expense system is unavailable, retry after 30 minutes.
```

Click **"Generate"** to create the assignment SOP.

***

### Step 3: Review Generated SOP

Duvo will generate structured SOP based on your description. Review it to ensure:

* All systems are correctly identified (expense system, HR system, email)
* The approval workflow matches your process
* Error handling covers your edge cases

You can edit the SOP directly if you need to adjust any details.

***

### Step 4: Configure Connections

The assignment needs access to your systems. Click **"Connections"** and ensure:

1. **Expense system** - Add logins for your expense management platform
2. **Email** - Connect your Gmail or Outlook account
3. **HR system** (if using) - Add logins for manager lookup

***

### Step 5: Test Your Assignment

Before scheduling, run a test:

1. Click **"Run Assignment"**
2. Watch the assignment execute each step in real-time
3. Review the session log to verify correct behavior

![Assignment Running](https://2799416172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV0i3nXTFWDeWtbyZ9xMo%2Fuploads%2Fgit-blob-38d5f9f8a98c64abc4a296673c3664470a9d9e53%2Fhow-to-run-agent-1.png?alt=media)

**What to check**:

* Did it find the correct expense reports?
* Did it identify the right managers?
* Did the email look correct? (Check your sent folder)
* Did the status update in your expense system?

***

### Step 6: Schedule Weekly Jobs

Once testing is successful, set up the Monday schedule:

1. Go to **Assignment Settings** > **Schedule**
2. Select **Weekly** on **Monday** at **8:00 AM**
3. Save the schedule

Your assignment will now automatically process expense reports every Monday morning.

***

### Expected Results

When your assignment runs successfully, you should see:

**In your expense system**:

* All "Submitted" reports now show "Pending Manager Approval"
* Activity log shows the assignment's actions

**In manager inboxes**:

* Formatted approval emails with report summaries
* PDF attachments with full expense details
* Clear approve/reject call-to-action

**In Duvo**:

* Complete session log showing each step
* Audit trail of all emails sent and status updates

***

### Troubleshooting

#### Assignment can't find expense reports

* **Check filters**: Verify the status filter matches your system (e.g., "Submitted" vs "Pending")
* **Check date range**: Ensure the 7-day lookback is correct for your timezone
* **Check permissions**: Confirm the logins have read access to all reports

#### Manager lookup fails

* **HR system connection**: Verify logins are correct and not expired
* **Missing manager data**: Some employees may not have managers assigned—add a fallback in your SOP
* **Field mapping**: Check that employee IDs match between systems

#### Emails not sending

* **Email connection**: Re-authorize if token expired
* **Spam filters**: Check if emails are being blocked
* **Rate limits**: If processing many reports, add delays between emails

#### Status not updating

* **Write permissions**: Confirm logins can update report status
* **Field name**: Verify the status field name matches your system exactly

***

### Take It Further

Once your basic assignment is working, consider these enhancements:

**Add approval thresholds**

```
If total amount exceeds $5,000, also CC the finance director.
If total amount exceeds $10,000, require VP approval.
```

**Include receipt validation**

```
Before routing for approval, check that all line items over $25 have receipt images attached.
If receipts are missing, return the report to the employee with a note.
```

**Add Slack notifications**

```
After sending the approval email, also post a summary to #finance-approvals in Slack.
```

**Create urgency flags**

```
If the report is more than 5 days old, mark the email as high priority.
```

**Personalize with Assignment Memory**

Different users can set their own thresholds. [Learn about Assignment Memory](https://docs.duvo.ai/assignment-features/assignment-memory)

* Finance Manager: *"Auto-approve reports under $500 from employees in my department."*
* Director: *"Auto-approve all reports under $2,000. Flag anything over $2,000 for my review."*

***

### Related Resources

* [Human-in-the-Loop](https://docs.duvo.ai/assignment-features/human-in-the-loop) - Add approval steps before emails are sent
* [Assignment Memory](https://docs.duvo.ai/assignment-features/assignment-memory) - Personalize approval thresholds per user
* [Files](https://docs.duvo.ai/assignment-features/files) - Upload your expense policy for the assignment to reference
* [Refining Your Assignment](https://docs.duvo.ai/building-assignments/refining-your-assignment) - Improve assignment performance over time
