Skip to content
NEWMarketplace and your team: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / AI Agents & Assistants

AI Agents & Assistants

Trace refund approval flows with OpenRouter and OpenTelemetry

When an API call/webhook arrives, it runs an AI agent with OpenRouter and OpenAI / ChatGPT.

What it does

## Trace a human approval across a wait with OpenRouter and OpenTelemetry ### Quick overview This workflow enriches a refund request, drafts an approval proposal with an AI agent, and waits for a human to approve or reject it, so you can follow one execution across the wait with OpenTelemetry tracing. It is the Exercise 5 template from the n8n Production AI Playbook post on Audit & Trace. No payment is processed. ### How it works 1. Receives a POST webhook request with a requestId, amount in cents, reason and a traceparent header. 2. Enrich Request Sub-workflow validates the request and adds simulated customer context. 3. Policy Service Call sends an HTTP request that carries the trace context to an echo service. 4. Approval Proposal Agent drafts a proposal using an OpenRouter chat model. 5. Return Approval Request responds with the proposal, executionId and resumeUrl. 6. Wait for Human Approval pauses until a decision is posted to the resume URL. 7. Validate Approval checks the decision, and Record Approval saves it. Invalid decisions stop at Reject Approval. ### Setup 1. Import, save and publish the Exercise 5 enrichment sub-workflow, then select it in Enrich Request Sub-workflow. 2. Add an OpenRouter API credential to OpenRouter - Approval. 3. Optionally enable OpenTelemetry tracing in Settings > OpenTelemetry. 4. Select Execute workflow and POST {"requestId":"REQ-2001","amount":4999,"reason":"duplicate charge"} with a traceparent header. 5. POST {"approved":true,"approver":"Demo reviewer"} to the returned resumeUrl. In production, authenticate the reviewer and protect the resume endpoint.

The steps

  1. Webhook - Approval Request
  2. Enrich Request Sub-workflow
  3. Policy Service Call
  4. Approval Proposal Agent
  5. OpenRouter - Approval
  6. Return Approval Request
  7. Wait for Human Approval
  8. Validate Approval
  9. Reject Approval
  10. Record Approval

Similar automations