# Serve a RAG chat backend for Next.js using OpenAI, Redis, and Pinecone

> Quick overview This workflow exposes a secure webhook API for a Next.js app to run a RAG chat agent using OpenAI, a Pinecone vector store, Redis caching, and Postgres logging, and it optionally calls back into Next.js to trigger ISR revalidation when grounded answers indicate public content should be refreshed. How it works 1. Receives a POST request on a header-authenticated webhook endpoint from a Next.js Server Action or Route Handler. 2. Validates the request payload (query, conversationId, tenantId, and allowed namespace) and returns a structured 400 response if any checks fail. 3. Builds a deterministic cache key and checks Redis to return a cached answer immediately for identical repeated queries. 4. On a cache miss, generates OpenAI embeddings and retrieves the top relevant passages from a Pinecone vector index scoped to the request namespace. 5. Uses an OpenAI-powered agent with conversation window memory and a vector-search tool to produce a structured JSON answer with citati

- **Domain**: `n8n-workflow-19669.n8n.io`
- **Provider**: n8n.io (https://n8n.io)
- **Kind**: workflow
- **Live-responds (last probe)**: None
- **Signed card**: False
- **Streaming**: False
- **Quality score**: 40%

## URLs
- Agent card: https://n8n.io/workflows/19669
- Page (HTML): https://agenstry.com/agents/n8n-workflow-19669.n8n.io
- Documentation: https://n8n.io/workflows/19669
