🔬 Create purchase orders from Gmail using Groq LLM, Airtable, and Google Sheets

⚡ 1 views · 🔬 Document Extraction & Analysis

Description

Quick overview

This workflow pulls unread “purchase request” emails from Gmail, uses a Groq-hosted LLM to extract line items and urgency into structured JSON, matches items against an Airtable catalog to apply pricing and vendors, then logs approvals to Google Sheets and creates or flags purchase orders in Airtable.

How it works

  1. Starts manually and stores the current run timestamp for use on the next execution.
  2. Fetches up to five unread Gmail messages with the subject filter “purchase request” and normalizes each email into raw request text plus the requester’s address.
  3. Sends the freeform request text to a Groq chat model (via n8n’s LangChain integration) and parses the response into a strict JSON schema with urgency and itemized quantities.
  4. Loads the approved item catalog from Airtable and performs fuzzy matching to assign SKUs, preferred vendors, and contract/standard pricing while calculating a total PO cost.
  5. Routes the request based on whether any items failed to match, any items are ready for an automatic PO, or the request is marked urgent.
  6. For matched requests, appends/updates an approval/audit entry in Google Sheets and then upserts an “Approved - Auto” purchase order record into Airtable.
  7. For triage or urgent cases, creates or updates an Airtable purchase order record with a “Pending Triage” or “Pending Urgent Review” status.

Setup

  1. Connect Gmail OAuth credentials and ensure incoming requests use the expected subject filter (subject contains “purchase request”) and are left unread until processed.
  2. Add a Groq API credential and confirm the selected chat model is available for your account.
  3. Connect Airtable credentials and update the base/table IDs for both the catalog source and the purchase order destination.
  4. Ensure the Airtable catalog includes fields used for matching and pricing (for example: Search Keywords or Item Name, SKU, Vendor ID/Vendor, Price, optional Contract Price, and optional Preferred Rank).
  5. Connect Google Sheets credentials and update the spreadsheet/document ID, sheet tab, and column names used for the approval log.

Additional info

How To Customize Nodes

Add‑ons

Use Case Examples

Troubleshooting Guide

IssuePossible CauseSolution
Slack node fails to fetch historyIncorrect Channel ID or missing app permissions.Verify the Channel ID in the Slack node and ensure your Slack app has the channels:history scope and is invited to the target channel.
LLM Output Parser throws an errorThe AI model hallucinated outside the requested JSON schema.Try lowering the AI model’s temperature, or switch to a strictly typed model (like OpenAI’s gpt-4o-mini) to enforce strict JSON adherence.
All requests route to manual triageCatalog search keywords in Airtable do not align with employee phrasing.Open the Code: Match & Price Logic node and lower the threshold from 0.3, or enrich your Airtable catalog’s Search Keywords column with common synonyms.
Duplicate processing of the same requestThe static data timestamp is not saving correctly.Ensure the workflow is active. Static memory ($getWorkflowStaticData) only persists across executions when a workflow is formally activated, not during manual testing.
Google Sheets log fails to updateColumn headers in the live sheet do not match node configuration.Open Sheets: Log Approval and click “Refresh Schema”. Ensure your live sheet contains exactly “Date”, “Total Cost”, “Matched SKUs”, “Vendors”, and “Status”.

Need Help

Need assistance configuring this workflow for your specific ERP, setting up advanced 3-way matching for accounts payable, or adjusting the AI parsing logic to meet strict tax and regulatory compliance rules?

WeblineIndia’s team of automation developers specializes in building robust, audit-ready n8n workflows tailored for the finance and procurement sectors. Whether you need to connect this workflow to custom legacy software or scale your automated invoice validation, contact WeblineIndia to customize and deploy this solution for your organization.

đź”— Nodes Used

Airtable, Google Sheets, Gmail, Basic LLM Chain, Structured Output Parser, Groq Chat Model

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup