The bot was ending answers with "see §22.2 in the documentation". Nobody
outside the team can open that document, so the citation points at a shelf
the customer cannot reach and makes a complete answer look partial.
The rule is now derived from whether a reachable URL exists. Set KB_DOC_URL
(or KB_GOOGLE_DOC_ID, whose Doc URL is used automatically, since it has to
be link-shared for the bot to read it at all) and the bot cites the section
by NAME and includes the link. Set neither and it stops citing sections
altogether and just gives the answer.
Names rather than numbers on purpose: section numbers shift every time the
document is edited, so a number in a chat transcript goes stale quickly
while "the Vendor COI compliance section" keeps pointing at the right place.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Stop the bot inventing detail and answering the wrong feature
Testing "tell me about PO Receipt Matching" surfaced two problems. The
removal of that feature from the knowledge base worked — the bot did not
describe the unreleased Vista capability — but it silently answered about
ordinary PO matching instead, and padded the answer with requirements that
appear nowhere in the documentation ("the invoice must reference a valid
PO number", "for subcontracts ensure Cost Type, Job Id & Cost Id is also
enabled", "enable Consolidate Line Items to simplify matching").
Two fixes:
Knowledge base — a new section names the capabilities users ask for that
do not exist (receipt-level matching, bulk delete, un-approve, full
invoice export, Foundation division sync, lien waiver tracking) and gives
the honest answer plus the nearest real feature. Grounded text is far more
reliable here than prompt pressure alone.
System prompt — accuracy is stated as the first and most important rule,
with an explicit ban on inventing prerequisites or carrying a setting over
fr…
Make the Google Doc an opt-in override instead of the default source
knowledge_base.md is now the source of truth: it is written against the
deployed code and versioned alongside the app. A Google Doc can still
override it for support-side edits — set KB_GOOGLE_DOC_ID on the Space
and restart.
Hard-coding a Doc id is a trap here. A Doc that has drifted behind this
file is indistinguishable from a current one at runtime, so pointing at a
stale Doc silently downgrades every answer. Making the override explicit
means the bot cannot regress just because someone shared a document.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Repoints GOOGLE_DOC_ID at "Beiing Human Support KB v2.1 — FAQ Chatbot
Source (CURRENT)", which is rebuilt from the web app and backend source
and covers roles, document visibility, every company setting, all
supported ERPs, code visibility and enforced limits.
Also stops a failed fetch from silently emptying the knowledge base.
fetch_google_doc_text used to return its error message as a string, and
that string became doc_context — so any fetch failure turned every answer
into "I don't have information about that" and mailed an unanswered-question
alert to support on every message. It now returns None on failure, validates
the body (a Doc that is not link-shared answers with an HTML sign-in page,
not an error status), and falls back to knowledge_base.md committed here.
The Doc stays the source of truth so support can edit answers without a
code change; the bundled copy only covers a fetch failure.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>