assistant-skills/log-work-expense/SKILL.md

49 lines
2.2 KiB
Markdown

---
name: log-work-expense
description: Log work expense receipts into MongoDB. Use when the user sends a receipt image (photo of a receipt) along with context about the expense, or says things like "log this expense", "record this receipt", "add this to my work expenses", "expense entry", or provides receipt details for work reimbursement tracking.
---
# Log Work Expense
Log receipt images and expense details into the `wip.work_expenses` collection in MongoDB.
## Trigger Phrases
- "log this expense"
- "record this receipt"
- "add this to my work expenses"
- "expense entry"
## Steps
1. **Extract receipt info** — If the user sent an image, run the OCR script to read the date, vendor, and amount:
```bash
python3 scripts/ocr_receipt.py /path/to/image.jpg
```
The script is located at `~/notes/skills/log-work-expense/scripts/ocr_receipt.py`. It returns JSON with `date`, `vendor`, and `amount` fields. If the output doesn't contain a confident date, **ask the user** — never guess. If they only provided text, use that.
2. **Upload the receipt image to S2** — If the user provided an image, upload it to S2 and get the public URL. If they only provided a file or no image, skip this step.
3. **Insert into MongoDB** — Insert a document into `wip.work_expenses` with this structure:
```json
{
"file": "https://s2.connorrhodes.com/agent/{sha256}.{ext}",
"date": "YYYY-MM-DD",
"note": "Context the user provided about the expense"
}
```
- **file**: The S2 URL of the uploaded receipt image. Omit if no image was provided.
- **date**: The date from the receipt, formatted as YYYY-MM-DD. If you cannot confidently read the date from the receipt, ask the user — do not guess.
- **note**: Any context the user gave about the expense (what it was for, project, etc.). If they didn't provide context, ask what the expense was for.
4. **Confirm** — Reply with a brief confirmation showing what was logged (date, note, and file link if applicable).
## Notes
- Use `uv run --with pymongo` for MongoDB scripts.
- Use the S2 upload endpoint from TOOLS.md for file uploads.
- If the user sends a receipt without context, log what you can read from the image and note that context is pending.