Skip to content
Invoice and Receipt Extractor

Module 07 · business · intermediate

Exercises 07 · Invoice and Receipt Extractor

Start from workflow/starter.json (upload + PDF text) or your finished lesson workflow.

Exercise 1: Sanity-check the math

Task: Set needs_review to true also when subtotal + tax differs from total by more than 0.02, or when any amount is NaN.

Done when: editing the extractor output (pin data) to a wrong total flips needs_review to true.

Hint

Math.abs($json.output.subtotal + $json.output.tax - $json.output.total) > 0.02, plus Number.isNaN(...) checks. Pin the AI node's output to test without spending tokens.

Exercise 2: Photo receipts

Task: Accept JPG/PNG photos too, using OpenAI's vision capability instead of PDF text extraction.

Done when: a phone photo of a receipt returns the same fields.

Hint

Branch on mime type. For images, use the OpenAI node → Image → Analyze Image with the binary input and ask for JSON with the same fields, then feed it into Clean Receipt.

Exercise 3: Receipts from email

Task: Process PDF attachments arriving at a Gmail label like Receipts automatically.

Done when: forwarding a receipt email to yourself (labeled Receipts) adds a row to the sheet.

Hint

Gmail Trigger with Simplify off and Download Attachments on, filtered by label. Attachments arrive as $binary.attachment_0, attachment_1… and the Has PDF? expression already handles any field name.