Mailhook and NetSuite: AI Purchase-Order Line Extractor Template
A purchase-order PDF emailed to a Mailhook is read, its line items and quantities are extracted as structured data, and a matching record is created in NetSuite.
What It Builds
A Mailhook trigger gives you a dedicated Spojit email address. When a supplier or buyer emails a purchase-order PDF to it, an Attachment node fetches the PDF, a Knowledge node in Embed mode loads it into a Transient collection, and a Knowledge node in Query mode pulls out the PO number, line items, SKUs, and quantities as structured output. A Connector node on the netsuite connector then creates the record. Everything runs seconds after the email lands, with no mailbox or polling involved.
The Prompt
Paste this into Miraxa and it builds the workflow, connecting the tools for you:
Build a workflow triggered by a Mailhook. When a purchase-order PDF is emailed in, use an Attachment node to fetch the first PDF attachment, embed it into a Transient Knowledge collection, then query that collection with a Response Schema to extract the PO number, supplier name, and an array of line items each with SKU, description, and quantity. Then use a Connector node on the NetSuite connector to create a record from the extracted line items.
Connectors Used
- Mailhook (trigger) - the dedicated Spojit address that starts the run when a PO PDF is emailed in. Output is available as
{{ input }}. - Attachment node - fetches the PDF bytes referenced by the Mailhook email; set Mode to
Singleand Filename pattern to*.pdf. - Knowledge node - Embed mode loads the PDF into a Transient collection; Query mode extracts the line items with a Response Schema.
- netsuite - creates the record from the extracted data using a tool such as
create-recordorupsert-recordin Direct mode.
Customize It
Change the Filename pattern in the prompt if your POs arrive as *.csv or images rather than PDFs. Adjust the extracted fields (add a delivery date, currency, or line-level unit price) by naming them in the prompt so they appear in the Response Schema. To restrict who can trigger the run, add a From allowlist on the Mailhook so only your supplier domains are accepted. Swap the NetSuite tool to upsert-record if you want re-sent POs to update an existing record instead of creating a duplicate.
Tips
- Use a Transient collection for one-off "embed then query then discard" extraction on a single PO: it is auto-created per run, shared across the two Knowledge nodes, and cleaned up on completion, so you do not manage a file name or stored documents.
- Feed the Attachment node's
{{ attachment.content }}straight into the Knowledge node's Document Input field with Document Type set toPDF. - Keep the NetSuite record creation in Direct mode so the field mapping is deterministic and costs no AI credits; reserve Agent mode for the extraction step where judgment is needed.
Common Pitfalls
- The designer refuses to save an Attachment node unless the workflow uses a Mailhook trigger, so build the trigger first.
- Attachments default to a 10 MB per-attachment and 25 MB per-run limit; very large or multi-page scanned POs may need a tighter filename filter or a smaller source file.
- Without a Response Schema on the Query node, the extracted line items come back as free text and will not map cleanly into NetSuite fields. Always force structured output.
- Confirm your netsuite connection is added under Connections before running, or the create-record step will have nothing to authenticate against.
Related
- Want the step-by-step? See How to Create NetSuite Sales Orders from Emailed PO PDFs.
- How to Create Shopify Orders from PO PDFs Emailed to a Mailhook applies the same Mailhook and Attachment pattern to a Shopify order.
- How to Use Structured Output for Reliable AI Data Extraction explains the Response Schema technique behind the extraction step.