This is Part 2 of the “Restaurant PO Automation” series. Part 1 got the PDF into n8n as binary data on attachment_0. This post covers nodes 02 and 03: turning that file into text, then turning that text into one structured order object that a spreadsheet can actually consume.

Series guide: Restaurant Purchase Order Automation: Series Guide & Case Study

1. Two different jobs that are easy to conflate

The client’s manual routine is usually described as “open the PDF and read the order number and quantities.” That reads like one action, but in an automation it is two, and they fail in completely different ways.

Extract From File is a mechanical operation. It opens the PDF container and returns whatever characters are inside it. It has no opinion about what those characters mean. If the PDF says 20 KG, it returns 20 KG. If it says Required Delivery Date: 23 Nov 2026, it returns exactly that string.

Information Extractor is an interpretation operation. It has to decide which part of the text is an outlet, which is a PO number, which tokens are product names, which numbers are quantities, and which short strings are units. It also has to return them in a shape the next node can rely on, every single time.

2. Configuring Extract From File

Add the node after Gmail Trigger and choose the Extract From PDF operation. The parameter table is short:

ParameterSettingWhy it matters
OperationExtract From PDFWe want text, not metadata or page images
Input Binary Fieldattachment_0Must match the Binary property name produced by Gmail Trigger exactly
OutputTextA single text field for the next node

That second row is the one that breaks most first attempts. Gmail Trigger names its downloaded attachment attachment_0 by default, but the name is version- and option-dependent. We confirm it in the trigger’s output before configuring this node rather than assuming it. If the trigger had produced attachment_1, or a prefixed name because we changed Attachment Prefix, this field would have to change with it.

Extract From File parameters and the extracted PDF text

The four simulated purchase orders in this demo are text-type PDFs exported from WPS. That is an important scope decision: it means no OCR is required. There is no Google Vision node, no AWS Textract call, and no per-page API cost. A scanned or photographed order would need OCR or a model with document vision, and that must be validated against real samples before any quote is given.

For PO-20261123-001.pdf, the text output looks roughly like this:

HARBOUR KITCHEN
PURCHASE ORDER

PO Number: PO-20261123-001
Required Delivery Date: 23 Nov 2026

Outlet: Harbour Kitchen - Orchard

VEG-001 Fresh Tomatoes 20 KG
VEG-002 Romaine Lettuce 12 KG
PRO-001 Boneless Chicken Breast 15 KG
FRZ-001 Frozen French Fries 8 CTN
DRY-001 Jasmine Rice 10 BAG

3. What text extraction loses

The original PDF has a clean five-column table: Item Code | Product Description | Category | Quantity | Unit. After extraction, the table layout is gone. Columns collapse, spacing becomes irregular, and the whole order arrives as one continuous string.

This looks alarming and is not. We only check three things at this stage:

CheckExpected
PDF text present in textYes, one item
All five product lines presentVEG-001 through DRY-001
Quantity and unit preserved20 KG, 12 KG, 15 KG, 8 CTN, 10 BAG

A rule-based parser tuned to PO 01 would silently misread PO 04, so we hand the flat text to a schema-driven extractor instead.

4. Setting up Information Extractor

Add an Information Extractor node after Extract From File. Search for that exact node, not AI Agent. This scenario is pure data extraction: there are no tools to call, no decisions to make, and no multi-step reasoning. An Agent would add nondeterminism for no benefit.

ParameterSetting
Text{{ $json.text }}
Schema TypeDefine using JSON Schema

{{ $json.text }} can also be dragged in from the previous node’s output panel. Either way, the input is the raw string from node 02, nothing else.

5. The JSON Schema

The schema is where the business requirement becomes enforceable. The critical part is items: an array, not a single object. Without it, one purchase order collapses into one row and the five products get crammed into a single cell, which is useless for picking and dispatch.

{
  "type": "object",
  "properties": {
    "po_number": { "type": "string" },
    "order_date": { "type": "string" },
    "delivery_date": { "type": "string" },
    "brand": { "type": "string" },
    "outlet": { "type": "string" },
    "outlet_code": { "type": "string" },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sku": { "type": "string" },
          "product": { "type": "string" },
          "category": { "type": "string" },
          "quantity": { "type": "number" },
          "unit": { "type": "string" }
        },
        "required": ["sku", "product", "category", "quantity", "unit"]
      }
    }
  },
  "required": [
    "po_number",
    "order_date",
    "delivery_date",
    "brand",
    "outlet",
    "outlet_code",
    "items"
  ]
}

Two choices here are worth stating plainly. quantity is a number, so 20 arrives as a numeric value that can be summed later by QUERY rather than as a string that has to be cleaned. And unit is its own field, never folded into the quantity: 10 KG, 10 CTN and 10 BAG are different physical amounts, and mixing them is the fastest way to send the wrong goods to a restaurant.

The required arrays are not decoration. They are what turns “the model felt like returning something” into a contract the Code node in Part 3 can iterate without defensive guessing.

6. The extraction instruction

Alongside the schema we give the model a short English instruction. It is worth quoting in full because every rule exists to prevent a specific failure we do not want to discover after the sheet is live:

You are a purchase order data extraction assistant
for a Singapore food distribution warehouse.

Extract structured data from the provided
purchase order PDF text.

Return the following information:
- PO number
- Order date
- Required delivery date
- Restaurant brand
- Outlet name
- Outlet code
- All ordered line items

For each line item, extract:
- SKU or item code
- Product description
- Product category
- Quantity
- Unit of measure

Rules:
1. Extract every product line in the order.
2. Do not invent or estimate quantities.
3. Preserve original product descriptions.
4. Preserve units such as KG, CTN, BAG, BTL.
5. Convert dates to YYYY-MM-DD format.
6. Normalize outlet names without losing identity.
7. Return null for missing information.
8. Ignore delivery instructions and disclaimers.
9. Return structured data matching the schema.
10. Do not include explanatory text.

Rule 1 protects the items array from a model that returns only the first product. Rule 2 is the warehouse-safety rule: an invented quantity is worse than a blank cell. Rule 7 gives us a defined value for missing data instead of a guess. Rule 8 matters because our simulated PDFs contain delivery instructions and disclaimer text that must not become order lines.

7. Connecting the Chat Model sub-node

The first execution of this node failed, and the error was unambiguous:

A Model sub-node must be connected and enabled

Information Extractor configuration showing the missing model sub-node error

Nothing was wrong with the schema, the text mapping, or the previous node. Information Extractor is a container: it defines the shape of the answer, but a Chat Model has to produce it. Click the + under Model at the bottom of the node and attach one.

Chat Model connected as a sub-node of Information Extractor

For this demo we reuse a credential that already works rather than opening a new subscription. A compatible endpoint can be configured as:

ParameterValue
Base URLhttps://api.deepseek.com/v1
Modeldeepseek-chat
API Keyexisting DeepSeek API key
Temperature0 (if supported)

One practical wrinkle: a DeepSeek key previously used inside an HTTP Request node is not automatically usable by an OpenAI Chat Model node. The credential may need to be recreated with its API key and Base URL in the model node’s own credential form. Temperature 0 is preferable here because this is extraction, not copywriting; we want the same order text to produce the same JSON every time.

This is also why the AI Chat Model is drawn as a sub-node of Information Extractor, not as a sixth main node. The running workflow is still five main nodes: Gmail Trigger, Extract From File, Information Extractor, Code, Google Sheets.

8. Reading the first structured result

Executing the node against PO 01 returned one order object:

FieldValue
po_numberPO-20261123-001
order_date20 Nov 2026
delivery_date23 Nov 2026
brandHarbour Kitchen
outletHarbour Kitchen - Orchard
outlet_codeHK-ORC-01
items5 objects

The AI correctly recovered product codes, names, categories, quantities and units even though the PDF’s table layout had been flattened into continuous text. That is the single most important verification in the whole demo.

Note the dates: they came back as 20 Nov 2026 and 23 Nov 2026, not YYYY-MM-DD, despite rule 5. We deliberately do not fix this by editing the already-working AI node. The Code node in Part 3 normalises dates, which is cheaper and more deterministic than asking a model to be punctual about formatting. Keep a working node working.

One more implementation detail: some models wrap the result in an output object rather than returning fields at the top level. The Code node therefore reads order.json.output ?? order.json, so either shape works without reconfiguring anything.

9. When AI is unnecessary, and when OCR becomes necessary

AI is not automatically the right answer for PDF extraction, and saying so in a proposal is more credible than assuming it.

If every outlet’s PDF is generated by the same purchasing system with fixed field positions, a small deterministic parser is cheaper to run, easier to audit, and has no per-call model cost. We would skip Information Extractor entirely. Conversely, if the PDFs are scanned images or photographs, text extraction returns nothing and no schema will help; OCR or a document-vision model becomes mandatory, with the extra API cost that implies.

Between those two extremes - same brand, different outlets, slight layout differences, text-type PDFs - a schema-driven extractor is the right trade-off. That is exactly the situation our four simulated orders reproduce, including PO 04’s different template.

One real, redacted PO PDF settles which of the three applies, and should be requested before any scope or price is fixed.

10. Scope note

This node extracts; it does not validate business correctness. There is no duplicate-order check, no revised-PO detection, and no route to human review when the model is unsure. A production warehouse system would keep the original PDF for audit and send unrecognised quantities, outlets or PO numbers to a review queue rather than letting them flow into a dispatch sheet. Those are phase-two features, deliberately out of scope for this five-node demo.

What we have now is one clean order object with five line items. Part 3 expands that object into five separate rows and fixes the date format.

Next: Part 3 - Normalizing Order Lines with a Code Node

Data note: all business data in this series - Harbour Kitchen, its outlets, PO numbers, SKUs, quantities and delivery dates - is fictional mock data for a Self-initiated Demonstration. This is a demo, not a production warehouse system.

Related reading