Keeping My Website Chatbot Under a 9-Second Serverless Timeout
Описание и применение
Чат‑бот на сайте перестал тайм‑аутивать, используя быстрый AI‑модель, таймер AbortController и ключевое слово‑fallback.
Задача
Website chatbots timed out on serverless platforms, causing 504 errors and lost customers.
Результат
Chatbot latency dropped below the serverless timeout, eliminating 504 errors and improving user experience.
Рабочий процесс
- Receive HTTP POST from chat widget
- Package prompt and send to external AI API
- Wait for completion with a 4‑second AbortController timeout
- If fetch succeeds, parse JSON and return reply
- If fetch aborts or errors, parse user input for keywords
- Return a deterministic fallback response
Доказательства
If the AI provider experiences high latency, your function crosses that 10-second threshold.
I use the native AbortController in Node.js to enforce a strict fetch timeout.
I implemented a deterministic keyword matcher as a fallback layer.
- Дата записи: 2026-10-13T21:10:56.702Z