# AI support chat

An open-source AI customer support chat for small business websites, built with Next.js, TypeScript, PostgreSQL and Claude. Visitors ask in a one-script-tag widget or on a hosted help centre, Claude answers only from the owner's help articles and cites them, and questions the articles don't cover go to an owner inbox with the transcript, alongside an article editor, an Unanswered list and widget settings.

- Framework: Next.js (JavaScript)
- Category: Apps / AI apps, Helpdesk and support
- Creates: a server app and a PostgreSQL database on the Shared tier (1 GB)
- Plan: Lite or above
- Price: Free
- Author: Light Cloud
- Page: https://templates.light-cloud.com/apps/ai/ai-support-chat-template
- Updated: 2026-11-21

## Features

- A chat widget added to any website with one script tag, opening full screen on phones and closing with Escape
- Answers from your published help articles only, picked with PostgreSQL full-text search where rare words count most, with no vector database
- Every answer lists the articles it used, linked to their pages on a hosted help centre with topics, an FAQ and LocalBusiness and FAQPage markup
- Says when the articles don't cover a question and offers a pre-filled hand-off form that lands in the owner inbox with the transcript
- An Unanswered list of questions the articles missed, each with Write an article (the question becomes the title) or Dismiss
- Streaming replies, conversation transcripts, and the widget's colour, greeting, button label and corner with a live preview
- A labelled demo mode without ANTHROPIC_API_KEY that replies with the best article's short answer and matching paragraph, also used when Claude can't be reached
- Per-visitor rate limits, an hourly ceiling on Claude calls, a demo Bristol bike shop with 18 articles, and WCAG 2.2 AA in light and dark

## What you need

- A paid plan: deploying creates a PostgreSQL database, which the Free plan does not include
- To run it locally: Node.js 22.12 or newer, npm, and Docker for a local PostgreSQL
- No API keys needed to start: without ANTHROPIC_API_KEY the chat runs in a labelled demo mode that quotes the best-matching article
- Optional: ANTHROPIC_API_KEY so Claude writes the answers, and ANTHROPIC_MODEL to choose the model (default claude-opus-5-5)
- Optional: RESEND_API_KEY and EMAIL_FROM to email new hand-offs and password resets; without them they go to the server log and hand-offs stay in the inbox

## About

The owner edits everything at /admin: business details and opening hours, help articles written as questions with a short answer and a Markdown body, the widget and the Unanswered list; the assistant's instructions are systemPrompt in src/lib/ai.ts and the demo bike shop is scripts/seed.mjs. With a key, up to three articles that clear a low bar go to Claude as citable documents with the last six questions and answers, an offer_handoff tool marks questions they don't cover, and past an hourly ceiling for the whole app answers fall back to the articles. The Claude path has never been called live: it was tested by replaying recorded-style streams through the Anthropic SDK, so send one real question before relying on it. Retrieval is keyword search with stemming, not embeddings, and demo mode only quotes strong matches, so a question such as whether a helmet that's too small can be returned gets a couldn't-find reply there, while with Claude on the article is still sent. Rate limits are kept in memory per instance, there is one owner account with no team roles, and replies to hand-offs go by email from your own mail program, so the visitor is not told in the chat. How well the widget button stands out on your own website depends on the colour you pick.

## Variables

- `AUTH_SECRET`: generated

## Questions

### How do I add an AI chatbot to my small business website?

Deploy this template, write a help article for each question your customers ask, then paste the one-line script tag from the owner area, Widget, into your website. The chat button appears in the corner and answers from your articles.

### How do I stop an AI support bot from making things up?

This chat only sends Claude your own help articles and business details, tells it to answer from those alone, and has it cite the article for each answer. When the articles don't cover a question, it says so and offers a form to reach you instead of guessing.

### Can an AI support chat hand a conversation over to a person?

Yes. Visitors can press Talk to a person at any time, and the chat offers it whenever the articles don't have the answer. Their question and email land in your inbox with the transcript, and are emailed to you when RESEND_API_KEY is set.

### Does it work without an OpenAI or Anthropic API key?

Yes. Without ANTHROPIC_API_KEY it runs in demo mode and replies with the best-matching help article's own words, clearly labelled, but only when the match is strong. Add the key to have Claude write the answers.

### Does a support chatbot need a vector database or embeddings?

Not this one. It picks articles with PostgreSQL's built-in full-text search, weighted so rare words matter most, which works well for the tens or hundreds of articles a small business has; a question worded very differently from every article may miss.
