feat(assistant): v2 — query-language detection, analytics, chips, auto-index

Addresses real gaps found in testing (a Macedonian question on an English
page returned nothing):

- Detect the language of the QUESTION (Cyrillic -> MK; Slovene markers -> SI;
  else the page language) and load that language's index + curated answers.
  Fixes cross-language questions.
- Expand curated multilingual intents (now incl. enrolment/eVŠ, deadlines,
  health, "what is MSOS", etc.) with stem keywords for better paraphrase
  matching. MK/SI answers machine-drafted — proofread before launch.
- Suggested-question chips on open (localized) to guide users.
- Privacy-safe analytics: fire a GA4 'assistant_query' event ONLY after the
  visitor accepts cookies (q text, result type, question vs page language) so
  the team can see real FAQs and unanswered questions.
- Move the widget to bottom-left on pages with the floating "Become a member"
  CTA so they never overlap. Design polish (chips, typing dots, launcher pulse).
- CI: rebuild the search index on every deploy (setup-python + build script)
  so the assistant stays in sync with content automatically. Build script is
  now path-portable (no hardcoded path).

Verified in a headless browser: MK-on-EN now answers correctly, chips work,
analytics event fires only with consent, become-a-member offset applies,
zero console errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
popovskikandClaude Opus 4.8 committed 2026-08-04 01:48:39 +02:00
1 parent f7f297bd65
commit 661943bb34
4 files changed
+263 -185

No files matched your search

+3 -1
View File
@@ -5,7 +5,9 @@ assistant/index-<lang>.json (loaded lazily in the browser, no API needed)."""
import os, re, json, glob
from bs4 import BeautifulSoup
ROOT = r"C:\Coding\msosorg.com"
# Repo root = parent of this script's tools/ folder. Works locally and in CI
# (override with SITE_ROOT env var if ever needed).
ROOT = os.environ.get("SITE_ROOT") or os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
os.chdir(ROOT)
OUT = os.path.join(ROOT, "assistant")
os.makedirs(OUT, exist_ok=True)