{"product_id":"n8n-webhook-llm-fallback-anthropic-openai-gemini-postgres-slack","title":"n8n Webhook LLM Fallback: Anthropic, OpenAI, Gemini + Postgres \u0026 Slack","description":"\u003ch3\u003eResilient LLM answers via an n8n Webhook—Anthropic → OpenAI → Gemini with Postgres logging and Slack alerts\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow exposes a \u003cstrong\u003ePOST webhook\u003c\/strong\u003e that sends your prompt through a \u003cstrong\u003efallback LLM chain\u003c\/strong\u003e: it tries \u003cstrong\u003eAnthropic\u003c\/strong\u003e, then \u003cstrong\u003eOpenAI\u003c\/strong\u003e, and finally \u003cstrong\u003eGoogle Gemini\u003c\/strong\u003e. It validates outputs deterministically, logs attempts to \u003cstrong\u003ePostgres\u003c\/strong\u003e with a circuit breaker, and posts a \u003cstrong\u003eSlack\u003c\/strong\u003e alert when fallback or degraded responses occur.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eReceives requests\u003c\/strong\u003e on an n8n Webhook (or runs manually for testing) with an LLM prompt and optional validation settings.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNormalizes and safeguards inputs\u003c\/strong\u003e: applies defaults, coerces types, and generates a prompt hash for stale-cache fallback.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eBuilds an ordered provider chain\u003c\/strong\u003e using provider health stored in \u003cstrong\u003ePostgres\u003c\/strong\u003e, optionally honoring a preferred provider and skipping providers with an open circuit.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCalls providers\u003c\/strong\u003e via HTTP, then normalizes and validates the response using deterministic rules (status codes, empty\/truncated\/blocked\/refusal output, length\/keyword rules, and optional JSON + schema checks).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eLogs every attempt\u003c\/strong\u003e to Postgres and updates the circuit-breaker state; if needed, it retries with backoff and repair hints, or switches providers.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eHandles total failure gracefully\u003c\/strong\u003e: if all providers fail, it returns a recent successful response for the same prompt hash from Postgres; otherwise it returns an HTTP \u003cstrong\u003e503\u003c\/strong\u003e degraded message.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSlack notification only when needed\u003c\/strong\u003e: posts an alert when fallback\/degraded mode is used.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eMission-critical SaaS automation that must keep working even when an LLM provider is degraded.\u003c\/li\u003e\n  \u003cli\u003eWebhook-driven customer support or internal tools needing consistent JSON-formatted outputs.\u003c\/li\u003e\n  \u003cli\u003eTeams managing reliability with provider health checks, circuit breaking, and audit trails in Postgres.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eIntegrations:\u003c\/strong\u003e Webhook (POST), \u003cstrong\u003ePostgres\u003c\/strong\u003e, \u003cstrong\u003eSlack\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n node types used:\u003c\/strong\u003e if, set, code, wait, slack, switch.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCore reliability features:\u003c\/strong\u003e LLM failover chain (Anthropic → OpenAI → Google Gemini), deterministic validation, prompt-hash stale fallback, Postgres circuit breaker logging, and Slack alerts.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46146291597491,"sku":"N8N-20259","price":36.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/u6GJ6HetuxKSpcsLAft50_BwBIssfj.png?v=1790845740","url":"https:\/\/buyflowscripts.com\/products\/n8n-webhook-llm-fallback-anthropic-openai-gemini-postgres-slack","provider":"N8N Commerce","version":"1.0","type":"link"}