Skip to main content

AI Hub Knowledge Base

This section contains all knowledge base entries (nudges) that inform our AI agents when interacting with end users. Each entry is designed to help agents provide accurate, helpful, and context-aware responses about the Toto ecosystem.

What is a Knowledge Base Entry?​

A knowledge base entry (also called a "nudge") is a structured piece of information that:

  • Provides context about how the Toto ecosystem works
  • Helps agents answer user questions accurately
  • Ensures consistent information across all interactions
  • Covers topics that affect end users (donors, guardians, general public)

Structure​

Each knowledge base entry follows this structure:

interface KnowledgeItem {
id: string;
title: string;
content: string; // Detailed information for the agent
category: string; // e.g., "donations", "case-management", "social-media"
agentTypes: string[]; // Which agents can use this (empty array = available to all agents)
audience: string[]; // Target audience for relevance (e.g., ["donors", "guardians"])
lastUpdated: string;
usageCount: number;
metadata?: {
guardianId?: string; // Optional: for guardian-specific entries
guardianName?: string;
isGuardianSpecific?: boolean;
};
}

Categories​

  • Donations: How donations work, banking aliases, verification, Totitos
  • Case Management: Creating cases, updating cases, case status, guardian roles
  • Social Media: How to share cases, social media links, engagement
  • User Experience: How agents interact, what platforms are available

How Entries Are Used​

  1. RAG (Retrieval Augmented Generation): Agents use semantic search to retrieve relevant entries based on user queries
  2. Context Injection: Retrieved entries are injected into the agent's system prompt
  3. Dynamic Updates: Entries can be updated in toto-bo and are immediately available to agents
  4. Access Control: All KB entries are accessible to all agents - no filtering by guardian
  5. Relevance Scoring: Entries with matching audience get a 20% relevance boost during retrieval
  6. Agent Types: Empty agentTypes array means the entry is available to all agents

Creating New Entries​

New entries are created through:

  1. Conversation Simulation: We simulate user interactions to identify knowledge gaps
  2. Documentation Review: Review existing docs and extract user-facing information
  3. Feedback Analysis: Learn from actual user interactions

Automatic Sync​

The knowledge base documentation is automatically synced from the AI Hub knowledge base:

  1. On Build: The documentation site automatically syncs before building
  2. Manual Sync: Run npm run sync:kb in the toto-docs/app directory
  3. Source of Truth: The knowledge base in toto-ai-hub is the source of truth

Sync Script​

The sync script (scripts/sync-knowledge-base.js):

  • Fetches all entries from the AI Hub API (/api/ai/knowledge)
  • Generates individual markdown files for each entry
  • Creates an index file grouping entries by category
  • Removes orphaned files (entries that no longer exist)

Environment Variables​

Set TOTO_AI_HUB_URL to point to your AI Hub instance:

TOTO_AI_HUB_URL=http://localhost:8080 npm run sync:kb

Files in This Section​

Each entry is documented in a separate markdown file for easy review and maintenance.