Public
24/7 customer care chatbot using Google Sheets FAQs + Gemini AI
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Customer Care FAQ Bot

A no-AI FAQ chatbot for your website. It reads your questions & answers from a Google Sheet and returns the most probable answer using fuzzy keyword matching (handles typos and synonyms). When it doesn't know an answer, it asks the customer for their phone number and details, which are saved for your team to follow up.

How it works

Rendering mermaid diagram...

Files

  • main.ts — HTTP entry point. Serves the chat UI and exposes /api/chat, /api/lead, and /admin.
  • faq.ts — loads the sheet (CSV) and does the keyword matching. No AI.
  • leads.ts — saves & lists captured leads in this val's SQLite database.
  • index.html — the chat widget shown to your website visitors.
  • admin.html — table of captured leads (search + CSV download).

Setup

1. Build your FAQ Google Sheet

First row must be headers. Columns (header names are matched case-insensitively):

QuestionAnswerKeywords (optional)
What are your opening hours?We're open 9am–6pm Mon–Fri.timing hours open close
Do you offer refunds?Yes, within 30 days.money back return

The optional Keywords column improves matching — add synonyms customers might use that don't appear in the question itself.

2. Publish the sheet as CSV

In Google Sheets: File → Share → Publish to web, choose the tab, select Comma-separated values (.csv), and copy the link. Then set it as an env var:

👉 Add SHEET_CSV_URL here: https://www.val.town/x/microshieldmagics/customer-care-bot/environment-variables?key=SHEET_CSV_URL

3. (Optional) Protect the admin page

Set a password so only you can view captured leads:

👉 Add ADMIN_KEY here: https://www.val.town/x/microshieldmagics/customer-care-bot/environment-variables?key=ADMIN_KEY

Then open the leads page at /admin?key=YOUR_KEY. If you don't set ADMIN_KEY, /admin is open to anyone with the link.

Viewing leads

  • Web table: visit /admin (or /admin?key=...) — search and "Download CSV".
  • Raw JSON: /admin?format=json (same auth rules).

Embedding on your website

Add an iframe pointing at the val's URL:

<iframe src="https://YOUR-VAL-URL/" style="border:0;width:440px;height:720px"></iframe>

Tuning the matcher

In faq.ts, CONFIDENCE_THRESHOLD controls how confident a match must be before the bot answers (vs. asking for details). Raise it to be stricter (fewer wrong answers, more "leave your details"); lower it to answer more often.