Create an AI-ready knowledge base
This guide helps you transform raw data into an AI-ready knowledge base.
Enterprise Knowledge uses a simple hierarchy: sources live inside knowledge bases. After you create a knowledge base, you provide its unique ID to your AI tool, which gives the AI the context it needs to stay on-brand and accurate.
Follow these steps to learn how to structure your data and connect your knowledge to AI tools like Conversation Intelligence.
Think of a knowledge base as your library. It's the container that your AI tools search through.
To create a knowledge base, make a POST request to the knowledge bases endpoint:
1curl -X POST "https://knowledge.twilio.com/v2/ControlPlane/KnowledgeBases" \2-u $TWILIO_API_KEY:$TWILIO_API_SECRET \3-H "Content-Type: application/json" \4-d '{5"displayName": "my-knowledge-base"6}'
Save the knowledge base ID that you'll receive (for example, KBxxxxxxxxxx). You need this ID to link your knowledge to CINTEL or TAC in Step 3.
For more details, see the knowledge bases API reference.
Add the actual source information to your knowledge base. You can use a website URL, raw text, or upload a file.
To add a website source, make a POST request to the knowledge sources endpoint with your kbId:
1curl -X POST "https://knowledge.twilio.com/v2/KnowledgeBases/KBxxxxxxxxxx/Knowledge" \2-u $TWILIO_API_KEY:$TWILIO_API_SECRET \3-H "Content-Type: application/json" \4-d '{5"name": "Product Documentation",6"description": "Official product guides and API documentation",7"source": {8"type": "web",9"url": {10"web": "https://example.com/docs",11"crawlDepth": 3,12"crawlPeriod": "WEEKLY"13}14}15}'
Use your knowledge base with Twilio Agent Connect (TAC) or Conversation Intelligence (CINTEL) to provide AI context.
Most Twilio AI features require you to pass the kbId in the tool's configuration or with the Assistant API.
To give your agents real-time suggestions based on your knowledge:
- In the Twilio Console, navigate to your Assistant configuration.
- Paste your
kbIdinto the Knowledge Management section. - When an agent is queried, TAC semantically searches this specific
kbIdto suggest a response.
To use knowledge for automated analysis, attach your knowledge base to an intelligence configuration. Make a PUT request to the Intelligence Configuration resource with your knowledge base ID in the context.knowledge.bases array:
1curl -X PUT "https://intelligence.twilio.com/v3/ControlPlane/Configurations/<INTELLIGENCE_CONFIGURATION_ID>" \2-u $TWILIO_API_KEY:$TWILIO_API_SECRET \3-H "Content-Type: application/json" \4-d '{5"displayName": "real-time-intelligence-config",6"description": "Intelligence configuration with knowledge context",7"rules": [8{9"operators": [10{11"id": "<OPERATOR_ID>"12}13],14"triggers": [15{16"on": "COMMUNICATION",17"parameters": {18"count": 219}20}21],22"actions": [23{24"type": "WEBHOOK",25"method": "POST",26"url": "https://your-webhook-endpoint.com/rule-action"27}28],29"context": {30"memory": {31"enabled": true32},33"knowledge": {34"bases": [35"KBxxxxxxxxxx"36]37}38}39}40]41}'
For step-by-step instructions, see Create an intelligence configuration.
After linking your knowledge base, you can use Custom Language Operators to access this data as Context. In your Operator definition, enable knowledge_retrieval. The AI then:
- Listens to the live conversation.
- Searches your knowledge base for relevant facts. For example, "What is our 30-day refund policy?"
- Determines if the agent is providing information that matches your documentation.
For more information, see Language Operators.
To ensure your AI tools provide accurate answers and avoid hallucinations:
- Remove contradictory content: Sources with conflicting information confuse semantic search and increase hallucination risk. Review and reconcile any duplicate or conflicting information before adding to your knowledge base.
- Use consistent terminology: Define key terms once and use them consistently throughout your sources. For example, use "refund policy" or "return policy" consistently, not both interchangeably.
- Avoid speculative content: Stick to facts and documented information. Avoid marketing language, opinions, or phrases like "likely," "probably," or "expected to" that the AI might treat as definitive facts.
- Chunk content: When using text sources, keep snippets focused and organized. Break large documents into logical sections by topic instead of pasting entire manuals into one field.
- Use clear formatting: Use Markdown-style headers in raw text. This helps the semantic indexer understand your content hierarchy.
- Set recrawl frequency: If your website changes frequently, set
crawlPeriodtoWEEKLYto keep the AI up to date with your latest information. - Write descriptive source names: Give each knowledge source a clear description. CINTEL uses these descriptions to determine which source is most relevant to specific conversation topics.
- Configure permissions: Ensure your API key has the appropriate
ControlPlanepermissions to read and write to knowledge resources.