Quick overview
This workflow receives refund requests via webhook, scores risk using n8n Data Tables and rule-based signals, generates an investigation note with Groq, and routes approvals through Gmail before optionally issuing refunds via Paystack and notifying customers when Paystack confirms processing.
How it works
- Receives a refund request via an n8n webhook and loads configurable thresholds like risk bands, auto-approve limits, and the approver email.
- Validates and normalizes the incoming payload, replying 202 for valid requests or 400 with validation errors.
- Looks up the matching order and the customer’s past refund cases in n8n Data Tables, then calculates an auditable risk score and risk band from fixed rules.
- Sends the scored case details to Groq to generate a short JSON case note with a summary, recommendation, and optional question for the customer.
- Auto-approves low-risk, low-value requests, otherwise sends an approval email via Gmail with Approve/Reject buttons and waits for the reviewer response.
- Logs the final decision to the refund_cases Data Table and emails the customer the outcome via Gmail.
- If enabled and a payment reference exists, triggers a Paystack refund (full via the Paystack node or partial via the Paystack Refund API), then listens for Paystack’s refund.processed webhook to mark the case processed and email the customer that the refund was sent.
Setup
- Create and select two n8n Data Tables for orders and cases (refund_orders and refund_cases) and ensure their column names match the fields used in the workflow.
- Add credentials for Groq (LLM), Gmail, Paystack (community node), and an HTTP Bearer Auth credential containing your Paystack secret key for the partial refund API call.
- Update all placeholder values in Set Configuration Parameters (for example [YOUR STORE NAME] and [APPROVER EMAIL]) and match the same store name placeholder in the Paystack refund event parsing step.
- If you enable Paystack refunds, install the n8n-nodes-paystack community node and register the Paystack “refund processed” webhook URL from the Paystack trigger in your Paystack dashboard.
- Configure your source system to POST to the refund-request webhook URL with order_id, customer_email, amount, and reason (optionally customer_name and request_id).