Skip to content

box-community/files-sdk-invoice-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Box Records Manager

Classifies invoices using Box AI Extract and organizes them into folders with the Files SDK.

Drop unorganized invoices into a Box folder, click Organize, and watch each file get classified by expense category (Meals, Office Supplies, Travel, etc.) and filed into the matching subfolder — all in real time. A classification-report.json is uploaded to Box when the run completes.

Prerequisites

Setup

bun install
cp .env.example .env

Edit .env with your Box credentials:

Variable Description
BOX_CLIENT_ID OAuth 2.0 client ID from your Box app
BOX_CLIENT_SECRET OAuth 2.0 client secret
BOX_ENTERPRISE_ID Your Box enterprise ID
BOX_FOLDER_ID Box folder ID containing the invoices to classify
PORT Server port (default 3000)

Run

bun run start

Open http://localhost:3000.

How it works

  1. GET /api/files — lists files in BOX_FOLDER_ID using files.listAll()
  2. POST /api/organize — for each file:
    • Extracts expense_category, vendor_name, and total_amount via Box AI (files.raw.ai.createAiExtractStructured)
    • Skips duplicates with files.exists(dest)
    • Moves the file into a {category}/ subfolder using files.move()
    • Uploads a classification-report.json summary using files.upload()
  3. GET /api/events — SSE stream for real-time progress in the browser

Files SDK usage

Method Purpose
files.listAll() Discover files (handles pagination)
files.exists() Skip already-filed duplicates
files.move() Organize into category folders (auto-creates them)
files.upload() Write classification report back to Box
hooks.onAction Stream SDK activity to the browser via SSE
files.raw Escape hatch for Box AI Extract

Stack

  • Files SDK — unified storage API with Box adapter
  • Box AI Extract — server-side document classification and metadata extraction
  • Bun — runtime and HTTP server

About

Classify and organize invoices into expense folders using Box AI Extract and Files SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors