Language

Visitor-side endpoints: Q&A, handoff to human and translation

Identity's two layers both avoid relying on knowing the number; the AI's stepping aside is judged server-side; the quota only stops the model, not the people; and length and size are two numbers.

The few things a visitor does on the page — ask one question, request a human, send an image, give a "was this useful" — sit behind a set of public interfaces. This page is written for people who will build their own frontend or client: addresses, how identity is computed, what failure looks like.

Three capabilities. Q&A has a synchronous and a streaming address; handoff to human is one initiation endpoint plus a set of in-conversation operations; and there is one "translate a passage in place". Q&A retrieves published knowledge first and then hands it to the model; when keywords do not hit it still asks the model, allowing general explanations, suggestions, greetings and clarification, rather than throwing a fixed "please transfer to a human"; the prompt explicitly forbids fabricating prices, delivery times, policies, contact details or execution results. A miss itself does not equal "suggest transfer to human" — that marker is not decided by the hit rate; transfer to human is the visitor's own choice.

Identity has two layers, neither relies on "knowing the number". The conversation identifier is generated on the visitor side, and the server issues an HttpOnly visitor cookie; from then on reading and writing this conversation both need it. Knowing the conversation number alone cannot read or operate someone else's conversation: pulling messages, sending messages, canceling, closing and restoring AI all require the person's own credentials. The AI Q&A history during a wait is a separate matter — it is claimed with server-issued answer credentials, carrying at most several pairs at a time, with idempotent duplicate submissions; a publicly guessable conversation identifier cannot carry someone else's Q&A records into your own conversation.

Feedback votes per item, and the server only stores the credential's hash. An AI answer carries back a message number and a feedback token for that item; only the token holder can vote, and resubmitting the same state does not count twice. Feedback on human answers goes through another address, needs the owning conversation's visitor cookie, and that message must have been sent by an agent.

After the handoff the AI steps aside, and the server judges. The criterion is the conversation row in the store (whether someone has picked it up), not the browser's self-reported state. When the visitor and the agent share a language, the AI fully steps aside; when languages differ, the AI only does translation forwarding. In both cases it no longer answers content questions — so "the agent is typing and the bot interjects" cannot happen, and that outbound call's money is not spent.

The reception mode is public; the rest is not. One read-only address answers two things: which mode tier is current, and whether message translation is on. It contains no provider, keys, quota, agent list or conversation records. The difference in visitor-side behavior across modes must be said: in one tier, transfer requests without an explicit human request are refused (an established conversation can still be read and written with its own credentials); in another tier, Q&A does not call the model and the client itself hands the request to a human. Third-party clients must branch by their own policy and must not display the status notice as an AI-generated answer.

When the quota runs out only the model stops, not the people. Visitor Q&A has its own quota ledger (separate accounts from site translation and backend creation assistance). When exhausted, the two Q&A addresses return 503 with a stable error code, while handoff to human, sending messages and sending attachments go as before — this gate blocks outbound-call costs, not visitors at the door. The order of judgment is fixed: first whether it is human mode, then whether the model is configured, then the quota, and only last the outbound call; so a visitor in human mode always sees "transferred to human" first, not a billing error.

Length and size are two numbers; do not mix them. The question is capped by character count (the same limit as the floating window's input box), and the request body is capped by bytes — one CJK character is three bytes, and the mixed-use symptom is "just let him finish typing, and the server refuses". The greeting and contact details are tiered (the latter leaves room for an international number with an extension), over-limit returns 413 rather than "decode failure = 400"; the reverse direction is also pinned: half a JSON must be 400. The visitor's own sent message carries a client message number for idempotency, and a resend does not produce a second one.

Rate limiting uses three buckets, by source address. The read-only bucket, the money-spending bucket and the writing bucket each have their own budgets; over-limit returns 429 with a retry-after time, without blocking the source address. All three buckets use the client address resolved uniformly by the kernel, not trusting unverified forwarding headers — otherwise all visitors share one bucket, and tracing by address records the proxy's address. Specific numbers are not written into the public docs, because they are tuned per version, and shapes like "reading a page once consumes one write budget" are what you really need to guard against when integrating.

The streaming one's failure criteria deserve a separate read. Before the first segment there is a "thinking" state with a status role, and sending again is not allowed before completion; connection failure, rate limiting and server errors can, before consumption starts, fall back to the backup provider by rule; once consumption starts, it is never auto-resent. A broken stream, a missing end marker, or model output truncated by length — none counts as success — the browser side must clear that unfinished bubble and clearly indicate, rather than leaving half a sentence.