← All N8N workflows
AI & researchCodeExtract From FileIfInformation ExtractorOpenAI Chat Model

PURCHASE ORDER EXAMPLE

Configured with Extract From File, Information Extractor, OpenAI Chat Model, Microsoft Outlook, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
AI & modelsExtract Purchase OrderDetailsInformation ExtractorRoutingIs Excel Document?IfTransformRun ChecksEdit FieldsRoutingIs Valid PurchaseOrder?IfTransformExtract from FileExtract From FileCodeXLSX to Markdown TableCodeAI & modelsOpenAI Chat ModelOpenAI Chat ModelMessagingReply Invalid FormatMicrosoft OutlookTriggerOutlook TriggerMicrosoft Outlook TriggerMessagingReply RejectionMicrosoft OutlookMessagingReply AcceptedMicrosoft OutlookRoutingDo Something withPurchase OrderNo OpTransformFix Excel DatesEdit FieldsAI & modelsIs Submitting aPurchase Order?Text ClassifierRoutingDo NothingNo OpAI & modelsOpenAI Chat Model1OpenAI Chat Model

Node categories in this workflow

  • AI & models
  • Routing
  • Transform
  • Code
  • Messaging
  • Trigger

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Extract Purchase Order DetailsAI & modelsInformation ExtractorSee node parameters
Is Excel Document?RoutingIfSee node parameters
Run ChecksTransformEdit FieldsSee node parameters
Is Valid Purchase Order?RoutingIfSee node parameters
Extract from FileTransformExtract From Filexlsx
XLSX to Markdown TableCodeCodeSee node parameters
OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
Reply Invalid FormatMessagingMicrosoft Outlookreply
Outlook TriggerTriggerMicrosoft Outlook TriggerSee node parameters
Reply RejectionMessagingMicrosoft Outlookreply
Reply AcceptedMessagingMicrosoft Outlookreply
Do Something with Purchase OrderRoutingNo OpSee node parameters
Fix Excel DatesTransformEdit FieldsSee node parameters
Is Submitting a Purchase Order?AI & modelsText ClassifierSee node parameters
Do NothingRoutingNo OpSee node parameters
OpenAI Chat Model1AI & modelsOpenAI Chat ModelSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • microsoftOutlookOAuth2Api
  • openAiApi

Workflow notes

2. Manually Convert XLSX to Markdown

2. Manually Convert XLSX to Markdown

Learn more about the Extract From File node

Today's LLMs cannot parse Excel files directly so the best we can do is to convert the spreadsheet into a format that they can, namely markdown. This conversion is also a good solution for excels which aren't really datasheets - the cells are used like layout elements - which is still common for invoices and purchase orders.

To perform the conversion, we can use the 'Extract from File' node to get the each row from the xlsx and then iterate and concatenate to form our markdown table using the code node.

3. Extract Purchase Order Details using AI

3. Extract Purchase Order Details using AI

Learn more about the Information Extractor

Data entry is probably the number one reason as to why we need AI/LLMs. This time consuming and menial task can be completed in seconds and with a high degree of accuracy. Here, we ask the AI to extract each event with the term dates to a list of events using structured output.

Try it out!

Try it out!

This n8n template imports purchase order submissions from Outlook and converts attached purchase order form in XLSX format into structured output.

Data entry jobs with user-submitted XLSX forms is a time consuming, incredibly mundane but necessary tasks which in likelihood are inherited and critical to business operation.

While we could dream of system overhauls and modernisation, the fact is that change is hard. There is another way however - using n8n and AI!

How it works

  • An Outlook trigger is used to watch for incoming purchase order forms submitted via a shared inbox.
  • The email attachment for the submission is a form in xlsx format - like this one https://1drv.ms/x/c/8f1f7dda12b7a145/ETWH8dKwgZ1OiVz7ISUWYf8BwiyihBjXPXEbCYkVi8XDyw?e=WWU2eR - which is imported into the workflow.
  • The 'Extract from File' node is used with the 'code' node to convert the xlsx file to markdown. This is so our LLM can understand it.
  • The Information Extractor node is used to read and extract the relevant purchase order details and line items from the form.
  • A simple validation step is used to check for common errors such as missing PO number or the amounts not matching up. A notification is automated to reply to the buyer if so.
  • Once validation passes, a confirmation is sent to the buyer and the purchase order structured output can be sent along to internal systems.

How to use

  • This template only works if you're expecting and receiving forms in XLSX format. These can be invoices, request forms as well as purchase order forms.
  • Update the Outlook nodes with your email or other emails as required.
  • What's next? I've omitted the last steps to send to an ERP or accounting system as this is dependent on your org.

Requirements

  • Outlook for Emails
    • Check out how to setup credentials here: https://docs.n8n.io/integrations/builtin/credentials/microsoft/
  • OpenAI for LLM document understanding and extraction.

Customising the workflow

  • This template should work for other Excel files. Some will be more complicated than others so experiment with different parsers and extraction tools and strategies.
  • Customise the Information Extractor Schema to pull out the specific data you need. For example, capture any notes or comments given by the buyer.

Need Help?

Join the Discord or ask in the Forum!

Happy Hacking!

PURCHASE ORDER EXAMPLE

PURCHASE ORDER EXAMPLE

This is the purchase order XLSX which is used an example for this template. https://1drv.ms/x/c/8f1f7dda12b7a145/ETWH8dKwgZ1OiVz7ISUWYf8BwiyihBjXPXEbCYkVi8XDyw?e=WWU2eR

4. Use Simple Validation to Save Time and Effort

4. Use Simple Validation to Save Time and Effort

Learn more about the Edit Fields node

With our extracted output, we can run simple validation checks to save on admin time. Common errors such as missing purchase order numbers or miscalculated cost amounts are easy to detect and a quick response can be given. Once validation passes, it's up to you how you use the extracted output next.

1. Wait For Incoming Purchase Orders

1. Wait For Incoming Purchase Orders

Read more about the Outlook trigger

Our template starts by watching for new emails to a shared inbox (eg. "user@example.com") using the Outlook Trigger node. Our goal is to identify and capture buyer purchase orders so that we can automating validate and use AI to reduce the data entry time and cost at scale.

We can also use the Text Classifier node to validate intent. This ensures we catch valid submissions are not just queries about purchase-orders or replies.

PURCHASE ORDER EXAMPLE

PURCHASE ORDER EXAMPLE

Purpose and structure

This folder contains the PURCHASE ORDER EXAMPLE workflow. Its executable nodes use code, extractFromFile, if, informationExtractor, lmChatOpenAi, microsoftOutlook, microsoftOutlookTrigger, noOp, set, textClassifier. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Outlook Trigger

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Code/0851_Code_Extractfromfile_Monitor_Triggered.json MIT; preserve source notices.

More in AI & research