Knowledge base

Give an agent documents to answer from, instead of putting every fact in the prompt.

A knowledge base is a set of documents an agent searches during the call. Use it for facts that are too long or change too often for the prompt: price lists, policies, opening hours, product details.

Each agent has one knowledge base. It is created the first time you add a document.

How it works

When you add a document, Dialgem splits it into passages and indexes them. On each turn the agent looks up the passages closest to what the caller said and gives them to the model. An agent with no documents skips the lookup, so it costs nothing.

Add a document

Send the document's text and a filename.

curl
curl https://api.dialgem.com/v1/agents/AGENT_ID/knowledge \
  -H "X-API-Key: $DIALGEM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "opening-hours.md",
    "content": "The clinic is open Monday to Friday, 8am to 6pm."
  }'

The reply gives a source_id, the number of passages (chunk_count) and whether indexing finished (embedded). A document may be up to 500,000 characters. In the dashboard you can upload .txt and .md files instead.

List documents with GET /v1/agents/{agent_id}/knowledge. Remove one with DELETE /v1/agents/{agent_id}/knowledge/{source_id}. To change a document, delete it and add the new version.

Write documents the agent can use

  • One topic per document, with clear headings. The agent retrieves passages, not whole files.
  • Plain statements, such as "A cleaning costs $90", rather than tables of numbers that lose their labels when split up.
  • Say it the way callers ask. If callers say "do you take insurance", include that wording.
  • Keep it current. The agent will repeat an out-of-date price confidently.

Documents are not private from the agent

Anything in the knowledge base can be spoken aloud on a call. Do not add content the caller should not hear.

In flow agents

A flow can attach knowledge to the whole flow or to a single node, and tune how many passages are retrieved and how close they must be to count. See Flow agents.