Disclosure up front: I’m the author of a paid n8n workflow pack (linked at the end). Most of this post is the pattern itself, which you can build without buying anything, plus one free thing you can use.
When an AI step decides “approve refund”, the dangerous part usually isn’t the model. It’s what happens when the same request arrives twice (retry, webhook redelivery) or several times at once. These are the guards I ended up with:
- Idempotency key per refund decision. The caller sends an
Idempotency-Key; a replayed key returns the stored result instead of running the refund again. - Per-order lock. Concurrent requests for the same order wait instead of racing.
- “Already refunded?” check against the store right before the refund call, as a last line of defence.
- Fail safe on bad model output. Invalid JSON or an API error → one corrective retry → otherwise hand off to a human. No money moves on bad output.
- AI classifies, rules decide. Refund window, auto-refund limit and evidence requirements are plain deterministic checks, not prompt instructions.
How I tested it, honestly scoped: n8n 1.123.84 self-hosted, against a bundled mock store. Resending a request, or firing 10 at the same time, still produced exactly one refund. I have not run it against a live Shopify store yet, so if you build this, do a $1 refund on a development store first.
Free, no purchase needed:
If you draft review replies with an AI agent (Claude Code / Codex), I published a free skill that writes one specific reply per review and flags chargeback, legal, safety or allergy mentions for a human instead of answering them: https://skillhq.dev/skills/qihangwu/review-reply-drafter
The full set (8 workflows: order status, ticket triage, FAQ answers, review replies, refund triage/risk/execution) is my Store Support Agent Pack: Store Support Agent Pack for n8n (8 AI workflows)
Happy to go deeper on how the lock and key storage work in n8n. How do you handle webhook redelivery in workflows that move money?