This repository contains a lightweight, front-end chatbot prototype designed for spartanburgregional.com.
- Offers a website "information desk" for common health-system navigation questions.
- Uses a floating chat widget button in the lower-right so users can open/close chat from any page.
- Includes a minimize control in the header so the chat can collapse without disappearing entirely.
- Includes modern UX touches: quick action chips, typing indicator, timestamped messages, and live website-index status.
- Routes people to a wider set of service lines (primary care, urgent care, records, billing, locations, women's services, heart care, imaging, lab, surgery, rehab, behavioral health, pediatrics, and more).
- Adds an emergency guardrail that redirects urgent symptom language to 911/emergency care.
- Returns clickable recommendation chips for every link result.
- Loads and indexes sitemap pages so fallback answers can recommend real pages based on the user's question.
python3 -m http.server 8080Then open http://localhost:8080.
The standard Drupal approach is to include the widget assets globally in your base page template (or theme library):
- Include
styles.csson all public pages. - Include the widget markup from
index.htmlnear the end of<body>. - Include
chatbot.jsafter the widget markup. - Deploy the Netlify Function proxy (or equivalent server endpoint) for sitemap fetches.
Once added at template level, the same chatbot appears site-wide.
- The widget uses a Netlify Function proxy at
/.netlify/functions/sitemap?page=1|2to avoid browser CORS issues when fetching sitemap XML. - Function source is in
netlify/functions/sitemap.js. - Front-end still includes direct sitemap URL fallback, but Netlify function routes are preferred.
The chatbot attempts to index these pages at startup:
/.netlify/functions/sitemap?page=1/.netlify/functions/sitemap?page=2https://www.spartanburgregional.com/default/sitemap.xml?page=1https://www.spartanburgregional.com/default/sitemap.xml?page=2
When a question does not match a hard-coded intent, the bot scores sitemap pages by query token overlap and returns top matches.
index.html— Floating widget markup and chat shell.styles.css— Widget/button styling and modern UX visual components.chatbot.js— Intent routing, safety handling, widget controls, clickable links, quick actions, typing indicator, sitemap indexing, and legacy-shell cleanup.netlify/functions/sitemap.js— Server-side sitemap proxy for Netlify deployments.

