Handling Webhook Timeouts in n8n When Processing Heavy AI Workflows

When triggering an n8n workflow via an incoming webhook that runs an LLM chain, the HTTP request frequently timed out with a 504 Gateway Timeout because the AI analysis took 20 to 45 seconds.

The Architectural Fix: Decoupling Response from Processing

Instead of making the client wait for the final AI output, I changed the Webhook node setting to Respond: Using ‘Respond to Webhook’ Node.

{
  "parameters": {
    "respondWith": "json",
    "responseBody": "{\"status\": \"accepted\", \"message\": \"Processing queued\"}"
  },
  "name": "Immediate 200 OK",
  "type": "n8n-nodes-base.respondToWebhook",
  "typeVersion": 1.1,
  "position": [400, 200]
}

The webhook returns HTTP 202 Accepted within 150 milliseconds, and the heavy AI processing continues in the background, eventually sending the result via Slack or webhook callback.

Leave a Comment