We've all been there: you click a link, expecting to land on a helpful page, but instead you're met with a generic "404 — Page Not Found" message. Frustrating, right? At James Studio, we decided to do something about it.
The Problem with Traditional 404s
Traditional 404 pages are dead ends. They tell users what went wrong, but offer no path forward. You might see a "Return Home" button, but that's not always helpful if you were looking for something specific. Users often bounce, frustrated that they couldn't find what they needed.
Our Solution: AI-Powered Suggestions
When a user lands on a 404 page on our site, we don't just show an error. We analyze the URL they tried to visit and use AI to suggest the most relevant pages they might have been looking for.
Here's how it works:
- We capture the invalid URL path
- We send it to our AI chat endpoint along with a list of all available pages on our site
- The AI analyzes the path and determines which pages are most relevant
- We display up to 3 suggested pages as clickable buttons
How We Built It
We use the same AI chat endpoint that powers our website's chat widget. When the 404 page loads, it makes a POST request to /api/chat with a structured prompt asking for relevant page suggestions.
The AI is given context about our site structure and told to prioritize actual pages over contact options. It also has a 30-second timeout to fetch site content, ensuring it has up-to-date information.
Reliability First
AI is powerful, but it's not infallible. If the AI endpoint fails or returns an error, we have a reliable fallback system in place. We use simple keyword matching to suggest relevant pages based on the URL path—for example, if someone tries to visit /project/example, we'll suggest pages from our portfolio section.
This ensures users always get helpful suggestions, even if the AI is temporarily unavailable.
The Result
Users who hit a 404 on our site now see a helpful message: "Did you mean one of these?" followed by intelligent suggestions. They can quickly navigate to where they actually wanted to go, reducing frustration and bounce rates.
It's a small detail, but these small details are what make the difference between a frustrating experience and a helpful one.
Want to see it in action?
Try visiting a non-existent page on our site, like /this-page-does-not-exist, to see the intelligent suggestions in action.
Get in Touch