Skip to main content

Overview

Knowledge tools enable your AI persona to search uploaded documents and provide accurate, source-based answers using Retrieval-Augmented Generation (RAG). Instead of relying only on the LLM’s training data, your persona can access your organization’s specific documentation, policies, and knowledge base. This guide covers how to create and optimize knowledge tools for maximum accuracy and relevance.

Prerequisites

Before creating knowledge tools, you need:

Creating a Knowledge Tool

  • Stateful (Database-Saved)
Create reusable tools in the Anam Lab that can be attached to multiple personas.
1

Create the tool

Navigate to /tools in the Anam Lab and create your knowledge tool:
  1. Click Create Tool
  2. Select Knowledge Tool
  3. Fill in the configuration:
    • Name: search_product_docs (snake_case)
    • Description: Clear description of when to use this tool
    • Knowledge Folders: Select one or more folders
  4. Click Create Tool
The tool is now saved with a unique ID and appears in your organization’s tool library.
2

Attach tool to persona

Navigate to /build/{personaId} and attach the tool:
  1. Scroll to the Tools section
  2. Click Add Tool
  3. Select search_product_docs from the dropdown
  4. Save the persona
The tool is now attached to this persona. When you create sessions with this persona, the tool will automatically be available.
3

Use in session

Create a session using the persona ID:
const response = await fetch("https://api.anam.ai/v1/auth/session-token", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    personaConfig: {
      personaId: "your-persona-id", // Tools loaded automatically
    },
  }),
});
Stateful tools are ideal when you want to reuse the same tool across multiple personas or manage tools centrally.

How Knowledge Tools Work

When the AI needs information to answer a question, it uses a knowledge tool to search your documents.
1

User asks a question

User: “How do I authenticate API requests?”
2

AI decides to search

The AI determines the question requires information from your documentation and automatically formulates a search query.
The AI is smart about searching. It looks for the meaning behind the user’s question, not just literal keywords.
3

System finds relevant content

The system searches the folders associated with the tool and retrieves the most relevant snippets from your documents.
4

AI generates a response

The AI uses the retrieved information to construct an accurate, conversational answer.“To authenticate API requests, you’ll need to include your API key in the Authorization header like this: Authorization: Bearer YOUR_API_KEY. You can get an API key from your dashboard.”
The user receives an answer grounded in your specific documentation.

Next Steps