Skip to main content
A coding agent such as Claude Code can read how your agent answers customers: which knowledge each reply used, which searches found nothing, which sources are never used, and which questions keep coming back as knowledge gaps. With a read-only key it reports and recommends. With write access it can also add the fixes, retrain and run your test questions to compare before and after.

Set up

1

Create a key

In Team settings → API keys, create a key. The default read access (knowledge:read, conversations:read) covers answers, searches, stats and gaps; also turn on quality:read to read test questions and runs. To let the agent apply fixes, also turn on knowledge:write and quality:write.customers:read is off by default, so the analysis endpoints return customer emails and phone numbers as [email] and [phone] and keep them out of the agent’s context.
2

Install the CLI and sign in

Or set TOTEBOT_API_KEY in the environment. See the CLI overview.
3

Ask

In Claude Code, ask for example: “Analyse the knowledge base of my Shop agent and tell me what to fix.” The Totebot skill and totebot ai-guide give the agent a step-by-step recipe.

What the agent does

The recipe in totebot ai-guide (“Analyse and improve my knowledge base”) walks through these steps: The API reports data as it is (counts, sources, scores, labels). The analysing agent decides what matters. To go further than knowledge, with instruction and model changes tested before they are applied and a rollback if results get worse, see Optimize your agents with Claude Code.

What the data means

  • Answers. For each customer message: the replies, every knowledge search with the sources it returned and their scores, the tools the bot called, and usedNoTool when the bot answered from its instructions alone. Tool calls come from the stored playground trace when there is one, otherwise from the conversation state (toolCallsSource).
  • Searches. origin is TOOL (the bot searched), PREFETCH (the automatic search before every answer) or PRODUCT_FINDER. empty: true means nothing came back.
  • Stats. retrievalShare is the share of customer messages with at least one search. neverReturnedSources lists live sources no search returned in the range: often outdated, duplicated, or worded differently from how customers ask.
  • Gaps. verification is MISSING (not in the knowledge) or PARTIAL (partly covered). RETRIEVAL_MISS gaps, hidden by default, are covered by the knowledge but search did not find the answer: rewording or a Q&A usually fixes them. signals shows thumbs-down and handovers. suggestedAnswerDraft comes from a team member’s reply, with emails and phone numbers masked.
  • Test questions. Each has the sources search must return and the facts the answer must state. A run reports pass or fail per question. Add --prompt-file to totebot tests run to try new instructions without saving them.
Searches are kept for 90 days. For older ranges retrievalDataAvailable is false and the search metrics are null, so they read as not available rather than 0%. Playground conversations are left out of the stats.

What the agent never sees

  • Other teams’ data, or agents the key is not allowed to access.
  • System notes, raw tool output, visitor ids, IP addresses or message metadata.
  • Customer emails and phone numbers, when the key has no customers:read.

Example session

Plain API

Without the CLI, the same calls are in the typed client (totebot.analysis, totebot.gaps, totebot.tests) and in the API reference: