n8nMoneyLower billsAI score · 83/100AI-assisted edit · no obvious prompt-injection riskn8n.io

Auto-Classify Purchase Requisitions with Google Gemini and Route for Approval

Webhook ingestion → data validation → Gemini classification with confidence scoring → auto or manual approval → Sheets logging → Gmail/Slack notifications

Some experienceStepsWorkflowPromptTip
Who
Operations or finance teams automating procurement approval workflows
You get
Automatically categorize purchase requisitions, auto-approve high-confidence requests, escalate low-confidence ones for manual review, and log and notify automatically
You need
n8n · gmail · google-sheets · slack

Constraints

Requires an n8n instance; configure Google Gemini (googlePalmApi), Gmail OAuth2, Slack OAuth2, and Google Sheets credentials. The webhook source must send a POST request with pr_id, requester, description, and amount.

What they did

This n8n template by WeblineIndia demonstrates a complete automated purchase requisition classification workflow. After an external system submits PR data via Webhook POST, the workflow validates required fields and normalizes the data structure, then calls Google Gemini for intelligent categorization, returning category, confidence, risk signals, and reasoning. It then auto-approves or escalates to manual review based on confidence thresholds, logs results to a Google Sheets audit table, and notifies stakeholders via Gmail and Slack.

How it went

The author reports the template can be used for IT procurement automation, office supply management, compliance monitoring, enterprise audit tracking, and high-volume PR processing (author_report). Typical behavior: High confidence + low risk → Auto Approved; Medium confidence or elevated risk → Manual Review; Low confidence or category mismatch → Manual Review.

Worth knowing

1. This site has not tested the workflow; reproduction=not_tested. Actual results depend on Gemini response stability and correct credential configuration. 2. Approval thresholds (confidence ≥ 85 for auto-approve, 60–84 for manual review) and the category list are customizable, but boundary cases should be retested after changes. 3. If Gemini returns invalid JSON, the Parse node gracefully degrades to Uncategorized/0 score/Unknown risk without halting the workflow, but may cause all requests to route to manual review. 4. The Google Sheets spreadsheet ID and sheet name must be replaced with actual values; column order must match the schema definition. 5. No explicit author-published date is provided; the createdAt in api.json is system-generated and should not be treated as the author's stated publication date. 6. The template contains promotional content (WeblineIndia development services link), which does not affect technical description but should be noted for its commercial nature.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • Google Gemini Chat Model node: connect Google Gemini/PaLM API credentials.

Configuration to replace

  • Source template is n8n public workflow #18492 (~20 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-24

Steps

  1. Configure Webhook and Credentials

    Create a new workflow in n8n, add a Webhook node, and set the POST path to /pr-submission. Configure credentials in this order: Google Gemini API (for AI classification), Gmail OAuth2 (for review and result emails), Slack OAuth2 (for procurement channel alerts), and Google Sheets (for audit logging). Ensure the submission source can send a JSON body containing pr_id, requester, description, and amount.

  2. Configure the AI Classification Node

    Add a Basic LLM Chain node (AI: Categorize Purchase Requisition) and connect the Google Gemini Chat Model as the language model. Paste the template's classification prompt into the Prompt field. The prompt instructs Gemini to return strict JSON with final_category, confidence_score, misclassification_risk, suggested_correction, and reasoning. You may modify the Allowed Categories list to match your procurement taxonomy.

    Execution prompt · Source text。Prompt / text field of the 'AI: Categorize Purchase Requisition' node

    =You are an enterprise procurement classification assistant.
    
    Analyze the following purchase requisition and determine the best procurement category.
    
    Purchase Requisition Details:
    - PR ID: {{$json.pr_id}}
    - Requester: {{$json.requester}}
    - Department: {{$json.department}}
    - Description: {{$json.description}}
    - Amount: {{$json.amount}} {{$json.currency}}
    - Suggested Category: {{$json.suggested_category}}
    
    Items:
    {{ JSON.stringify($json.items, null, 2) }}
    
    Allowed Categories:
    - IT Equipment
    - Office Supplies
    - Software
    - Facilities
    - Marketing
    - HR & Training
    - Professional Services
    - Logistics
    - Uncategorized
    
    Tasks:
    1. Determine the most appropriate category.
    2. Detect whether the suggested category may be incorrect.
    3. Provide a confidence score between 0 and 100.
    4. Suggest corrected category if needed.
    5. Explain reasoning briefly.
    
    Return ONLY valid JSON in this exact structure:
    
    {
      "final_category": "",
      "confidence_score": 0,
      "misclassification_risk": "",
      "suggested_correction": "",
      "reasoning": ""
    }
  3. Set Up Approval Branching Logic

    Add a Code node to parse Gemini's JSON response (Parse AI Classification Result), then another Code node to compute confidence level and approval recommendation (Calculate Classification Confidence). Current logic: auto_approve=true when confidence ≥ 85 and misclassification_risk is not High; manual review for 60–84 or high risk; manual review for <60. Then add an If node (Check Auto Approval Eligibility) branching on auto_approve: the pass branch sets approval_status='Auto Approved' and routing_status='Ready for ERP Update'; the review branch sets approval_status='Pending Manual Review' and routing_status='Escalated to Procurement Team', and triggers a Gmail review ticket.

  4. Merge Results and Write to Google Sheets

    Use a Merge node to combine original PR data with AI results by position (Merge PR Data With AI Result), then connect a Google Sheets node (Store Procurement Record) in append mode to the PR_Records sheet. Ensure column names match the node schema: pr_id, requester, department, description, amount, currency, final_category, confidence_level, confidence_score, approval_status, misclassification_risk, suggested_correction, routing_status, review_reason, ai_reasoning, processed_timestamp.

  5. Send Gmail and Slack Notifications

    After the Sheets node, connect in parallel a Gmail node (Notify Procurement Approver) and a Slack node (Send Procurement Slack Alert). Gmail sends a processing summary to the approver; Slack posts a channel alert with PR ID, category, confidence, approval status, and risk level. Update recipient addresses and channelId to actual values. [First-test safety] Before the first test, temporarily disconnect the Gmail, Slack, and Google Sheets write nodes, or retarget them to a test label/channel/sheet; enable real targets only after the dry-run looks correct.

    Execution prompt · Source text。text field of the 'Send Procurement Slack Alert' node

    =Procurement Request Processed!
    
    PR ID: {{$json.pr_id}}
    
    Requester: {{$json.requester}}
    
    Department: {{$json.department}}
    
    Final Category: {{$json.final_category}}
    
    Approval Status: {{$json.approval_status}}
    
    Confidence Level: {{$json.confidence_level}}
    
    Misclassification Risk: {{$json.misclassification_risk}}
    
    Routing Status: {{$json.routing_status}}

Prompt you can copy

Setup guidance · Editorial suggestion。Setup assistant starter: helps understand the AI classification node configuration and field mapping; not the node runtime instruction

This block is the prompt. Ads are never placed here.

You are an enterprise procurement classification assistant. Based on the provided purchase requisition details, determine the best procurement category from the allowed list, detect if the suggested category may be incorrect, provide a confidence score between 0 and 100, suggest a corrected category if needed, and explain reasoning briefly. Return strict JSON with: final_category, confidence_score, misclassification_risk, suggested_correction, reasoning.

Paste the above prompt into the Basic LLM Chain's Prompt field, and ensure the Google Gemini Chat Model sub-node is connected.

Source

Classify purchase requisitions with Google Gemini, Gmail, Slack and Sheets · weblineindia · n8n.io · 2026-08-20

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related