Smarter chatbot + support matching by meaning (Marty 2026-11-16): the hub's semantic match (free core2 embeddings)
Chatbot (chatbot.js + netkb.js route): a hand-off pattern still answers first; then the hub's POST /v1/kb/match answers with this site's entry when it is sure, keeps or overrules the CANNED regex hit, and picks the AI prompt context, this site's own entries first. 1.5 s timeout, then the hub is skipped for 30 s and the old pattern + BM25 path answers (NETKB_MATCH=0 = off). Support desk: while a signed-in member types a new ticket, POST /api/my/support/suggest shows the closest help answers (KB entries only, incl. ones written from past tickets, never another member's ticket; BM25 when the hub is down); Send is never blocked. help-screen.js?v=20261116sg. Tests: qa/netkb-semantic.test.mjs (route/suggest decisions, fail soft, shared-file parity; run.sh kb) and qa/support-suggest.mjs (run.sh member). netkb.js is the same file in all eight network sites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ const drip = require('./drip');
|
||||
const spaces = require('./spaces'); // DO Spaces video storage (inert unless DO_SPACES_* set)
|
||||
let QR = null; try { QR = require('qrcode'); } catch (e) { /* optional */ }
|
||||
const chatbot = require('./chatbot');
|
||||
const netkb = require('./netkb'); // the shared network KB on the hub; suggest() for the Help screen (2026-11-16)
|
||||
const kb = require('./kb'); // the assistant's knowledge base: Admin > Knowledge base, seeded from chatbot.js CANNED + kb-seed.js (2026-10-20)
|
||||
const coach = require('./coach'); // coaching view, nudges, digest, prospects, link stats
|
||||
const tank = require('./tank'); // holding tank: unsponsored free members, adoptions, pay-it-forward
|
||||
@@ -1895,6 +1896,17 @@ const server = http.createServer(async (req, res) => {
|
||||
if (!s || !s.email) return json(res, 200, { unread: 0 });
|
||||
return json(res, 200, { unread: await helpdesk.unread(s.email) });
|
||||
}
|
||||
// help desk suggestions (2026-11-16): while a signed-in member types a new ticket, the closest help answers (the hub's semantic
|
||||
// match over the network KB, BM25 here when the hub is slow or down). KB entries only, never another member's ticket. Never blocks sending.
|
||||
if (p === '/api/my/support/suggest' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const b = await readBody(req);
|
||||
if (supportFlood('sg:' + String(s.email).toLowerCase(), 240, 3600000)) return json(res, 200, { items: [], via: 'limited' });
|
||||
const text = (String(b.subject || '').slice(0, 200) + '. ' + String(b.body || '').slice(0, 800)).trim();
|
||||
try { return json(res, 200, await netkb.suggest(text, { own: await kb.own(), fallback: q => kb.context(q, 4) })); }
|
||||
catch (e) { console.error('support suggest', e.message); return json(res, 200, { items: [], via: 'error' }); }
|
||||
}
|
||||
if (p === '/api/my/support' && (req.method === 'GET' || req.method === 'POST')) {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
|
||||
Reference in New Issue
Block a user