đź’¬ Answer procurement questions by role using Groq and Google Sheets

⚡ 2 views · 💬 Support Chatbots

Description

Quick overview

This workflow receives procurement questions via n8n Chat or a webhook, looks up role and procurement records in Google Sheets, and uses Groq-hosted LLM agents to generate a role-restricted, sheets-grounded answer with suggested next actions.

How it works

  1. Receives a question from n8n Chat or a POST request to the procurement-copilot webhook and normalizes the request fields (user identity hints, object ID, and confidence threshold).
  2. Loads a Users Google Sheet to resolve the requester’s role and RBAC rules, and returns an access-limited response if the role is unknown.
  3. Uses a Groq LLM agent to classify the intent and extract entity IDs (requisition, PO, invoice, supplier, contract), then validates/fills missing entities from the question text.
  4. Loads matching procurement data from Google Sheets tabs (Requisitions, Approvals, Suppliers, Contracts, and Invoices) and assembles a single context object.
  5. Filters the context by role (allowed entities) and redacts denied fields before sending only the allowed context to a second Groq LLM agent.
  6. Generates a grounded JSON answer, removes any suggested actions not permitted for the user’s role, and routes either a confident response or a clarification message based on the confidence threshold.
  7. Returns the final result as JSON to the webhook caller or as chat text back to n8n Chat.

Setup

  1. Create and connect Google Sheets credentials, and ensure the spreadsheet includes the Users, Requisitions, Approvals, Suppliers, Contracts, and Invoices tabs with the expected columns (IDs like REQ-…, PO-…, INV-…, CTR-…).
  2. Add a Groq API credential and select it for both the intent and answer LLM model nodes.
  3. Populate the Users sheet with each caller’s email and a valid role (buyer, approver, requisitioner, category_manager, ap_analyst, supplier_manager) to enable access.
  4. If using the webhook entry point, copy the production webhook URL for procurement-copilot and configure your portal/application to POST questions (and optional userEmail, roleHint, objectId, and confidenceThreshold).

Additional info

How To Customize Nodes

Add‑ons

Use Case Examples

Troubleshooting Guide

IssuePossible CauseSolution
Workflow returns “Access limited: add [email] to Users sheet…”[cite: 1]The user’s email was not found in the Google Sheets database, or their assigned role is invalid[cite: 1].Ensure the user’s email is added to the Users sheet with a valid role (e.g., buyer, approver)[cite: 1].
AI returns “I could not produce a grounded answer from Google Sheets context.”[cite: 1]The specific REQ, PO, INV, or Supplier ID was not found in any of the Google Sheets during the data enrichment phase[cite: 1].Verify that the record actually exists in the connected Google Sheets and that the ID matches the expected formatting (e.g., REQ-10482)[cite: 1].
Suggested actions are missing from the response.The generated action was blocked by the Role-Based Access Control (RBAC) filter[cite: 1].Check the Resolve Identity and Role node to verify if that specific action is listed in the allowedActions array for the user’s role[cite: 1].
Google Sheets nodes fail to execute.Missing or expired credentials, or an incorrect Document ID[cite: 1].Re-authenticate the googleSheetsOAuth2Api credentials and verify the Document ID in all five sheet loading nodes[cite: 1].

Need Help?

If you need a helping hand to set up these API connections, customize the RBAC code nodes or build custom Add-Ons (like integrating this copilot directly into your Slack workspace or ERP system), contact WeblineIndia. Our n8n technical experts can help you customize this workflow or build similar automated, enterprise-grade AI solutions tailored exactly to your business needs!

đź”— Nodes Used

Google Sheets, Webhook, AI Agent, Chat Trigger, Groq Chat Model

📥 Import

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

📖 Importing guide · 🔑 Credential setup