Skip to main content

PO email to draft order

Watches a mailbox for purchase order PDFs and turns each one into a draft order in Propeller, with the customer matched, the products matched and the PO reference filled in. A sales rep only has to review and confirm.

Runs: Outside Propeller · Trigger: Email · Difficulty: Medium

What you need​

  • An n8n account. See Set up n8n.
  • A Gmail account for the mailbox that receives the purchase orders.
  • An OpenAI account.
  • A Propeller API key.

How it works​

Every minute the workflow checks the mailbox for emails with a PDF attachment and handles them one by one. For each email:

  1. AI reads the PDF and picks out the buyer, the company, the PO reference, remarks and the order lines.
  2. The workflow finds the customer through the sender's email address, or an email address in the PDF. Without a match it searches companies and contacts by the names in the PO, and the AI picks from at most 20 candidates.
  3. Each order line is matched on its article number first, as SKU or EAN. Otherwise the workflow searches the catalogue and the AI picks from at most 10 candidates per line. Quantities always come from the PO.
  4. The workflow creates an order with the PO reference and remarks, sets it to the status in ORDER_STATUS (default DRAFT_ORDER, as in the earlier version) and creates a ticket in the Action Hub. Lines that could not be matched are listed on the ticket, so you can add them yourself. When two lines match the same product, their quantities are added up and the ticket lists both lines, so you can check the quantity.

Every email ends in exactly one ticket. When the workflow cannot create the order, for example because the PDF cannot be read or the customer is not found, the ticket says why and you handle the PO manually.

Install it​

  1. In n8n, import the downloaded JSON as a new workflow.
  2. Connect your Gmail account on the Gmail Trigger node.
  3. Connect your OpenAI account on the three AI nodes: Extract Order Data, Match Customer and Match Products.
  4. Create a header auth credential with your Propeller API key and select it on the eight GraphQL nodes.
  5. In the Settings node, set CHANNEL_ID to the channel orders are created in, ASSIGN_TO_ADMIN_USER_ID to the backoffice user who gets the tickets and LANGUAGE to the language of your product names. Optionally set ORDER_TYPE to purchase or stock. Left empty, Propeller creates a dropshipment order.
  6. Send a test purchase order to the mailbox, run the workflow once manually and check the Action Hub.
  7. Activate the workflow.
Filling in your API key

In n8n, create a credential of type Header Auth and fill in its two fields exactly like this:

FieldWhat to fill in
NameapiKey
ValueYour Propeller API key

Name is not a title you pick yourself. It has to say exactly apiKey, otherwise the workflow cannot sign in. See Set up n8n for the full steps.

Make it yours​

  • Which emails: the search filter on the Gmail Trigger node (default has:attachment filename:pdf).
  • The AI model: pick another model on the three AI nodes.
  • Order type, status and channel: ORDER_TYPE, ORDER_STATUS and CHANNEL_ID in Settings.
  • Matching: COMPANY_CANDIDATES and CANDIDATES_PER_LINE set how many candidates the AI chooses from.

Limits​

Only the first PDF of an email is read. A purchase order is read up to 100 lines.

A run that takes longer than one hour is stopped and shows as canceled in the n8n executions list.

Use it outside n8n​

Copy the JSON into an AI assistant and follow Adjust a workflow with an AI assistant. The same flow works with any mail provider that your workflow tool supports.

Good to know

The workflows and agents in the Agent Hub are free to use and adapt. They are examples, not supported product features, so test them in a staging environment and check the results before using them in production.